forked from LandSandBoat/server
-
Notifications
You must be signed in to change notification settings - Fork 0
334 lines (300 loc) · 10.4 KB
/
Copy pathpr_checks.yml
File metadata and controls
334 lines (300 loc) · 10.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
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# Set DEVTOOLS_IMAGE repo var to use a different devtools image. Default: ghcr.io/landsandboat/devtools:ubuntu
name: PR Checks
on:
pull_request:
types:
- opened
- synchronize
- reopened
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
# # Available machines:
# # https://github.com/actions/runner-images/tree/main
jobs:
Sanity_Checks:
name: Sanity Checks
runs-on: ubuntu-latest
container:
image: ${{ vars.DEVTOOLS_IMAGE || 'ghcr.io/landsandboat/devtools:ubuntu' }}
defaults:
run:
shell: bash
steps:
# github.workspace is the workspace in the runner (/home/runner/work/server/server)
# $GITHUB_WORKSPACE is the workspace in the container (/__w/server/server)
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade -r ./tools/requirements.txt
- name: Run checks
run: ./tools/ci/sanity_checks.sh origin/${{ github.event.pull_request.base.ref }}
- name: Add sanity checks report to summary
if: ${{ always() }}
run: tr -d '\r' < sanity_checks_summary.md >> $GITHUB_STEP_SUMMARY
- name: Upload changed files as artifact
uses: actions/upload-artifact@v7
with:
name: changed-files
path: changed-files.txt
continue-on-error: true
Lua_Language_Server:
name: Lua Language Server
needs: Sanity_Checks
runs-on: ubuntu-latest
container:
image: ${{ vars.DEVTOOLS_IMAGE || 'ghcr.io/landsandboat/devtools:ubuntu' }}
defaults:
run:
shell: bash
steps:
- name: Download Changed Files
uses: actions/download-artifact@v8
with:
name: changed-files
- name: Check For Changed Lua Files
id: check-changes
run: |
mapfile -t changed_files < changed-files.txt
lua_changes=false
for changed_file in ${changed_files[@]}; do
if [[ $changed_file == scripts/**/*.lua || $changed_file == modules/**/*.lua ]]; then
lua_changes=true
break
fi
done
echo "lua_changes=$lua_changes" >> $GITHUB_OUTPUT
- run: git config --global --add safe.directory $GITHUB_WORKSPACE
- uses: actions/checkout@v6
if: ${{ steps.check-changes.outputs.lua_changes == 'true' }}
with:
fetch-depth: 0
- name: Install Python dependencies
if: ${{ steps.check-changes.outputs.lua_changes == 'true' }}
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade -r ./tools/requirements.txt
- name: Generate codegen Lua enums
if: ${{ steps.check-changes.outputs.lua_changes == 'true' }}
run: python -m tools.codegen "$RUNNER_TEMP/codegen-out"
- name: Run Lua Language Server
id: run_lls
if: ${{ steps.check-changes.outputs.lua_changes == 'true' }}
run: python ./tools/ci/lua_lang_server.py
- name: Summarize run
id: summarize_run
if: ${{ steps.check-changes.outputs.lua_changes == 'true' }}
run: |
found_issues=false
check_file=lua_lang_errors.txt
if [[ -f "$check_file" && -s "$check_file" ]]; then
found_issues=true
echo "## :x: Run Failed" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
tr -d '\r' < "$check_file" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
if [[ "$found_issues" == "false" ]]; then
if [[ "${{ steps.run_lls.outcome }}" == "success" ]]; then
echo "## :heavy_check_mark: All checks passed." >> $GITHUB_STEP_SUMMARY
else
echo "## :x: Lua Language Server had errors, but no specific output was found." >> $GITHUB_STEP_SUMMARY
echo "Check the logs step for details." >> $GITHUB_STEP_SUMMARY
found_issues=true
fi
fi
echo "issues_found=$found_issues" >> $GITHUB_OUTPUT
- name: Fail Workflow if Checks Failed
if: ${{ steps.check-changes.outputs.lua_changes == 'true' && (steps.run_lls.outcome == 'failure' || steps.summarize_run.outputs.issues_found == 'true') }}
run: |
echo "Lua Language Server failed. See summary for details."
exit 1
Schema_Validation:
needs: Sanity_Checks
name: Data validation
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Download Changed Files
uses: actions/download-artifact@v8
with:
name: changed-files
- name: Check for data/ or codegen changes
id: changed
run: |
mapfile -t changed_files < changed-files.txt
touched=false
for f in "${changed_files[@]}"; do
if [[ $f == data/* || $f == tools/codegen/* ]]; then
touched=true
break
fi
done
echo "touched=$touched" >> "$GITHUB_OUTPUT"
echo "Touched: $touched"
- uses: actions/checkout@v6
if: steps.changed.outputs.touched == 'true'
- name: Setup Python
if: steps.changed.outputs.touched == 'true'
uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Install Python dependencies
if: steps.changed.outputs.touched == 'true'
run: python -m pip install jinja2 jsonschema pyyaml
- name: Run codegen --validate
if: steps.changed.outputs.touched == 'true'
run: |
mkdir -p "$RUNNER_TEMP/codegen-out"
python -m tools.codegen "$RUNNER_TEMP/codegen-out" --validate
Formatting:
needs: Sanity_Checks
name: Data formatting
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Download Changed Files
uses: actions/download-artifact@v8
with:
name: changed-files
- name: Filter data/ changed files
id: changed
run: |
mapfile -t changed_files < changed-files.txt
data_files=()
for f in "${changed_files[@]}"; do
if [[ $f == data/* ]]; then
data_files+=("$f")
fi
done
echo "files=${data_files[*]}" >> "$GITHUB_OUTPUT"
echo "Changed data files: ${data_files[*]}"
- uses: actions/checkout@v6
if: steps.changed.outputs.files != ''
- name: Cache prettier results
if: steps.changed.outputs.files != ''
uses: actions/cache@v5
with:
path: /tmp/prettier-cache
key: prettier-cache-${{ hashFiles('data/**/*.yaml', 'data/**/*.json') }}
restore-keys: prettier-cache-
- name: Run prettier
if: steps.changed.outputs.files != ''
run: |
set +e
FAILED=$(npx --yes prettier@3 --cache --cache-strategy content --cache-location /tmp/prettier-cache --list-different ${{ steps.changed.outputs.files }})
set -e
if [ -z "$FAILED" ]; then
echo "All files use Prettier code style!"
exit 0
fi
echo "::group::Files needing reformat"
echo "$FAILED"
echo "::endgroup::"
echo "::group::Diff"
for f in $FAILED; do
diff -u "$f" <(npx --yes prettier@3 "$f") || true
done
echo "::endgroup::"
echo "Run \`npx prettier --write data\` locally to fix."
exit 1
Clang_Tidy:
needs: Sanity_Checks
name: Clang Tidy
uses: ./.github/workflows/runner_build.yml
with:
runner: ubuntu-26.04
compiler: clang
compiler_version: 22
build_type: Debug
build_modules: false
tracy: false
upload_artifact: false
clang_tidy: true
optional_build: true
Build:
needs: Sanity_Checks
name: ${{ matrix.runner && 'Build' || '' }} # GitHub Actions hack to hide matrix args
strategy:
fail-fast: false
matrix:
include:
- build_type: Debug
runner: windows-2025
compiler: msvc
build_modules: false
- build_type: Debug
runner: macos-26
compiler: appleClang
build_modules: false
- build_type: Debug
runner: ubuntu-26.04
compiler: gcc
compiler_version: 15
build_modules: false
uses: ./.github/workflows/runner_build.yml
with:
runner: ${{ matrix.runner }}
compiler: ${{ matrix.compiler }}
compiler_version: ${{ matrix.compiler_version }}
build_type: ${{ matrix.build_type }}
build_modules: ${{ matrix.build_modules }}
upload_artifact: true
Test:
needs: Build
if: ${{ !cancelled() && needs.Build.result == 'success' }}
name: ${{ matrix.runner && 'Test' || '' }} # GitHub Actions hack to hide matrix args
strategy:
fail-fast: false
matrix:
include:
- runner: windows-2025
test_modules: false
multi_process: true
xi_test: true
startup_checks: true
- runner: macos-26
test_modules: false
multi_process: false
xi_test: true
startup_checks: true
- runner: ubuntu-26.04
test_modules: false
multi_process: false
xi_test: true
startup_checks: true
uses: ./.github/workflows/runner_test.yml
with:
runner: ${{ matrix.runner }}
test_modules: ${{ matrix.test_modules }}
multi_process: ${{ matrix.multi_process }}
xi_test: ${{ matrix.xi_test }}
startup_checks: ${{ matrix.startup_checks }}
# Docker_Build:
# needs: Sanity_Checks
# name: Build
# uses: ./.github/workflows/docker_build.yml
# with:
# os: ubuntu
# compiler: gcc14
# build_type: Debug
# build_modules: false
# tracy: false
# upload_artifact: true
# Docker_Test:
# needs: Docker_Build
# name: Test
# uses: ./.github/workflows/docker_test.yml
# with:
# os: ubuntu
# test_modules: false
# multi_process: false