chore: migrate L1 language validator to lingua detector #229
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 | |
| L1-all-files: | |
| name: L1 - Encoding, forbidden chars, english-only | |
| needs: setup | |
| 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" | |
| deploy-check: | |
| name: Check deploy bundles | |
| 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 | |