-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (169 loc) · 5.99 KB
/
Copy pathvalidate.yml
File metadata and controls
181 lines (169 loc) · 5.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: validate
on:
pull_request:
branches: [main]
push:
branches: [main]
jobs:
setup:
name: CI - 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: CI - No changes to validate
needs: setup
if: needs.setup.outputs.any != 'true'
runs-on: ubuntu-latest
steps:
- run: echo "No place_*.md files changed - skipping validation"
L7-graph-sync:
name: L7 - Graph edge consistency
needs: [setup, L3-state-files, L4-road-files, L5-node-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_sync.py ${{ needs.setup.outputs.files }}
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