-
-
Notifications
You must be signed in to change notification settings - Fork 1
322 lines (288 loc) · 9.86 KB
/
checks.yml
File metadata and controls
322 lines (288 loc) · 9.86 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
name: Checks
on:
push:
branches:
- main
paths:
- "src/**"
- "lib.typ"
- "examples/**"
- "tests/**"
- "typst.toml"
- "tools/**"
- "README.md"
- "LICENSE"
- ".github/actions/**"
- ".github/workflows/checks.yml"
pull_request:
paths:
- "src/**"
- "lib.typ"
- "examples/**"
- "tests/**"
- "typst.toml"
- "tools/**"
- "README.md"
- "LICENSE"
- ".github/actions/**"
- ".github/workflows/checks.yml"
permissions:
contents: read
# One active run per branch; cancel superseded runs on the same ref.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
typstdoc-tests:
name: Run typstdoc tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Lua
uses: leafo/gh-actions-lua@v11
with:
luaVersion: "5.4"
- name: Run typstdoc tests
id: typstdoc
shell: bash
run: |
set -euo pipefail
lua tools/typstdoc/test/run.lua 2>&1 | tee "${RUNNER_TEMP}/typstdoc.log"
- name: Validate docstrings and example gallery
shell: bash
run: |
set -euo pipefail
lua tools/typstdoc/main.lua --check
- name: Summary
if: always()
shell: bash
run: |
set -euo pipefail
log="${RUNNER_TEMP}/typstdoc.log"
if [[ ! -f "${log}" ]]; then
{
echo "## typstdoc tests"
echo "- Status: failed (no log captured)"
} >> "${GITHUB_STEP_SUMMARY}"
exit 0
fi
totals_line=$(grep -E '^[0-9]+ passed, [0-9]+ failed$' "${log}" | tail -1 || true)
passed=$(awk '{print $1}' <<< "${totals_line:-0 passed, 0 failed}")
failed=$(awk '{print $3}' <<< "${totals_line:-0 passed, 0 failed}")
total=$((passed + failed))
{
echo "## typstdoc tests"
if [[ "${failed}" -gt 0 ]]; then
echo "- Status: failed (${passed}/${total})"
echo ""
echo "### Failures"
grep -E '^ FAIL ' "${log}" | sed -E 's/^ FAIL (.*)$/- `\1`/'
else
echo "- Status: passed (${passed}/${total})"
fi
} >> "${GITHUB_STEP_SUMMARY}"
typst-compile:
name: Compile Typst sources
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Read Typst version from typst.toml
id: typst-version
uses: ./.github/actions/typst-version
- name: Set up Typst
uses: typst-community/setup-typst@v5
with:
typst-version: ${{ steps.typst-version.outputs.version }}
- name: Compile unit tests
id: unit
uses: ./.github/actions/typst-compile
with:
label: unit
glob: "tests/unit/*.typ"
- name: Compile examples
id: examples
if: always()
uses: ./.github/actions/typst-compile
with:
label: example
glob: "examples/*.typ"
- name: Summary
if: always()
shell: bash
env:
UNIT_PASSED: ${{ steps.unit.outputs.passed }}
UNIT_TOTAL: ${{ steps.unit.outputs.total }}
UNIT_FAILED: ${{ steps.unit.outputs.failed }}
UNIT_FAILURES: ${{ steps.unit.outputs.failures }}
EXAMPLES_PASSED: ${{ steps.examples.outputs.passed }}
EXAMPLES_TOTAL: ${{ steps.examples.outputs.total }}
EXAMPLES_FAILED: ${{ steps.examples.outputs.failed }}
EXAMPLES_FAILURES: ${{ steps.examples.outputs.failures }}
run: |
set -euo pipefail
render_section() {
local title="$1" passed="$2" total="$3" failed="$4" failures="$5"
passed="${passed:-0}"
total="${total:-0}"
failed="${failed:-0}"
echo ""
echo "### ${title}"
if [[ "${failed}" -gt 0 ]]; then
echo "- Status: failed (${passed}/${total})"
echo ""
echo "#### Failures"
while IFS= read -r line; do
[[ -n "${line}" ]] && echo "- \`${line}\`"
done <<< "${failures}"
else
echo "- Status: passed (${passed}/${total})"
fi
}
{
echo "## Typst compile"
render_section "Unit tests" "${UNIT_PASSED}" "${UNIT_TOTAL}" "${UNIT_FAILED}" "${UNIT_FAILURES}"
render_section "Examples" "${EXAMPLES_PASSED}" "${EXAMPLES_TOTAL}" "${EXAMPLES_FAILED}" "${EXAMPLES_FAILURES}"
} >> "${GITHUB_STEP_SUMMARY}"
visual-snapshots:
name: Visual snapshot diff
runs-on: ubuntu-latest
# Serialise against the refresh workflow on the same ref so a
# `snapshot-refresh` push and a checks run can't fight over goldens.
concurrency:
group: snapshot-refresh-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Read Typst version from typst.toml
id: typst-version
uses: ./.github/actions/typst-version
- name: Set up Typst
uses: typst-community/setup-typst@v5
with:
typst-version: ${{ steps.typst-version.outputs.version }}
- name: Set up Lua
uses: leafo/gh-actions-lua@v11
with:
luaVersion: "5.4"
- name: Run visual snapshot harness
uses: ./.github/actions/typst-snapshot
with:
mode: check
- name: Summary
if: always()
shell: bash
run: |
set -euo pipefail
log="${RUNNER_TEMP}/snapshot.log"
if [[ ! -f "${log}" ]]; then
{
echo "## Visual snapshots"
echo "- Status: failed (no log captured)"
} >> "${GITHUB_STEP_SUMMARY}"
exit 0
fi
totals_line=$(grep -E '^snapshots: [0-9]+/[0-9]+ ok$' "${log}" | tail -1 || true)
passed=$(sed -E 's|^snapshots: ([0-9]+)/[0-9]+ ok$|\1|' <<< "${totals_line:-snapshots: 0/0 ok}")
total=$(sed -E 's|^snapshots: [0-9]+/([0-9]+) ok$|\1|' <<< "${totals_line:-snapshots: 0/0 ok}")
failures=$(grep -E '^(COMPILE-FAIL|DIFF|MISSING|COMPARE-ERR) ' "${log}" || true)
{
echo "## Visual snapshots"
if [[ -n "${failures}" ]]; then
echo "- Status: failed (${passed}/${total})"
echo ""
echo "### Failures"
while IFS= read -r line; do
key=$(awk '{print $2}' <<< "${line}")
echo "- \`${key}\`"
done <<< "${failures}"
else
echo "- Status: passed (${passed}/${total})"
fi
} >> "${GITHUB_STEP_SUMMARY}"
package-check:
name: Run typst-package-check
runs-on: ubuntu-latest
# Repository URL check fails with 404 while `mcanouil/gribouille` stays
# private; keep the job informational rather than blocking until then.
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Install typst-package-check
shell: bash
run: cargo install --git https://github.com/typst/package-check --locked
- name: Read versions from manifest
id: versions
shell: bash
run: |
set -euo pipefail
version=$(awk -F'"' '/^version[[:space:]]*=/ { print $2; exit }' typst.toml)
[[ -n "$version" ]] || { echo "::error::version not found in typst.toml"; exit 1; }
compiler=$(awk -F'"' '/^compiler[[:space:]]*=/ { print $2; exit }' typst.toml)
[[ -n "$compiler" ]] || { echo "::error::compiler not found in typst.toml"; exit 1; }
{
echo "version=${version}"
echo "compiler=${compiler}"
} >> "${GITHUB_OUTPUT}"
- name: Set up Typst
uses: typst-community/setup-typst@v5
with:
typst-version: ${{ steps.versions.outputs.compiler }}
- name: Seed package cache
shell: bash
# typst-package-check refuses to download `@preview/*` itself; warm
# the local cache by compiling a tiny file that imports each pinned
# dependency listed in src/deps.typ.
run: |
set -euo pipefail
{
grep -E '^#import[[:space:]]+"@preview/' src/deps.typ
printf '\nseed\n'
} > /tmp/seed.typ
typst compile /tmp/seed.typ /tmp/seed.pdf
- name: Stage published payload
env:
VERSION: ${{ steps.versions.outputs.version }}
shell: bash
run: |
set -euo pipefail
STAGE="/tmp/stage/gribouille/${VERSION}"
tools/package.sh stage "${STAGE}"
echo "STAGE=${STAGE}" >> "${GITHUB_ENV}"
- name: Run typst-package-check
id: pkgcheck
shell: bash
run: |
set -euo pipefail
typst-package-check check "${STAGE}" 2>&1 | tee "${RUNNER_TEMP}/pkgcheck.log"
- name: Summary
if: always()
shell: bash
env:
OUTCOME: ${{ steps.pkgcheck.outcome }}
run: |
set -euo pipefail
log="${RUNNER_TEMP}/pkgcheck.log"
{
echo "## Package check"
if [[ "${OUTCOME}" == "success" ]]; then
echo "- Status: passed"
else
echo "- Status: failed"
if [[ -f "${log}" ]]; then
echo ""
echo "### Failures"
echo ""
echo '```'
tail -n 30 "${log}"
echo '```'
fi
fi
} >> "${GITHUB_STEP_SUMMARY}"