-
Notifications
You must be signed in to change notification settings - Fork 17
218 lines (196 loc) · 8.73 KB
/
Copy pathtest.yml
File metadata and controls
218 lines (196 loc) · 8.73 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
name: Tests
on:
pull_request:
branches:
- 'main'
workflow_dispatch:
inputs:
ref:
description: 'Release tag or branch to scan.'
required: true
default: 'main'
jobs:
test:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.ref || github.ref }}
# Windows uses MSVC for LuaJIT and the C rocks; activate the toolchain (sets VCINSTALLDIR + cl).
- uses: step-security/msvc-dev-cmd@v1
if: runner.os == 'Windows'
- uses: leafo/gh-actions-lua@v13
if: runner.os != 'Windows'
with:
luaVersion: "luajit-2.1"
# DepCtrl relies on Lua 5.2 features (table.unpack, __pairs/__len)
luaCompileFlags: "XCFLAGS=-DLUAJIT_ENABLE_LUA52COMPAT"
# Cache the MSVC LuaJIT build, keyed on the live v2.1 commit so it refreshes when upstream moves
# (leafo/gh-actions-lua already caches LuaJIT on Linux/macOS).
- name: Resolve LuaJIT revision
if: runner.os == 'Windows'
id: luajit-rev
shell: pwsh
run: |
$line = git ls-remote https://github.com/LuaJIT/LuaJIT.git refs/heads/v2.1 | Select-Object -First 1
Add-Content -Path $env:GITHUB_OUTPUT -Value "sha=$(($line -split '\s+')[0])"
- name: Cache LuaJIT
if: runner.os == 'Windows'
id: cache-luajit
uses: actions/cache@v6
with:
path: .lua
key: luajit-msvc-x64-${{ steps.luajit-rev.outputs.sha }}
# The C rocks build with MSVC on Windows, so LuaJIT must too, for a matching lua51.lib and CRT.
# The Lua action only builds LuaJIT with mingw, so build it here with msvcbuild.bat and install
# into .lua/ using the layout the luarocks action expects.
- name: Build LuaJIT with MSVC
if: runner.os == 'Windows' && steps.cache-luajit.outputs.cache-hit != 'true'
shell: pwsh
run: |
git clone --depth 1 --branch v2.1 https://github.com/LuaJIT/LuaJIT.git "$env:RUNNER_TEMP\luajit"
Set-Location "$env:RUNNER_TEMP\luajit\src"
cmd /c msvcbuild.bat lua52compat
$lua = "$env:GITHUB_WORKSPACE\.lua"
New-Item -ItemType Directory -Force -Path "$lua\bin", "$lua\lib", "$lua\include\luajit-2.1" | Out-Null
Copy-Item luajit.exe -Destination "$lua\bin\lua.exe"
Copy-Item lua51.dll -Destination "$lua\bin"
Copy-Item -Path lua51.dll, lua51.lib -Destination "$lua\lib"
Copy-Item -Path lua.h, lualib.h, lauxlib.h, luaconf.h, lua.hpp, luajit.h -Destination "$lua\include\luajit-2.1"
# .lua/bin holds lua.exe whether just built or restored from cache; put it on PATH either way.
- name: Add LuaJIT to PATH
if: runner.os == 'Windows'
shell: pwsh
run: Add-Content -Path $env:GITHUB_PATH -Value "$env:GITHUB_WORKSPACE\.lua\bin"
# Installs LuaRocks and builds the C rocks with the active toolchain — MSVC on Windows
# (VCINSTALLDIR set above), the system gcc/clang on Linux/macOS.
- uses: luarocks/gh-actions-luarocks@v7
# Pegasus's lzlib dependency links against zlib, which isn't on the Windows runner. Cache the
# vcpkg build; zlib 1.3.x is stable, so a fixed key is safe. Path matches VCPKG_INSTALLATION_ROOT.
- name: Cache zlib
if: runner.os == 'Windows'
id: cache-zlib
uses: actions/cache@v6
with:
path: C:\vcpkg\installed\x64-windows
key: zlib-x64-windows-1
- name: Set up zlib for lzlib
if: runner.os == 'Windows'
shell: pwsh
env:
CACHE_HIT: ${{ steps.cache-zlib.outputs.cache-hit }}
run: |
$z = "$env:VCPKG_INSTALLATION_ROOT\installed\x64-windows"
if ($env:CACHE_HIT -ne 'true') {
& "$env:VCPKG_INSTALLATION_ROOT\vcpkg.exe" install zlib:x64-windows
# zlib 1.3.x's import lib is z.lib, but lzlib looks for zlib.lib.
Copy-Item "$z\lib\z.lib" "$z\lib\zlib.lib"
}
luarocks --lua-version=5.1 config variables.ZLIB_INCDIR "$z\include"
luarocks --lua-version=5.1 config variables.ZLIB_LIBDIR "$z\lib"
# moonscript loader
- run: luarocks --lua-version=5.1 install moonscript
# lfs (Aegisub provides an internal copy)
- run: luarocks --lua-version=5.1 install luafilesystem
# CLI argument parsing
- run: luarocks --lua-version=5.1 install argparse
# mock HTTP server dependencies
- run: luarocks --lua-version=5.1 install luasocket
- run: luarocks --lua-version=5.1 install copas
- run: luarocks --lua-version=5.1 install pegasus
# json schema validation
- run: luarocks --lua-version=5.1 install lua-schema
- run: luarocks --lua-version=5.1 install lpeg
- name: Run tests
timeout-minutes: 5
run: lua depctrl.lua test
# Per-platform status check; the raw CTRF reports are uploaded next for the merged-comment job.
- name: Publish status check
uses: ctrf-io/github-test-reporter@v1
if: ${{ !cancelled() }}
with:
report-path: ./ctrf/*.json
status-check: true
status-check-name: Test results (${{ matrix.os }})
annotate: false
use-suite-name: true
summary-report: true
failed-report: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload CTRF reports
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: ctrf-report-${{ matrix.os }}
path: ctrf/*.json
# Lint the module sources' LuaCATS annotations: missing docs on public members and
# @param/@return that disagree with the real signature fail the build. This also emits every
# definition and verifies it is loadable Lua, so it doubles as type-generation coverage.
- name: Check annotations
if: ${{ !cancelled() }}
run: lua depctrl.lua generate-types --check
# Smoke-test that documentation generation runs over the real feed without a parse or emit
# failure. --site none skips scaffolding; the output goes to a throwaway directory.
- name: Smoke-test doc generation
if: ${{ !cancelled() }}
run: lua depctrl.lua generate-docs --site none -o "${{ runner.temp }}/docs"
# Post one PR comment covering every platform. Each test's suite is prefixed with its platform, then
# the per-platform reports are merged into one the reporter renders.
report:
needs: test
if: ${{ !cancelled() && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
pattern: ctrf-report-*
path: reports
- name: Prefix each test's suite with its platform
run: |
mkdir -p merged-input
for dir in reports/ctrf-report-*/; do
os=$(basename "$dir" | sed 's/^ctrf-report-//')
for f in "$dir"*.json; do
jq --arg os "$os" '.results.tests = ((.results.tests // []) | map(.suite = ("[" + $os + "] " + (.suite // ""))))' "$f" > "merged-input/${os}-$(basename "$f")"
done
done
- name: Merge into one report
run: npx --yes ctrf-cli merge merged-input --output merged.json
# Per-platform pass/fail line for the comment title, read off the [platform]-prefixed suites.
- name: Per-platform summary line
id: summary
run: |
line=$(jq -r '
[ .results.tests[] | { os: (.suite | capture("^\\[(?<os>[^\\]]+)\\]").os), status } ]
| group_by(.os)
| map({ os: .[0].os,
p: ([ .[] | select(.status == "passed") ] | length),
f: ([ .[] | select(.status == "failed") ] | length) })
| map("\(.os) ✅\(.p)" + (if .f > 0 then " ❌\(.f)" else "" end))
| join(" · ")
' merged-input/merged.json)
echo "title=Test results — $line" >> "$GITHUB_OUTPUT"
- name: Publish merged test report
uses: ctrf-io/github-test-reporter@v1
with:
report-path: merged-input/merged.json
pull-request: true
overwrite-comment: true
comment-tag: all-platforms
title: ${{ steps.summary.outputs.title }}
use-suite-name: true
group-by: suite
# per-test listing with 3k+ passing tests × 3 platforms would blow past GitHub's 65 KB comment limit
suite-folded-report: false
summary-report: true
failed-report: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}