Repository navigation
412 lines (403 loc) · 15.7 KB
/
Copy pathunit-tests.yml
File metadata and controls
412 lines (403 loc) · 15.7 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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
name: Unit Tests
on:
push:
pull_request:
workflow_call:
inputs:
full:
description: Run the complete suite instead of selecting affected owners
required: false
default: true
type: boolean
allow_proposed_coverage_waivers:
description: Continue through coverage gaps with proposed waivers
required: false
default: false
type: boolean
workflow_dispatch:
inputs:
full:
description: Run the complete suite instead of selecting affected owners
required: false
default: true
type: boolean
allow_proposed_coverage_waivers:
description: Continue through coverage gaps with proposed waivers
required: false
default: false
type: boolean
permissions:
contents: read
jobs:
select:
name: Select affected unit owners
runs-on: ubuntu-24.04
outputs:
selection: ${{ steps.select.outputs.selection }}
run: ${{ steps.select.outputs.run }}
platform_unix: ${{ steps.select.outputs.platform_unix }}
platform_windows: ${{ steps.select.outputs.platform_windows }}
platform_dos16: ${{ steps.select.outputs.platform_dos16 }}
platform_dos32: ${{ steps.select.outputs.platform_dos32 }}
unix_matrix: ${{ steps.select.outputs.unix_matrix }}
watcom_matrix: ${{ steps.select.outputs.watcom_matrix }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Select exact source/function owners
id: select
env:
EVENT_NAME: ${{ github.event_name }}
PUSH_BASE: ${{ github.event.before }}
PR_BASE: ${{ github.event.pull_request.base.sha }}
FORCE_FULL: ${{ inputs.full }}
run: |
options=(--github-output "$GITHUB_OUTPUT")
if [[ "$FORCE_FULL" == true || "$EVENT_NAME" == workflow_dispatch ]]; then
options+=(--full)
elif [[ "$EVENT_NAME" == pull_request ]]; then
options+=(--base "$PR_BASE" --head HEAD)
elif [[ -z "$PUSH_BASE" || "$PUSH_BASE" =~ ^0+$ ]]; then
options+=(--full)
else
options+=(--base "$PUSH_BASE" --head HEAD)
fi
python3 unit/tools/selector.py "${options[@]}"
validate:
name: Inventory and framework
needs: select
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- name: Validate generated inventory and registered ownership
run: |
python3 unit/tools/inventory.py --check
python3 unit/tools/check.py
python3 -m unittest discover -s unit/tools -p 'test_*.py' -v
- name: Exercise the C89 runtime
run: |
clang -std=c89 -pedantic -Wall -Wextra -Werror \
-I unit/framework unit/framework/ut.c unit/framework/selftest.c \
-o "$RUNNER_TEMP/unit-selftest"
"$RUNNER_TEMP/unit-selftest" "$RUNNER_TEMP/unit-selftest.cov"
unix:
name: ${{ matrix.platform }} native and LLVM
needs: [select, validate]
if: needs.select.outputs.platform_unix == 'true'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.select.outputs.unix_matrix) }}
steps:
- uses: actions/checkout@v7
- name: Install and show LLVM tools
run: |
sudo apt-get update
sudo apt-get install --yes llvm
clang --version
llvm-profdata --version
llvm-cov --version
- name: Run registered cases with both coverage oracles
env:
UNIT_SELECTION: ${{ needs.select.outputs.selection }}
run: >-
mkdir -p build &&
printf '%s' "$UNIT_SELECTION" > build/unit-selection.json &&
python3 unit/tools/run.py
--platform "${{ matrix.platform }}"
--selection build/unit-selection.json
--coverage
${{ inputs.allow_proposed_coverage_waivers && '--allow-proposed-coverage-waivers' || '' }}
--build "build/unit-${{ matrix.platform }}"
- name: Upload detailed coverage records
if: always()
uses: actions/upload-artifact@v7
with:
name: unit-${{ matrix.platform }}-coverage
path: |
build/unit-${{ matrix.platform }}/*.coverage.json
build/unit-${{ matrix.platform }}/*.native-coverage.json
build/unit-${{ matrix.platform }}/*.mcc.txt
if-no-files-found: warn
macos:
name: macOS ${{ matrix.platform }} native and LLVM
needs: [select, validate]
if: needs.select.outputs.platform_unix == 'true'
runs-on: macos-15
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.select.outputs.unix_matrix) }}
steps:
- uses: actions/checkout@v7
- name: Select current Homebrew LLVM
run: |
if ! brew list llvm >/dev/null 2>&1; then
brew install llvm
fi
echo "$(brew --prefix llvm)/bin" >> "$GITHUB_PATH"
- name: Run registered cases with both coverage oracles
env:
UNIT_SELECTION: ${{ needs.select.outputs.selection }}
run: >-
mkdir -p build &&
printf '%s' "$UNIT_SELECTION" > build/unit-selection.json &&
python3 unit/tools/run.py
--platform "${{ matrix.platform }}"
--selection build/unit-selection.json
--coverage
--native-flag=-Wno-unused-but-set-global
${{ inputs.allow_proposed_coverage_waivers && '--allow-proposed-coverage-waivers' || '' }}
--build "build/unit-macos-${{ matrix.platform }}"
- name: Upload detailed coverage records
if: always()
uses: actions/upload-artifact@v7
with:
name: unit-macos-${{ matrix.platform }}-coverage
path: |
build/unit-macos-${{ matrix.platform }}/*.coverage.json
build/unit-macos-${{ matrix.platform }}/*.native-coverage.json
build/unit-macos-${{ matrix.platform }}/*.mcc.txt
if-no-files-found: warn
windows:
name: Windows ${{ matrix.architecture }} native
needs: [select, validate]
if: needs.select.outputs.platform_windows == 'true'
runs-on: windows-2025
strategy:
fail-fast: false
matrix:
architecture: [x86, x64]
steps:
- uses: actions/checkout@v7
- name: Detect LLVM profiling support
id: llvm-profile
shell: pwsh
run: |
$arguments = @('-print-file-name=clang_rt.profile.lib')
if ('${{ matrix.architecture }}' -eq 'x86') {
$arguments = @('-m32') + $arguments
}
$runtime = (& clang @arguments | Select-Object -Last 1).Trim()
$available = Test-Path -LiteralPath $runtime
"available=$($available.ToString().ToLowerInvariant())" >> $env:GITHUB_OUTPUT
Write-Host "LLVM profile runtime: $runtime (available: $available)"
- name: Show LLVM tools
shell: pwsh
run: |
clang --version
llvm-profdata --version
llvm-cov --version
- name: Run registered Windows cases
shell: pwsh
env:
UNIT_SELECTION: ${{ needs.select.outputs.selection }}
run: |
New-Item -ItemType Directory -Force build | Out-Null
Set-Content -NoNewline -Path build/unit-selection.json -Value $env:UNIT_SELECTION
python unit/tools/run.py `
--platform windows `
--windows-architecture ${{ matrix.architecture }} `
--windows-abi msvc `
--selection build/unit-selection.json `
--cc clang `
--clang clang `
${{ steps.llvm-profile.outputs.available == 'true' && '--coverage' || '' }} `
${{ inputs.allow_proposed_coverage_waivers && '--allow-proposed-coverage-waivers' || '' }} `
--build build/unit-windows-${{ matrix.architecture }}
- name: Upload detailed coverage records
if: always()
uses: actions/upload-artifact@v7
with:
name: unit-windows-${{ matrix.architecture }}-coverage
path: |
build/unit-windows-${{ matrix.architecture }}/*.coverage.json
build/unit-windows-${{ matrix.architecture }}/*.native-coverage.json
build/unit-windows-${{ matrix.architecture }}/*.mcc.txt
if-no-files-found: warn
watcom:
name: Open Watcom ${{ matrix.target }} runtime
needs: [select, validate]
if: needs.select.outputs.platform_dos16 == 'true' || needs.select.outputs.platform_dos32 == 'true'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.select.outputs.watcom_matrix) }}
steps:
- uses: actions/checkout@v7
- name: Restore Open Watcom cache
id: watcom-cache
uses: actions/cache/restore@v6
with:
path: ~/watcom
key: open-watcom-${{ runner.os }}-${{ runner.arch }}-2.0-2026-08-01
- name: Set up Open Watcom
if: steps.watcom-cache.outputs.cache-hit != 'true'
uses: open-watcom/setup-watcom@v1
with:
version: '2.0'
tag: 2026-08-01-Build
target: dos
environment: false
- name: Save Open Watcom cache
if: steps.watcom-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ~/watcom
key: open-watcom-${{ runner.os }}-${{ runner.arch }}-2.0-2026-08-01
- name: Configure Open Watcom environment
run: |
echo "WATCOM=$HOME/watcom" >> "$GITHUB_ENV"
echo "INCLUDE=$HOME/watcom/h" >> "$GITHUB_ENV"
echo "$HOME/watcom/binl" >> "$GITHUB_PATH"
- name: Install headless DOS runtime
run: |
sudo apt-get update
sudo apt-get install --yes dosbox xvfb xauth
- name: Compile and run every registered applicable case
env:
SDL_AUDIODRIVER: dummy
UNIT_SELECTION: ${{ needs.select.outputs.selection }}
run: >-
mkdir -p build &&
printf '%s' "$UNIT_SELECTION" > build/unit-selection.json &&
xvfb-run -a python3 unit/tools/run.py
--platform "${{ matrix.platform }}"
--selection build/unit-selection.json
--toolchain "${{ matrix.toolchain }}"
--dosbox "$(command -v dosbox)"
--dos-timeout 900
${{ inputs.allow_proposed_coverage_waivers && '--allow-proposed-coverage-waivers' || '' }}
--build "build/unit-${{ matrix.target }}"
- name: Upload DOS coverage and emulator diagnostics
if: always()
uses: actions/upload-artifact@v7
with:
name: unit-${{ matrix.target }}-coverage
path: |
build/unit-${{ matrix.target }}/*.native-coverage.json
build/unit-${{ matrix.target }}/*.COV
build/unit-${{ matrix.target }}/*.BAD
build/unit-${{ matrix.target }}/dosbox.log
if-no-files-found: warn
turbo-c:
name: Turbo C 2.01 runtime
needs: [select, validate]
if: needs.select.outputs.platform_dos16 == 'true'
runs-on: ubuntu-24.04
env:
TURBO_C_SHA256: 2c87f988605ae9ed70e5fef35b9854de87e36ccdb021caec35ab2424ca4b5553
steps:
- uses: actions/checkout@v7
- name: Restore Turbo C cache
id: turbo-c-cache
uses: actions/cache/restore@v6
with:
path: ~/.cache/opendoors/turbo-c-2.01
key: turbo-c-2.01-${{ env.TURBO_C_SHA256 }}-v1
- name: Download and stage Turbo C 2.01
if: steps.turbo-c-cache.outputs.cache-hit != 'true'
run: |
archive="$RUNNER_TEMP/tc201.zip"
disks="$RUNNER_TEMP/tc201-disks"
toolchain="$HOME/.cache/opendoors/turbo-c-2.01"
curl --fail --location --retry 3 \
--output "$archive" \
https://altd.embarcadero.com/download/museum/tc201.zip
echo "$TURBO_C_SHA256 $archive" | sha256sum --check --strict
unzip -q "$archive" -d "$disks"
mkdir -p "$toolchain/BIN" "$toolchain/INCLUDE/SYS" \
"$toolchain/LIB"
cp "$disks"/Disk2/*.EXE "$disks"/Disk2/*.COM \
"$toolchain/BIN/"
cp "$disks"/Disk3/TLIB.EXE "$toolchain/BIN/"
cp "$disks"/Disk3/*.H "$toolchain/INCLUDE/"
cp "$disks"/Disk3/SYS/*.H "$toolchain/INCLUDE/SYS/"
cp "$disks"/Disk1/*.LIB "$disks"/Disk1/*.OBJ \
"$disks"/Disk3/*.LIB "$disks"/Disk3/*.OBJ \
"$toolchain/LIB/"
echo "$TURBO_C_SHA256" > "$toolchain/ARCHIVE.SHA"
- name: Save Turbo C cache
if: steps.turbo-c-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ~/.cache/opendoors/turbo-c-2.01
key: turbo-c-2.01-${{ env.TURBO_C_SHA256 }}-v1
- name: Restore Open Watcom cache
id: watcom-cache
uses: actions/cache/restore@v6
with:
path: ~/watcom
key: open-watcom-${{ runner.os }}-${{ runner.arch }}-2.0-2026-08-01
- name: Set up Open Watcom
if: steps.watcom-cache.outputs.cache-hit != 'true'
uses: open-watcom/setup-watcom@v1
with:
version: '2.0'
tag: 2026-08-01-Build
target: dos
environment: false
- name: Save Open Watcom cache
if: steps.watcom-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v6
with:
path: ~/watcom
key: open-watcom-${{ runner.os }}-${{ runner.arch }}-2.0-2026-08-01
- name: Configure Open Watcom environment
run: |
echo "WATCOM=$HOME/watcom" >> "$GITHUB_ENV"
echo "INCLUDE=$HOME/watcom/h" >> "$GITHUB_ENV"
echo "$HOME/watcom/binl" >> "$GITHUB_PATH"
- name: Generate exact Turbo C unit translations
env:
UNIT_SELECTION: ${{ needs.select.outputs.selection }}
run: |
mkdir -p build
printf '%s' "$UNIT_SELECTION" > build/unit-selection.json
python3 unit/tools/turbo_generate.py \
--selection build/unit-selection.json \
--build build/unit-turbo-generated
- name: Stage Turbo C and OpenDoors headers
run: |
mkdir -p build/unit-turbo/TC build/unit-turbo/SRC/TRIO
cp -R "$HOME/.cache/opendoors/turbo-c-2.01"/* \
build/unit-turbo/TC/
for source in include/*.h src/*.h; do
destination="build/unit-turbo/SRC/$(basename "$source")"
awk '{ sub(/\r$/, ""); printf "%s\r\n", $0 }' \
"$source" > "$destination"
done
for source in third_party/trio/*.h; do
destination="build/unit-turbo/SRC/TRIO/$(basename "$source")"
awk '{ sub(/\r$/, ""); printf "%s\r\n", $0 }' \
"$source" > "$destination"
done
- name: Install headless DOS runtime
run: |
sudo apt-get update
sudo apt-get install --yes dosbox xvfb xauth
- name: Compile and run registered cases with Turbo C
env:
SDL_AUDIODRIVER: dummy
run: >-
xvfb-run -a python3 unit/tools/turbo.py
--generated build/unit-turbo-generated
--stage build/unit-turbo
--dosbox "$(command -v dosbox)"
--wasm "$(command -v wasm)"
--dosbox-config tools/turboc/dosbox.conf
${{ inputs.allow_proposed_coverage_waivers && '--allow-proposed-coverage-waivers' || '' }}
--timeout 900
- name: Upload Turbo C coverage and diagnostics
if: always()
uses: actions/upload-artifact@v7
with:
name: unit-turbo-c-coverage
path: |
build/unit-turbo-generated/*.turbo-native-coverage.json
build/unit-turbo/UNITOUT/*.COV
build/unit-turbo/UNITOUT/*.BAD
build/unit-turbo/TCUNIT.LOG
build/unit-turbo/WASM.LOG
build/unit-turbo/tcunit-dosbox.log
if-no-files-found: warn