Repository navigation
348 lines (328 loc) · 16.9 KB
/
Copy pathci.yml
File metadata and controls
348 lines (328 loc) · 16.9 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
name: CI
on:
workflow_call:
inputs:
versions:
description: "Julia versions to test (JSON array)"
required: false
type: string
default: '["1.10","1.13"]'
runs_on:
description: "GitHub runner labels (e.g., 'ubuntu-latest' or JSON array for self-hosted like '[\"self-hosted\", \"Linux\", \"gpu\"]')"
required: false
type: string
default: '["ubuntu-latest","macos-latest","windows-latest"]'
runner_type:
description: "Runner type: 'github' for GitHub-hosted runners or 'self-hosted' for self-hosted runners"
required: false
type: string
default: 'github'
use_ct_registry:
description: "Whether the local ct-registry is added or not"
required: false
default: false
type: boolean
test_args:
description: "Arguments string forwarded to julia-runtest's test_args (e.g. 'GPU' to select a package's GPU-specific test suite). Empty by default (no arguments)."
required: false
type: string
default: ''
ctactions_ref:
description: "Ref of CTActions whose scripts the `changes` job runs (main; a branch to test a change)"
required: false
type: string
default: main
upload_artifact_path:
description: "Optional file or directory to upload after tests, including on failure"
required: false
type: string
default: ''
upload_artifact_name:
description: "Optional base name for the test artifact; matrix identity is appended"
required: false
type: string
default: ''
upload_artifact_if_no_files:
description: "Behavior when the artifact path is missing: warn, error, or ignore"
required: false
type: string
default: warn
upload_artifact_retention_days:
description: "Optional artifact retention in days; empty keeps the repository default"
required: false
type: string
default: ''
upload_artifact_include_hidden_files:
description: "Whether hidden files are included in the test artifact"
required: false
type: boolean
default: false
fail_fast:
description: "Cancel the other matrix jobs when one fails (GitHub default). Set false to keep every platform running, e.g. to collect one report per platform."
required: false
type: boolean
default: true
secrets:
SSH_KEY:
required: false
# Superseded runs: on a pull request, a new run cancels the previous one of the same pull
# request (docs/workflows/superseded-runs.md). On a push to main, a tag, a schedule or a manual
# run, the group is the run itself: nothing is cancelled and nothing waits. Declared here,
# not in the caller: a label that changes nothing creates a run whose calling job is
# skipped, and a `concurrency` of the caller would still cancel the run in progress. The
# group starts with a name of its own: it must differ from every group of a caller.
# `runner_type` and `runs_on` keep apart the calls of one caller workflow (the GitHub, kkt
# and occidata runners of one `CI.yml`, which also reach this workflow through ci-gpu.yml).
# A run started by label-dispatch.yml (a `workflow_dispatch` with the input `pr`) is a
# run of that pull request: same group, same cancellation.
concurrency:
group: ctactions-ci-${{ github.workflow }}-${{ inputs.runner_type }}-${{ inputs.runs_on }}-${{ github.event.pull_request.number || github.event.inputs.pr || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.event.inputs.pr != '') }}
jobs:
# A run started by label-dispatch.yml shows as a commit status (pr-status.yml).
status-start:
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.pr != '' }}
permissions:
statuses: write
uses: control-toolbox/CTActions/.github/workflows/pr-status.yml@main
with:
context: CI / ${{ github.event.inputs.target }}
phase: start
status-end:
needs: [changes, test]
if: ${{ always() && github.event_name == 'workflow_dispatch' && github.event.inputs.pr != '' }}
permissions:
statuses: write
uses: control-toolbox/CTActions/.github/workflows/pr-status.yml@main
with:
context: CI / ${{ github.event.inputs.target }}
phase: end
results: ${{ toJSON(needs.*.result) }}
# Whether the jobs below run (docs/workflows/guard.md): no on a pull request that is not
# open; on a push to main, yes unless the merged pull request carries the label
# `ci on main: changes only` (docs/workflows/ci-on-main.md); yes otherwise.
changes:
permissions:
contents: read
pull-requests: read
actions: read
uses: control-toolbox/CTActions/.github/workflows/guard.yml@main
with:
scope: tests
job: test
ctactions_ref: ${{ inputs.ctactions_ref }}
actors: ${{ vars.CT_CI_CHANGES_ONLY_ACTORS }}
test:
needs: changes
if: ${{ !cancelled() && needs.changes.outputs.run != 'false' }}
strategy:
fail-fast: ${{ inputs.fail_fast }}
matrix:
version: ${{ fromJSON(inputs.versions) }}
runs_on: ${{ fromJSON(inputs.runs_on) }}
runs-on: ${{ matrix.runs_on }}
steps:
# ---------------------------
# Checkout Repository
# ---------------------------
- name: Checkout repository
uses: actions/checkout@v7
# ---------------------------
# Setup Julia Environment
# ---------------------------
- name: Setup Julia
id: julia
uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
# No `arch`: setup-julia installs the runner's native Julia (x64 on Linux and
# Windows, aarch64 on macOS). An x64 Julia on the Apple Silicon macOS runners ran
# under Rosetta, where binary dependencies such as KNITRO_jll are unavailable.
# ---------------------------
# Julia caching (conditional based on runner type)
# ---------------------------
# Must precede "Add ct-registry": julia-actions/cache also restores a
# cached ~/.julia/registries, but skips that restore with "Julia depot
# registries already exist" if a registry-adding step already ran first —
# forcing every run to re-clone the (large) General + ct-registry
# registries via git instead of reusing the cache.
- name: Cache Julia packages (GitHub-hosted runners)
if: inputs.runner_type == 'github'
uses: julia-actions/cache@v2
# julia-actions/setup-julia does not set JULIA_DEPOT_PATH, so different
# self-hosted runners can have different real depot locations (e.g. a
# cluster-wide JULIA_DEPOT_PATH exported by the runner service vs. the
# Julia default of ~/.julia). Hardcoding ~/.julia below would silently
# purge nothing on a runner where that's not the real depot. Ask
# Julia itself where its writable depot is instead of guessing.
#
# No actions/cache here: the depot persists between jobs, so artifacts/ and
# compiled/ are already on disk. Caching them restored what was there (or an
# older compiled/) and archived the whole shared depot at the end of every job
# (6.4 GB, tens of minutes on occidata's network disk, most of each repository's
# 10 GB cache quota).
- name: Resolve Julia depot path (self-hosted runners)
id: depot
if: inputs.runner_type == 'self-hosted'
shell: bash
run: echo "path=$(julia -e 'print(Base.DEPOT_PATH[1])')" >> "$GITHUB_OUTPUT"
# ---------------------------
# Add ct-registry
# ---------------------------
# add-julia-registry invokes bare `ssh-agent`/`ssh-add`/`ssh-keyscan` (PATH
# lookup, not a hardcoded path). By default that resolves to Windows'
# System32 OpenSSH port, which (a) treats a bare `ssh-agent` invocation as a
# Windows-service start rather than forking a background agent, failing with
# "unable to start ssh-agent service, error :1058" (ERROR_SERVICE_DISABLED),
# and (b) is old enough that its `ssh-keyscan github.com` cannot negotiate
# the sntrup761x25519-sha512@openssh.com post-quantum KEX GitHub now offers,
# failing with "choose_kex: unsupported KEX method". Git for Windows ships
# its own (MSYS2-based) OpenSSH client, behaves like the Unix tools these
# actions expect, and is already installed on GitHub-hosted Windows runners
# — prepend it to PATH so it's what gets resolved.
- name: Prefer Git's OpenSSH client (Windows)
if: inputs.use_ct_registry && runner.os == 'Windows'
shell: pwsh
run: echo "C:\Program Files\Git\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Add ct-registry
if: inputs.use_ct_registry
uses: control-toolbox/CTActions/.github/actions/add-ct-registry@main
with:
key: ${{ secrets.SSH_KEY }}
# add-julia-registry's own ssh-agent (started above) is only ever talked to
# by system `git`/`ssh`, which is why that step succeeds. Pkg's later git
# operations in the "Build Julia package" step below — the registry
# re-fetch during instantiate, and any git-sourced dependency clone (e.g.
# CTLie) — go through Julia's *bundled* LibGit2 instead, which on Windows
# can't use that same agent (its named-pipe transport isn't something
# libssh2 understands there) and fails with "user cancelled credential
# request".
#
# Setting JULIA_PKG_USE_CLI_GIT=true here does NOT fix it:
# julia-actions/julia-buildpkg's own script unconditionally does
# `ENV["JULIA_PKG_USE_CLI_GIT"] = <its git_cli input, default false>`
# before calling Pkg.Registry.add()/Pkg.build(), clobbering whatever we
# export via GITHUB_ENV. The actual fix is the `git_cli: true` input on
# that step below, which routes through the same env var but from
# inside the action, after its own default assignment.
# ---------------------------
# Build and test
# ---------------------------
# `Pkg.test` builds its sandbox environment (Project.toml + Manifest.toml)
# with `mktempdir()` — i.e. under $TMPDIR, which defaults to /tmp — and runs
# the test subprocess with JULIA_LOAD_PATH="@:<that dir>" and JULIA_PROJECT
# unset. No --project, no @stdlib: that temp directory is the *only* entry on
# the load path. If it disappears mid-run, every later `using X` fails with
# "Package X not found in current path" (stdlib `Test` included, because
# `Base.require` re-runs `identify_package` before looking at already-loaded
# modules), and a disappearance during precompilation surfaces instead as
# "N direct dependencies failed to precompile".
#
# That is exactly what happens on the occidata runner, whose node wipes /tmp
# every hour at HH:01: any run whose test window crosses the top of an hour
# dies. GitHub-hosted runners get a fresh disk per job and are unaffected, so
# scope this to self-hosted. $RUNNER_TEMP lives under the runner's own _work
# tree and is cleaned by the runner between jobs, not by the node.
- name: Keep the Pkg sandbox out of /tmp (self-hosted runners)
if: inputs.runner_type == 'self-hosted'
shell: bash
run: |
mkdir -p "$RUNNER_TEMP/jltmp"
echo "TMPDIR=$RUNNER_TEMP/jltmp" >> "$GITHUB_ENV"
- name: Build Julia package
uses: julia-actions/julia-buildpkg@v1
with:
git_cli: ${{ (inputs.use_ct_registry && runner.os == 'Windows') && 'true' || 'false' }}
# force_latest_compatible_version (auto: only on Dependabot/CompatHelper
# branches) is skipped on Julia 1.10: Pkg's implementation picks the latest
# registered version of each dependency without checking Julia
# compatibility, e.g. it forces JET 0.12 (needs Julia >= 1.11), which makes
# resolution fail. The latest versions are still tested on newer Julia.
- name: Run tests
if: inputs.runner_type != 'self-hosted'
uses: julia-actions/julia-runtest@latest
with:
test_args: ${{ inputs.test_args }}
force_latest_compatible_version: ${{ matrix.version == '1.10' && 'false' || 'auto' }}
# Self-hosted runners reuse a persistent Julia depot across every run
# (unlike GitHub-hosted runners, whose disk is wiped between jobs), so a
# compiled/ cache left over from a different branch/Manifest can drift
# out of sync with what's actually installed and break precompilation
# for unrelated packages/extensions. Retry once after purging it rather
# than requiring a runner-specific maintenance job to catch this.
#
# Both attempts live in one step so that its exit status is the retry's:
# continue-on-error on a julia-runtest step does not stop a failure inside
# that composite action from failing the job (seen on CTLie.jl run
# 37276655422, where the retry passed and the job still failed). The
# Pkg.test call is the one julia-runtest makes with its default inputs.
#
# The occidata runner idles in a CPU allocation so as not to hold a GPU for
# days; the tests get a GPU node for their own duration through the script
# the runner exports as $OCCIDATA_GPU_RUN (control-toolbox/occidata,
# scripts/slurm_gpu_run.sh). Unset on every other runner, so the prefix
# expands to nothing there.
- name: Run tests (self-hosted runners, one retry after cache purge)
if: inputs.runner_type == 'self-hosted'
shell: bash
env:
TEST_ARGS: ${{ inputs.test_args }}
JULIA_MATRIX_VERSION: ${{ matrix.version }}
COMPILED_DIR: ${{ steps.depot.outputs.path }}/compiled
run: |
# Same as julia-runtest's force_latest_compatible_version=auto: force
# the latest compatible versions on Dependabot/CompatHelper branches
# only (see julia-runtest's autodetect-dependabot.jl).
# Skipped on Julia 1.10, see "Run tests" above.
FORCE_LATEST=false
for ref in "${GITHUB_BASE_REF:-}" "${GITHUB_HEAD_REF:-}" "${GITHUB_REF:-}"; do
ref="${ref#refs/heads/}"
case "$ref" in dependabot/julia*|compathelper/*) FORCE_LATEST=true ;; esac
done
[ "$JULIA_MATRIX_VERSION" = "1.10" ] && FORCE_LATEST=false
echo "force_latest_compatible_version=$FORCE_LATEST"
export FORCE_LATEST
run_tests() {
# shellcheck disable=SC2086 # TEST_ARGS splits like julia-runtest's test_args
${OCCIDATA_GPU_RUN:-} julia --color=yes --project=@. -e '
import Pkg
Pkg.test(;
coverage=true,
julia_args=["--check-bounds=yes", "--compiled-modules=yes", "--depwarn=yes"],
force_latest_compatible_version=parse(Bool, ENV["FORCE_LATEST"]),
allow_reresolve=true,
test_args=ARGS,
)' -- $TEST_ARGS
}
run_tests && exit 0
echo "::warning::Tests failed on first attempt — purging $COMPILED_DIR in case it's a stale precompile cache, then retrying once"
rm -rf "$COMPILED_DIR"
run_tests
- name: Warn on an incomplete artifact request
if: ${{ always() && ((inputs.upload_artifact_path != '') != (inputs.upload_artifact_name != '')) }}
shell: bash
run: echo '::warning::Both upload_artifact_path and upload_artifact_name are required; no test artifact is uploaded.'
- name: Build the test artifact name
id: artifact-name
if: ${{ always() && inputs.upload_artifact_path != '' && inputs.upload_artifact_name != '' }}
shell: bash
env:
ARTIFACT_BASE: ${{ inputs.upload_artifact_name }}
JULIA_VERSION: ${{ matrix.version }}
RUNS_ON: ${{ toJSON(matrix.runs_on) }}
run: |
name="${ARTIFACT_BASE}-${JULIA_VERSION}-${RUNS_ON}"
# a list of labels (self-hosted, GPU) is a multi-line JSON array: newlines go too,
# otherwise GITHUB_OUTPUT rejects the value
name=$(printf '%s' "$name" | tr '\n' '-' | sed 's/[^A-Za-z0-9._-]/-/g; s/--*/-/g; s/^-//; s/-$//')
echo "name=$name" >> "$GITHUB_OUTPUT"
- name: Upload requested test artifact
if: ${{ always() && inputs.upload_artifact_path != '' && inputs.upload_artifact_name != '' }}
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact-name.outputs.name }}
path: ${{ inputs.upload_artifact_path }}
if-no-files-found: ${{ inputs.upload_artifact_if_no_files }}
include-hidden-files: ${{ inputs.upload_artifact_include_hidden_files }}
# 0 keeps the repository default retention
retention-days: ${{ fromJSON(inputs.upload_artifact_retention_days || '0') }}