-
-
Notifications
You must be signed in to change notification settings - Fork 0
499 lines (442 loc) · 16.2 KB
/
tests.yml
File metadata and controls
499 lines (442 loc) · 16.2 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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
name: Run Tests
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
permissions:
contents: read
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: 'true'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
precheck:
runs-on:
group: Default
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Setup venv and install pip dependencies
run: |
uv venv --python "3.12" \
&& uv sync --all-extras --all-groups --no-cache \
&& uv pip install pip \
&& echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH" \
&& if [ -d /nix/var/nix/profiles/default/bin ]; then echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"; fi
- name: Run pre-commit checks
run: uv run prek run --all-files
discover-standard-tests:
needs: precheck
runs-on:
group: Default
timeout-minutes: 20
outputs:
test-files: ${{ steps.set-matrix.outputs.test-files }}
steps:
- uses: actions/checkout@v6
- name: Discover standard test files
id: set-matrix
run: |
json_array="["
first=true
for test_file in $(find tests -maxdepth 1 -name 'test_*.py' -type f | sort); do
if [ "$first" = true ]; then
first=false
else
json_array+=","
fi
test_name=$(basename "$test_file" .py | sed 's/^test_//')
json_array+="{\"path\":\"$test_file\",\"name\":\"$test_name\"}"
done
json_array+="]"
echo "test-files=$json_array" >> "$GITHUB_OUTPUT"
echo "$json_array"
build:
name: ${{ matrix.target.os_name }} py${{ matrix.target.python_version }} ${{ matrix.test.name }}
needs: [precheck, discover-standard-tests]
runs-on: ${{ matrix.target.os }}
timeout-minutes: 20
if: ${{ needs.discover-standard-tests.outputs.test-files != '[]' }}
strategy:
fail-fast: false
max-parallel: 20
matrix:
target:
- os:
group: Default
os_name: linux
python_version: '3.11'
- os: macOS-latest
os_name: macOS
python_version: '3.14'
test: ${{ fromJson(needs.discover-standard-tests.outputs.test-files) }}
steps:
- uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.target.python_version }}
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Setup pnpm
uses: pnpm/action-setup@v5.0.0
with:
version: 10.19.0
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Bootstrap Linuxbrew on Linux
if: ${{ runner.os == 'Linux' }}
run: |
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
else
sudo apt-get update
sudo apt-get install -y build-essential file procps
sudo mkdir -p /home/linuxbrew
sudo chown -R "$(id -un)":"$(id -gn)" /home/linuxbrew
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o "${RUNNER_TEMP}/install-homebrew.sh"
NONINTERACTIVE=1 CI=1 bash "${RUNNER_TEMP}/install-homebrew.sh"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
{
echo "HOMEBREW_PREFIX=$HOMEBREW_PREFIX"
echo "HOMEBREW_CELLAR=$HOMEBREW_CELLAR"
echo "HOMEBREW_REPOSITORY=$HOMEBREW_REPOSITORY"
} >> "$GITHUB_ENV"
{
echo "$HOMEBREW_PREFIX/bin"
echo "$HOMEBREW_PREFIX/sbin"
} >> "$GITHUB_PATH"
brew --version
- name: Setup Yarn (classic + Berry)
run: |
npm install -g yarn@1.22.22
if [ "$(uname -s)" = "Darwin" ]; then
YARN_BERRY_PREFIX="/opt/homebrew/opt/yarn-berry"
YARN_BERRY_ALIAS="/opt/homebrew/bin/yarn-berry"
elif [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
BREW_PREFIX="$(brew --prefix)"
YARN_BERRY_PREFIX="$BREW_PREFIX/opt/yarn-berry"
YARN_BERRY_ALIAS="$BREW_PREFIX/bin/yarn-berry"
else
echo "ERROR: expected Linuxbrew at /home/linuxbrew/.linuxbrew"
exit 1
fi
YARN_BERRY_ALIAS_DIR="$(dirname "$YARN_BERRY_ALIAS")"
export PATH="$YARN_BERRY_ALIAS_DIR:$PATH"
echo "$YARN_BERRY_ALIAS_DIR" >> "$GITHUB_PATH"
mkdir -p "$YARN_BERRY_ALIAS_DIR"
npm install --prefix "$YARN_BERRY_PREFIX" @yarnpkg/cli-dist@4.13.0
ln -sf "$YARN_BERRY_PREFIX/node_modules/.bin/yarn" "$YARN_BERRY_ALIAS"
"$YARN_BERRY_ALIAS" --version | grep -q '^4\.'
command -v yarn
yarn --version
command -v yarn-berry
yarn-berry --version
yarn --version | grep -q '^1\.' || { echo "ERROR: yarn is not 1.x"; exit 1; }
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
cache: false
- name: Install Nix
if: runner.os == 'Linux'
uses: DeterminateSystems/nix-installer-action@v22
with:
planner: linux-multi
reinstall: true
start-daemon: true
- name: Install Nix
if: runner.os != 'Linux'
uses: DeterminateSystems/nix-installer-action@v22
- name: Sanitize PATH after Nix install
shell: bash
run: |
sanitized_path=""
while IFS= read -r path_entry; do
[ -n "$path_entry" ] || continue
[ -d "$path_entry" ] || continue
[ -x "$path_entry" ] || continue
case ":$sanitized_path:" in
*":$path_entry:"*) ;;
*) sanitized_path="${sanitized_path:+$sanitized_path:}$path_entry" ;;
esac
done < <(printf '%s' "$PATH" | tr ':' '\n')
printf 'PATH=%s\n' "$sanitized_path" >> "$GITHUB_ENV"
- name: Setup venv and install pip dependencies
run: |
export PNPM_HOME="${RUNNER_TEMP}/pnpm"
uv venv --python "${{ matrix.target.python_version }}"
uv sync --all-extras
uv pip install pip
mkdir -p "$PNPM_HOME"
echo "$PNPM_HOME" >> "$GITHUB_PATH"
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
BREW_PREFIX="$(brew --prefix)"
echo "$BREW_PREFIX/bin" >> "$GITHUB_PATH"
echo "$BREW_PREFIX/sbin" >> "$GITHUB_PATH"
fi
if [ -d /nix/var/nix/profiles/default/bin ]; then echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"; fi
- name: Environment diagnostic
run: |
echo "=== OS ==="; uname -a
# Activate the uv-managed venv so ``.venv/bin`` (where
# ``uv sync --all-extras`` installs pyinfra / ansible / pip /
# etc.) is on PATH, matching what ``uv run pytest`` sees.
if [ -d .venv/bin ]; then
export PATH="$PWD/.venv/bin:$PATH"
echo "=== venv === $PWD/.venv"
fi
echo "=== PATH ==="; echo "$PATH" | tr ':' '\n'
for bin in python pip uv node npm pnpm yarn bun deno go gem cargo rustc brew apt-get dpkg docker nix nix-env ansible ansible-playbook pyinfra sh bash; do
path=$(command -v "$bin" 2>/dev/null || true)
if [ -z "$path" ]; then
echo "=== $bin === (not installed)"
continue
fi
case "$bin" in
# go uses the ``version`` subcommand, not a ``--version`` flag
go) ver=$("$bin" version 2>/dev/null | head -1 || true) ;;
# some tools print corepack/network noise to stderr during the
# first version probe; capture stdout only.
pnpm|yarn|bun|deno|brew)
ver=$("$bin" --version 2>/dev/null | head -1 || true) ;;
*) ver=$("$bin" --version 2>&1 | head -1 || true) ;;
esac
echo "=== $bin === $path :: $ver"
done
- name: Run standard test file
run: |
export PNPM_HOME="${RUNNER_TEMP}/pnpm"
export PATH="$PNPM_HOME:$PATH"
set +e
uv run pytest -vv --tb=long -m "not root_required and not docker_required" "${{ matrix.test.path }}"
status=$?
set -e
if [ "$status" -eq 0 ] || [ "$status" -eq 5 ]; then
exit 0
fi
exit "$status"
discover-live-tests:
needs: precheck
runs-on:
group: Default
timeout-minutes: 20
outputs:
live-tests: ${{ steps.set-matrix.outputs.live-tests }}
steps:
- uses: actions/checkout@v6
- name: Discover live integration test files
id: set-matrix
run: |
json_array="["
first=true
for test_file in $(rg -l "def test_provider_direct_methods_exercise_real_lifecycle" tests/test_*.py | sort); do
test_name=$(basename "$test_file" .py | sed 's/^test_//')
needs_docker=false
if grep -q "@pytest.mark.docker_required" "$test_file"; then
needs_docker=true
fi
os_targets="linux macOS"
if grep -q "@pytest.mark.docker_required" "$test_file" || grep -q "@pytest.mark.root_required" "$test_file" || grep -q 'skipif("darwin"' "$test_file"; then
os_targets="linux"
elif grep -q 'require_tool("brew")' "$test_file" && ! grep -q 'require_tool("apt-get")' "$test_file" && ! grep -q "operations.apt.packages" "$test_file" && ! grep -q "ansible.builtin.apt" "$test_file"; then
os_targets="macOS"
fi
for os_target in $os_targets; do
if [ "$os_target" = "linux" ]; then
os_json='{"group":"Default"}'
else
os_json='"macOS-latest"'
fi
entry="{\"name\":\"${test_name}-${os_target}\",\"path\":\"$test_file\",\"os\":${os_json},\"os_name\":\"${os_target}\",\"needs_docker\":$needs_docker}"
if [ "$first" = true ]; then first=false; else json_array+=","; fi
json_array+="$entry"
done
done
json_array+="]"
echo "live-tests=$json_array" >> "$GITHUB_OUTPUT"
echo "$json_array"
live-integration:
name: ${{ matrix.live.name }}
needs: [precheck, discover-live-tests]
runs-on: ${{ matrix.live.os }}
timeout-minutes: 20
if: ${{ needs.discover-live-tests.outputs.live-tests != '[]' }}
strategy:
fail-fast: false
max-parallel: 20
matrix:
live: ${{ fromJson(needs.discover-live-tests.outputs.live-tests) }}
steps:
- uses: actions/checkout@v6
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
cache-dependency-glob: "pyproject.toml"
- name: Setup pnpm
uses: pnpm/action-setup@v5.0.0
with:
version: 10.19.0
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Bootstrap Linuxbrew on Linux
if: ${{ runner.os == 'Linux' }}
run: |
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
else
sudo apt-get update
sudo apt-get install -y build-essential file procps
sudo mkdir -p /home/linuxbrew
sudo chown -R "$(id -un)":"$(id -gn)" /home/linuxbrew
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o "${RUNNER_TEMP}/install-homebrew.sh"
NONINTERACTIVE=1 CI=1 bash "${RUNNER_TEMP}/install-homebrew.sh"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
{
echo "HOMEBREW_PREFIX=$HOMEBREW_PREFIX"
echo "HOMEBREW_CELLAR=$HOMEBREW_CELLAR"
echo "HOMEBREW_REPOSITORY=$HOMEBREW_REPOSITORY"
} >> "$GITHUB_ENV"
{
echo "$HOMEBREW_PREFIX/bin"
echo "$HOMEBREW_PREFIX/sbin"
} >> "$GITHUB_PATH"
brew --version
- name: Setup Yarn (classic + Berry)
run: |
npm install -g yarn@1.22.22
if [ "$(uname -s)" = "Darwin" ]; then
YARN_BERRY_PREFIX="/opt/homebrew/opt/yarn-berry"
YARN_BERRY_ALIAS="/opt/homebrew/bin/yarn-berry"
elif [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
BREW_PREFIX="$(brew --prefix)"
YARN_BERRY_PREFIX="$BREW_PREFIX/opt/yarn-berry"
YARN_BERRY_ALIAS="$BREW_PREFIX/bin/yarn-berry"
else
echo "ERROR: expected Linuxbrew at /home/linuxbrew/.linuxbrew"
exit 1
fi
YARN_BERRY_ALIAS_DIR="$(dirname "$YARN_BERRY_ALIAS")"
export PATH="$YARN_BERRY_ALIAS_DIR:$PATH"
echo "$YARN_BERRY_ALIAS_DIR" >> "$GITHUB_PATH"
mkdir -p "$YARN_BERRY_ALIAS_DIR"
npm install --prefix "$YARN_BERRY_PREFIX" @yarnpkg/cli-dist@4.13.0
ln -sf "$YARN_BERRY_PREFIX/node_modules/.bin/yarn" "$YARN_BERRY_ALIAS"
"$YARN_BERRY_ALIAS" --version | grep -q '^4\.'
command -v yarn
yarn --version
command -v yarn-berry
yarn-berry --version
yarn --version | grep -q '^1\.' || { echo "ERROR: yarn is not 1.x"; exit 1; }
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
cache: false
- name: Install Nix
if: runner.os == 'Linux'
uses: DeterminateSystems/nix-installer-action@v22
with:
planner: linux-multi
start-daemon: true
- name: Install Nix
if: runner.os != 'Linux'
uses: DeterminateSystems/nix-installer-action@v22
- name: Sanitize PATH after Nix install
shell: bash
run: |
sanitized_path=""
while IFS= read -r path_entry; do
[ -n "$path_entry" ] || continue
[ -d "$path_entry" ] || continue
[ -x "$path_entry" ] || continue
case ":$sanitized_path:" in
*":$path_entry:"*) ;;
*) sanitized_path="${sanitized_path:+$sanitized_path:}$path_entry" ;;
esac
done < <(printf '%s' "$PATH" | tr ':' '\n')
printf 'PATH=%s\n' "$sanitized_path" >> "$GITHUB_ENV"
- name: Setup Docker
if: ${{ matrix.live.needs_docker }}
uses: docker/setup-docker-action@v5.0.0
env:
LIMA_START_ARGS: --vm-type=vz
with:
daemon-config: |
{
"debug": true
}
- name: Setup venv and install pip dependencies
run: |
export PNPM_HOME="${RUNNER_TEMP}/pnpm"
uv venv --python "3.12"
uv sync --all-extras
uv pip install pip
mkdir -p "$PNPM_HOME"
echo "$PNPM_HOME" >> "$GITHUB_PATH"
if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
BREW_PREFIX="$(brew --prefix)"
echo "$BREW_PREFIX/bin" >> "$GITHUB_PATH"
echo "$BREW_PREFIX/sbin" >> "$GITHUB_PATH"
fi
echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
- name: Inspect Docker
if: ${{ matrix.live.needs_docker }}
run: |
docker version \
&& docker info
- name: Run live package lifecycle test
run: |
export PNPM_HOME="${RUNNER_TEMP}/pnpm"
export PATH="$PNPM_HOME:$PATH:/nix/var/nix/profiles/default/bin:$PATH"
uv run pytest "${{ matrix.live.path }}" -k test_provider_direct_methods_exercise_real_lifecycle