chore: migrate L1 language validator to lingua detector #234
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: validate | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| jobs: | |
| setup: | |
| name: Detect changed files | |
| runs-on: ubuntu-latest | |
| outputs: | |
| files: ${{ steps.changed.outputs.files }} | |
| any: ${{ steps.changed.outputs.any }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get changed place_*.md files | |
| id: changed | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| RANGE="origin/${{ github.base_ref }}...HEAD" | |
| else | |
| BEFORE="${{ github.event.before }}" | |
| if [ "$BEFORE" = "0000000000000000000000000000000000000000" ] || ! git cat-file -e "$BEFORE" 2>/dev/null; then | |
| BEFORE="HEAD~1" | |
| fi | |
| RANGE="$BEFORE..HEAD" | |
| fi | |
| RAW=$(git diff --name-only --diff-filter=ACMRT "$RANGE" | { grep 'place_.*\.md$' || true; }) | |
| EXPANDED="$RAW" | |
| for f in $RAW; do | |
| case "$f" in | |
| roads/*/place_*.md) | |
| road_dir=$(dirname "$f") | |
| road=$(basename "$road_dir") | |
| stem=$(basename "$f" .md) | |
| if [ "$stem" = "place_${road}" ] || [ "$stem" = "place_the_${road}" ]; then | |
| EXPANDED="$EXPANDED $(find "$road_dir" -maxdepth 1 -name 'place_*.md' -type f)" | |
| fi | |
| ;; | |
| esac | |
| done | |
| FILES=$(printf '%s\n' $EXPANDED | sort -u | tr '\n' ' ' | sed 's/ *$//') | |
| if [ -n "$FILES" ]; then | |
| echo "files=$FILES" >> "$GITHUB_OUTPUT" | |
| echo "any=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "files=" >> "$GITHUB_OUTPUT" | |
| echo "any=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| L0-stamp-check: | |
| name: L0 - Validation stamp | |
| needs: setup | |
| if: needs.setup.outputs.any == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Verify local validation was run | |
| run: | | |
| if [ ! -f ".validation-stamp" ]; then | |
| echo "❌ No .validation-stamp found." | |
| echo "" | |
| echo "Install the pre-commit hook and run locally first:" | |
| echo " git config core.hooksPath .githooks" | |
| exit 1 | |
| fi | |
| STAMP=$(cat .validation-stamp | tr -d '[:space:]') | |
| # Recompute content tree without the stamp file (mirrors pre-commit hook logic) | |
| CONTENT_TREE=$(git ls-tree HEAD | grep -v '\.validation-stamp' | git mktree) | |
| if [ "$STAMP" != "$CONTENT_TREE" ]; then | |
| echo "❌ Validation stamp is stale." | |
| echo " Stamp: $STAMP" | |
| echo " Content tree: $CONTENT_TREE" | |
| echo "" | |
| echo "Commit via the pre-commit hook to refresh the stamp." | |
| exit 1 | |
| fi | |
| echo "✓ Validation stamp matches content tree ($CONTENT_TREE)" | |
| L1-all-files: | |
| name: L1 - Encoding, forbidden chars, english-only | |
| needs: [setup, L0-stamp-check] | |
| if: needs.setup.outputs.any == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - run: pip install -r tests/requirements.txt | |
| - run: python3 tests/validate_general.py ${{ needs.setup.outputs.files }} | |
| - run: python3 tests/validate_language.py ${{ needs.setup.outputs.files }} | |
| L2-typed-files: | |
| name: L2 - Section structure and navigation links | |
| needs: [setup, L1-all-files] | |
| if: needs.setup.outputs.any == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - run: python3 scripts/validate_navigation_links.py ${{ needs.setup.outputs.files }} | |
| - run: python3 scripts/validate_stop_naming.py ${{ needs.setup.outputs.files }} | |
| L3-state-files: | |
| name: L3 - State file rules | |
| needs: [setup, L2-typed-files] | |
| if: needs.setup.outputs.any == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - run: python3 scripts/validate_states.py ${{ needs.setup.outputs.files }} | |
| L4-road-files: | |
| name: L4 - Road index and km chain | |
| needs: [setup, L2-typed-files] | |
| if: needs.setup.outputs.any == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - run: python3 scripts/validate_roads.py ${{ needs.setup.outputs.files }} | |
| - run: python3 scripts/validate_roads_km.py ${{ needs.setup.outputs.files }} | |
| L5-node-files: | |
| name: L5 - Node km math | |
| needs: [setup, L2-typed-files] | |
| if: needs.setup.outputs.any == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - run: python3 scripts/validate_roads_km_math.py ${{ needs.setup.outputs.files }} | |
| no-changes: | |
| name: No place_*.md files changed | |
| needs: setup | |
| if: needs.setup.outputs.any != 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: echo "No place_*.md files changed - skipping validation" | |
| L6-deploy-bundles: | |
| name: L6 - Deploy bundle integrity | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Check autobahn.md bundle integrity | |
| run: python3 scripts/deploy.py --check autobahn.md | |