Skip to content

Merge pull request #69 from ChBrain/fix/a20-german-bleed #174

Merge pull request #69 from ChBrain/fix/a20-german-bleed

Merge pull request #69 from ChBrain/fix/a20-german-bleed #174

Workflow file for this run

name: validate
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
validate-places:
name: Validate place_*.md files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- 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
# --diff-filter=ACMRT skips deletions; the validator must not be handed paths that no longer exist.
RAW=$(git diff --name-only --diff-filter=ACMRT "$RANGE" | { grep 'place_.*\.md$' || true; })
# When a road index file changes, expand to its sibling nodes - their
# km math depends on the index. Without this, an index-only edit
# would leave node files unvalidated against the new chain.
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/ *$//')
echo "files=$FILES" >> "$GITHUB_OUTPUT"
- name: Validate changed files
if: steps.changed.outputs.files != ''
run: python3 scripts/validate.py ${{ steps.changed.outputs.files }}
- name: Show validator results
if: steps.changed.outputs.files != ''
run: python3 scripts/validate.py --checks ${{ steps.changed.outputs.files }}
- name: No place_*.md files changed
if: steps.changed.outputs.files == ''
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