-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (128 loc) · 4.4 KB
/
Copy pathvalidate.yml
File metadata and controls
138 lines (128 loc) · 4.4 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
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