Repository navigation
251 lines (244 loc) · 9.07 KB
/
Copy pathpull-request.yml
File metadata and controls
251 lines (244 loc) · 9.07 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
name: Pull Request
on:
pull_request:
types: [opened, synchronize, reopened, edited]
permissions:
contents: read
jobs:
resolve-toolbox:
name: Pull Toolbox
runs-on: ubuntu-latest
outputs:
image: ${{ steps.image.outputs.image }}
steps:
- name: Resolve Toolbox Image
id: image
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
set -euo pipefail
toolbox_image=$(sed -nE 's/^[[:space:]]*toolbox_image=([^[:space:]]+)[[:space:]]*$/\1/p' <<< "$PR_BODY" | head -n 1)
if [ -n "$toolbox_image" ]; then
if [[ ! "$toolbox_image" =~ ^ghcr\.io/[A-Za-z0-9-]+/toolbox(:[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}|@sha256:[0-9a-f]{64})$ ]]; then
echo "Invalid Toolbox image: $toolbox_image" >&2
exit 1
fi
image="$toolbox_image"
else
image='ghcr.io/nzp-team/toolbox:main'
fi
echo "image=$image" >> "$GITHUB_OUTPUT"
echo "Toolbox Image: \`$image\`" >> "$GITHUB_STEP_SUMMARY"
resolve-refs:
name: Resolve Dependency Refs
runs-on: ubuntu-latest
outputs:
quakec_ref: ${{ steps.refs.outputs.quakec_ref }}
vril_ref: ${{ steps.refs.outputs.vril_ref }}
steps:
- name: Read dependency refs
id: refs
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
set -euo pipefail
quakec_ref=$(sed -nE 's/^[[:space:]]*quakec_ref=([^[:space:]]+)[[:space:]]*$/\1/p' <<< "$PR_BODY" | head -n 1)
vril_ref=$(sed -nE 's/^[[:space:]]*vril_ref=([^[:space:]]+)[[:space:]]*$/\1/p' <<< "$PR_BODY" | head -n 1)
{
echo "quakec_ref=$quakec_ref"
echo "vril_ref=$vril_ref"
} >> "$GITHUB_OUTPUT"
discover-maps:
name: Discover Maps
runs-on: ubuntu-latest
outputs:
maps: ${{ steps.maps.outputs.maps }}
steps:
- name: Checkout PR merge commit
uses: actions/checkout@v4
with:
fetch-depth: 2
persist-credentials: false
- name: List Maps
id: maps
env:
PR_MERGE_SHA: ${{ github.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
test "$(git rev-parse HEAD)" = "$PR_MERGE_SHA"
test "$(git rev-parse 'HEAD^2')" = "$PR_HEAD_SHA"
maps=$(find source/maps -type f -name '*.map' | awk -F/ 'NF == 4 && $4 == $3 ".map" { print $3 }' | jq -Rsc 'split("\n") | map(select(length > 0)) | sort')
test "$maps" != '[]' && echo "maps=$maps" >> "$GITHUB_OUTPUT"
assets-tests:
name: ${{ matrix.name }}
needs: [resolve-toolbox, resolve-refs]
runs-on: ubuntu-latest
container:
image: ${{ needs.resolve-toolbox.outputs.image }}
strategy:
matrix:
include:
- name: Verify .MAP files conform
test: map_validator
- name: Verify referenced map assets exist
test: map_assets_exist
- name: Verify WAD textures conform
test: wad_texture_conformity
- name: Verify MDL models conform
test: mdl_validator
- name: Verify WAV sounds conform
test: wav_validator
- name: Verify PCX textures conform
test: pcx_validator
- name: Validate waypoint paths
test: pathfind
defaults:
run:
shell: bash
steps:
- name: Toolbox Fetch
env:
TOOLBOX_HOST_OS: Linux
TOOLBOX_HOST_ARCH: x86_64
run: /entrypoint.sh fetch
- name: Select assets PR merge commit
env:
PR_MERGE_REF: ${{ github.ref }}
PR_MERGE_SHA: ${{ github.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
git -C /workspace/repos/assets fetch origin "$PR_MERGE_REF"
git -C /workspace/repos/assets checkout --detach FETCH_HEAD
test "$(git -C /workspace/repos/assets rev-parse HEAD)" = "$PR_MERGE_SHA"
test "$(git -C /workspace/repos/assets rev-parse 'HEAD^2')" = "$PR_HEAD_SHA"
{
echo "Assets PR head: \`$PR_HEAD_SHA\`"
echo "Tested merge commit: \`$PR_MERGE_SHA\`"
} >> "$GITHUB_STEP_SUMMARY"
- name: Select dependency overrides
if: needs.resolve-refs.outputs.quakec_ref != '' || needs.resolve-refs.outputs.vril_ref != ''
env:
QUAKEC_REF: ${{ needs.resolve-refs.outputs.quakec_ref }}
VRIL_REF: ${{ needs.resolve-refs.outputs.vril_ref }}
PR_HEAD_OWNER: ${{ github.event.pull_request.head.repo.owner.login }}
run: |
set -euo pipefail
for dependency in quakec vril; do
case "$dependency" in
quakec) repository=quakec; ref="$QUAKEC_REF" ;;
vril) repository=vril-engine; ref="$VRIL_REF" ;;
esac
[ -n "$ref" ] || continue
directory="/workspace/repos/$repository"
git -C "$directory" fetch "https://github.com/${PR_HEAD_OWNER}/${repository}.git" "$ref"
git -C "$directory" checkout --detach FETCH_HEAD
echo "${repository} override: \`${PR_HEAD_OWNER}/${repository}@$(git -C "$directory" rev-parse HEAD)\` (requested \`$ref\`)" >> "$GITHUB_STEP_SUMMARY"
done
- name: Run
env:
ASSETS_TEST: ${{ matrix.test }}
run: /entrypoint.sh test-assets "$ASSETS_TEST"
- name: Upload pathfind reports
if: always() && matrix.test == 'pathfind'
uses: actions/upload-artifact@v4
with:
name: pathfind-reports
path: /workspace/repos/assets/tmp/pathfind
if-no-files-found: warn
map-tests:
name: Compile ${{ matrix.map }}
needs: [resolve-toolbox, discover-maps]
runs-on: ubuntu-latest
container:
image: ${{ needs.resolve-toolbox.outputs.image }}
strategy:
fail-fast: false
matrix:
map: ${{ fromJSON(needs.discover-maps.outputs.maps) }}
defaults:
run:
shell: bash
steps:
- name: Toolbox Fetch
env:
TOOLBOX_HOST_OS: Linux
TOOLBOX_HOST_ARCH: x86_64
run: /entrypoint.sh fetch
- name: Select assets PR merge commit
env:
PR_MERGE_REF: ${{ github.ref }}
PR_MERGE_SHA: ${{ github.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
git -C /workspace/repos/assets fetch origin "$PR_MERGE_REF"
git -C /workspace/repos/assets checkout --detach FETCH_HEAD
test "$(git -C /workspace/repos/assets rev-parse HEAD)" = "$PR_MERGE_SHA"
test "$(git -C /workspace/repos/assets rev-parse 'HEAD^2')" = "$PR_HEAD_SHA"
{
echo "Assets PR head: \`$PR_HEAD_SHA\`"
echo "Tested merge commit: \`$PR_MERGE_SHA\`"
} >> "$GITHUB_STEP_SUMMARY"
- name: Compile Map
env:
MAP: ${{ matrix.map }}
run: /entrypoint.sh build-map --map "$MAP" --full
- name: Upload compiled map
uses: actions/upload-artifact@v4
with:
name: map-${{ matrix.map }}
path: |
/workspace/repos/assets/common/maps/${{ matrix.map }}.bsp
/workspace/repos/assets/common/maps/${{ matrix.map }}.nsz
if-no-files-found: error
assemble-assets:
name: Assemble Assets
needs: [resolve-toolbox, discover-maps, map-tests]
runs-on: ubuntu-latest
container:
image: ${{ needs.resolve-toolbox.outputs.image }}
defaults:
run:
shell: bash
steps:
- name: Toolbox Fetch
env:
TOOLBOX_HOST_OS: Linux
TOOLBOX_HOST_ARCH: x86_64
run: /entrypoint.sh fetch
- name: Select assets PR merge commit
env:
PR_MERGE_REF: ${{ github.ref }}
PR_MERGE_SHA: ${{ github.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
git -C /workspace/repos/assets fetch origin "$PR_MERGE_REF"
git -C /workspace/repos/assets checkout --detach FETCH_HEAD
test "$(git -C /workspace/repos/assets rev-parse HEAD)" = "$PR_MERGE_SHA"
test "$(git -C /workspace/repos/assets rev-parse 'HEAD^2')" = "$PR_HEAD_SHA"
{
echo "Assets PR head: \`$PR_HEAD_SHA\`"
echo "Tested merge commit: \`$PR_MERGE_SHA\`"
} >> "$GITHUB_STEP_SUMMARY"
- name: Download compiled maps
uses: actions/download-artifact@v4
with:
pattern: map-*
path: /workspace/repos/assets/common/maps
merge-multiple: true
- name: Verify compiled maps
env:
MAPS: ${{ needs.discover-maps.outputs.maps }}
run: |
jq -r '.[]' <<< "$MAPS" | while IFS= read -r map; do
test -s "/workspace/repos/assets/common/maps/$map.bsp"
done
- name: Build archives
run: |
/entrypoint.sh build-wads
/entrypoint.sh build-assets
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: assembled-assets-pr
path: /workspace/repos/assets/tmp/*.zip
if-no-files-found: error