Repository navigation
581 lines (498 loc) · 22.9 KB
/
Copy pathtest-install.yaml
File metadata and controls
581 lines (498 loc) · 22.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
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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
name: Test Install Script
on:
push:
branches:
- main
paths:
- 'install.sh'
- 'scripts/test-install.sh'
- 'scripts/test-bun-check.sh'
- 'packages/cli/**'
- '.github/workflows/test-install.yaml'
pull_request:
merge_group:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CI: true
GITHUB_TOKEN: ''
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
NODE_VERSION: '24'
jobs:
detect-install-changes:
name: Detect install test changes
runs-on: ubuntu-latest
outputs:
should-run: ${{ steps.changed-files.outputs.should-run }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
fetch-depth: 0
persist-credentials: false
- name: Detect changed files
id: changed-files
shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.event.before }}
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha || github.sha }}
run: |
set -euo pipefail
if [ -z "${BASE_SHA}" ] || [ "${BASE_SHA}" = "0000000000000000000000000000000000000000" ]; then
echo "should-run=true" >> "$GITHUB_OUTPUT"
echo "Unable to determine a base SHA; running install tests."
exit 0
fi
git diff --name-only "$BASE_SHA" "$HEAD_SHA" > changed-files.txt
cat changed-files.txt
should_run=false
if grep -E '^(install\.sh|scripts/test-install\.sh|scripts/test-bun-check\.sh|\.github/workflows/test-install\.yaml)' changed-files.txt > /dev/null; then
should_run=true
echo "Install script/workflow files changed."
fi
if grep '^packages/cli/' changed-files.txt > /dev/null; then
while IFS= read -r file; do
case "$file" in
packages/cli/package.json)
if git diff "$BASE_SHA" "$HEAD_SHA" -- "$file" | grep '^[+-]' | grep -v '"version"' | grep -qv '^[+-]\{3\}'; then
should_run=true
echo "packages/cli/package.json changed beyond version field."
fi
;;
*)
should_run=true
echo "Install-related CLI file changed: $file"
;;
esac
done < <(grep '^packages/cli/' changed-files.txt)
fi
if [ "$should_run" = true ]; then
echo "should-run=true" >> "$GITHUB_OUTPUT"
echo "Install-related files changed; running install tests."
else
echo "should-run=false" >> "$GITHUB_OUTPUT"
echo "No install-related files changed; skipping install test work."
fi
test-native-linux:
name: Native install (Linux)
needs: detect-install-changes
if: always()
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check change detection
if: ${{ needs.detect-install-changes.result != 'success' }}
run: |
echo "Install change detection failed"
exit 1
- name: Skip install test
if: ${{ needs.detect-install-changes.outputs.should-run != 'true' }}
run: echo "No install-related files changed; skipping Native install (Linux)."
- name: Checkout
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
persist-credentials: false
- name: Setup Node.js
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Bun
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
with:
bun-version: "1.3.11"
- name: Setup Node.js
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: '24'
- name: Install workspace dependencies
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
run: bun install --frozen-lockfile
- name: Pack CLI for install tests
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
run: bash scripts/pack-cli-for-install-test.sh
- name: Test install script
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
run: |
set -euo pipefail
tmpdir=
tmpdir=$(mktemp -d)
export HOME="$tmpdir"
trap 'rm -rf "$tmpdir"' EXIT
mkdir -p "$HOME/.bun/bin"
ln -s "$(which bun)" "$HOME/.bun/bin/bun"
export PATH="$HOME/.bun/bin:$PATH"
cli_package=$(cat dist/packages/.cli-install-tarball)
export AGENTUITY_CLI_PACKAGE="$PWD/${cli_package}"
./install.sh -y
if [ ! -f "$HOME/.bun/bin/agentuity" ]; then
echo "❌ CLI not installed at $HOME/.bun/bin/agentuity"
ls -la "$HOME/.bun/bin/" || true
exit 1
fi
"$HOME/.bun/bin/agentuity" --version
echo "✅ Native Linux install test passed"
test-native-macos:
name: Native install (macOS)
needs: detect-install-changes
if: always()
runs-on: macos-latest
timeout-minutes: 10
steps:
- name: Check change detection
if: ${{ needs.detect-install-changes.result != 'success' }}
run: |
echo "Install change detection failed"
exit 1
- name: Skip install test
if: ${{ needs.detect-install-changes.outputs.should-run != 'true' }}
run: echo "No install-related files changed; skipping Native install (macOS)."
- name: Checkout
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
persist-credentials: false
- name: Setup Node.js
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Bun
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
with:
bun-version: "1.3.11"
- name: Setup Node.js
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: '24'
- name: Install workspace dependencies
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
run: bun install --frozen-lockfile
- name: Pack CLI for install tests
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
run: bash scripts/pack-cli-for-install-test.sh
- name: Test install script
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
run: |
set -euo pipefail
tmpdir=
tmpdir=$(mktemp -d)
export HOME="$tmpdir"
trap 'rm -rf "$tmpdir"' EXIT
mkdir -p "$HOME/.bun/bin"
ln -s "$(which bun)" "$HOME/.bun/bin/bun"
export PATH="$HOME/.bun/bin:$PATH"
cli_package=$(cat dist/packages/.cli-install-tarball)
export AGENTUITY_CLI_PACKAGE="$PWD/${cli_package}"
./install.sh -y
if [ ! -f "$HOME/.bun/bin/agentuity" ]; then
echo "❌ CLI not installed at $HOME/.bun/bin/agentuity"
ls -la "$HOME/.bun/bin/" || true
exit 1
fi
"$HOME/.bun/bin/agentuity" --version
echo "✅ Native macOS install test passed"
test-linux-distros:
name: Linux distro install smoke
needs: detect-install-changes
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
with:
bun-version: "1.3.11"
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: '24'
- name: Install workspace dependencies
run: bun install --frozen-lockfile
- name: Pack CLI for install tests
run: bash scripts/pack-cli-for-install-test.sh
- name: Test installer across Linux distros
shell: bash
run: |
set -euo pipefail
cat > test-container.sh << 'EOF'
set -eu
if [ -n "${SETUP:-}" ]; then
echo "Running setup commands..."
if ! eval "$SETUP"; then
echo "❌ Distro setup failed"
exit 1
fi
fi
install_node() {
node_major="${NODE_VERSION:-24}"
case "$(uname -m)" in
x86_64) node_arch="x64" ;;
aarch64 | arm64) node_arch="arm64" ;;
*) echo "Unsupported Node architecture: $(uname -m)" && exit 1 ;;
esac
archive=$(curl -fsSL "https://nodejs.org/dist/latest-v${node_major}.x/SHASUMS256.txt" | awk -v arch="$node_arch" '$2 ~ "^node-v[0-9]+\\.[0-9]+\\.[0-9]+-linux-" arch "\\.tar\\.xz$" { print $2; exit }')
if [ -z "$archive" ]; then
echo "Unable to resolve Node ${node_major} archive for ${node_arch}"
exit 1
fi
curl -fsSLo "/tmp/${archive}" "https://nodejs.org/dist/latest-v${node_major}.x/${archive}"
mkdir -p /opt/node
tar -xJf "/tmp/${archive}" -C /opt/node --strip-components=1
export PATH="/opt/node/bin:$PATH"
installed_major=$(node -p 'Number(process.versions.node.split(".")[0])')
if [ "$installed_major" -lt "$node_major" ]; then
echo "Expected Node ${node_major}+ but found $(node --version)"
exit 1
fi
echo "Node version: $(node --version)"
}
install_node
echo "Installing Bun..."
curl -fsSL https://bun.sh/install | bash -s -- bun-v1.3.11 > /dev/null 2>&1
export PATH="$HOME/.bun/bin:$PATH"
bun --version
if [ -f dist/packages/.cli-install-tarball ]; then
cli_package=$(cat dist/packages/.cli-install-tarball)
export AGENTUITY_CLI_PACKAGE="/app/${cli_package}"
fi
if ! ./install.sh -y > /tmp/install.log 2>&1; then
echo "❌ Install failed:"
cat /tmp/install.log
exit 1
fi
if [ ! -f "$HOME/.bun/bin/agentuity" ]; then
echo "❌ CLI not found at $HOME/.bun/bin/agentuity"
ls -la "$HOME/.bun/bin/" || true
exit 1
fi
if ! "$HOME/.bun/bin/agentuity" --version > /tmp/version.log 2>&1; then
echo "❌ CLI execution failed:"
cat /tmp/version.log
exit 1
fi
version=$("$HOME/.bun/bin/agentuity" --version)
echo "✅ SUCCESS: agentuity version $version"
EOF
chmod +x test-container.sh
run_distro() {
local name="$1"
local image="$2"
local setup="$3"
echo "::group::${name}"
echo "Testing ${name} (${image})..."
docker run --rm \
-e CI=true \
-e NODE_VERSION="$NODE_VERSION" \
-e SETUP="$setup" \
-v "$PWD:/app" \
-w /app \
"$image" \
sh -c './test-container.sh'
echo "✅ ${name} test passed"
echo "::endgroup::"
}
run_distro 'Debian 12 (Bookworm)' 'debian:12@sha256:8c181802d706019b2ee6237441b3fb8691b92b5705daf7c4294e7405576c4a0d' 'apt-get update -qq && apt-get install -y -qq curl unzip xz-utils'
run_distro 'Debian 11 (Bullseye)' 'debian:11@sha256:cd3d9e8ec611d6fb11058fbcc4dbd9c27843f09b21623c4c81fb7a1bafc335ca' 'apt-get update -qq && apt-get install -y -qq curl unzip xz-utils'
run_distro 'Ubuntu 24.04' 'ubuntu:24.04@sha256:cdb5fd928fced577cfecf12c8966e830fcdf42ee481fb0b91904eeddc2fe5eff' 'apt-get update -qq && apt-get install -y -qq curl unzip xz-utils'
run_distro 'Ubuntu 22.04' 'ubuntu:22.04@sha256:14be402d3f1eeeb5e7da73d3260322c68e7b51c88388f53e88eb21d6450bd520' 'apt-get update -qq && apt-get install -y -qq curl unzip xz-utils'
run_distro 'Ubuntu 20.04' 'ubuntu:20.04@sha256:c664f8f86ed5a386b0a340d981b8f81714e21a8b9c73f658c4bea56aa179d54a' 'apt-get update -qq && apt-get install -y -qq curl unzip xz-utils'
run_distro 'Fedora Latest' 'fedora:latest@sha256:f717d3f59ea0dc45d3c024c9477e786bab7d418d26636920d17b48016f1e69ca' 'dnf install -y -q curl unzip xz'
run_distro 'Amazon Linux 2023' 'amazonlinux:2023@sha256:41e9b88745672d658868717255dcccbe531d82b88d6dd0ce5de04530b38b35fa' 'yum install -y -q gzip tar unzip xz'
test-bun-checks:
name: Bun version checks
needs: detect-install-changes
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: ${{ env.NODE_VERSION }}
- name: Run Bun version check tests
run: |
chmod +x scripts/test-bun-check.sh
./scripts/test-bun-check.sh
test-scenarios:
name: Installer scenarios
needs: detect-install-changes
if: ${{ needs.detect-install-changes.outputs.should-run == 'true' }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
with:
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
with:
bun-version: "1.3.11"
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
with:
node-version: '24'
- name: Install workspace dependencies
run: bun install --frozen-lockfile
- name: Pack CLI for install tests
run: bash scripts/pack-cli-for-install-test.sh
- name: Run installer scenarios
shell: bash
run: |
set -euo pipefail
# The single-quoted scenario bodies are intentionally expanded inside the container.
# shellcheck disable=SC2016
run_ubuntu() {
local name="$1"
local script="$2"
echo "::group::${name}"
docker run --rm -e CI=true -e NODE_VERSION="$NODE_VERSION" -v "$PWD:/app" -w /app ubuntu:latest@sha256:d31acef2a964b6df1f2b7e20a1525c4f2378024e087a4f8a8a9a4247e6a79573 sh -c "
set -e
apt-get update -qq && apt-get install -y -qq curl unzip xz-utils > /dev/null 2>&1
node_major=\"\${NODE_VERSION:-24}\"
case \"\$(uname -m)\" in
x86_64) node_arch=\"x64\" ;;
aarch64 | arm64) node_arch=\"arm64\" ;;
*) echo \"Unsupported Node architecture: \$(uname -m)\" && exit 1 ;;
esac
archive=\$(curl -fsSL \"https://nodejs.org/dist/latest-v\${node_major}.x/SHASUMS256.txt\" | awk -v arch=\"\$node_arch\" '\$2 ~ \"^node-v[0-9]+\\\\.[0-9]+\\\\.[0-9]+-linux-\" arch \"\\\\.tar\\\\.xz$\" { print \$2; exit }')
curl -fsSLo \"/tmp/\${archive}\" \"https://nodejs.org/dist/latest-v\${node_major}.x/\${archive}\"
mkdir -p /opt/node
tar -xJf \"/tmp/\${archive}\" -C /opt/node --strip-components=1
export PATH=\"/opt/node/bin:\$PATH\"
installed_major=\$(node -p 'Number(process.versions.node.split(\".\")[0])')
if [ \"\$installed_major\" -lt \"\$node_major\" ]; then
echo \"Expected Node \${node_major}+ but found \$(node --version)\"
exit 1
fi
echo \"Node version: \$(node --version)\"
curl -fsSL https://bun.sh/install | bash -s -- bun-v1.3.11 > /dev/null 2>&1
export PATH=\"\$HOME/.bun/bin:\$PATH\"
if [ -f dist/packages/.cli-install-tarball ]; then
cli_package=\$(cat dist/packages/.cli-install-tarball)
export AGENTUITY_CLI_PACKAGE=\"/app/\${cli_package}\"
fi
${script}
"
echo "✅ ${name} passed"
echo "::endgroup::"
}
# shellcheck disable=SC2016
run_ubuntu 'Force reinstall' '
./install.sh -y > /dev/null 2>&1
first_version=$($HOME/.bun/bin/agentuity --version)
./install.sh -y --force > /dev/null 2>&1
second_version=$($HOME/.bun/bin/agentuity --version)
echo "First version: $first_version"
echo "Second version: $second_version"
'
# shellcheck disable=SC2016
run_ubuntu 'Non-interactive with CI env' '
./install.sh > /tmp/install.log 2>&1
if [ ! -f "$HOME/.bun/bin/agentuity" ]; then
echo "❌ CLI not installed"
cat /tmp/install.log
exit 1
fi
$HOME/.bun/bin/agentuity --version
'
# shellcheck disable=SC2016
run_ubuntu 'Upgrade command available' '
./install.sh -y > /dev/null 2>&1
$HOME/.bun/bin/agentuity --help > /tmp/help.log 2>&1 || true
if ! grep -q "upgrade" /tmp/help.log; then
echo "⚠ Upgrade command not found (expected until new version is published)"
exit 0
fi
$HOME/.bun/bin/agentuity upgrade --help > /tmp/upgrade-help.log 2>&1 || true
if ! grep -q "Upgrade the CLI to the latest version" /tmp/upgrade-help.log; then
echo "❌ Upgrade help missing expected text"
cat /tmp/upgrade-help.log
exit 1
fi
'
# shellcheck disable=SC2016
run_ubuntu 'Legacy shim creation' '
mkdir -p "$HOME/.agentuity/bin"
touch "$HOME/.agentuity/bin/agentuity"
export PATH="$HOME/.agentuity/bin:$PATH"
./install.sh -y > /dev/null 2>&1
if [ ! -f "$HOME/.agentuity/bin/agentuity" ]; then
echo "❌ Legacy shim not created"
exit 1
fi
if ! "$HOME/.agentuity/bin/agentuity" --version > /dev/null 2>&1; then
echo "❌ Legacy shim does not work"
exit 1
fi
'
# shellcheck disable=SC2016
run_ubuntu 'Legacy shim cleanup when not on PATH' '
mkdir -p "$HOME/.agentuity/bin"
touch "$HOME/.agentuity/bin/agentuity"
./install.sh -y > /dev/null 2>&1
if [ -f "$HOME/.agentuity/bin/agentuity" ]; then
echo "❌ Legacy binary should have been cleaned up (not on PATH)"
exit 1
fi
if ! "$HOME/.bun/bin/agentuity" --version > /dev/null 2>&1; then
echo "❌ Main CLI does not work"
exit 1
fi
'
test-summary:
name: Install test summary
runs-on: ubuntu-latest
needs:
- detect-install-changes
- test-native-linux
- test-native-macos
- test-linux-distros
- test-bun-checks
- test-scenarios
if: always()
steps:
- name: Check results
run: |
if [ "${{ needs.detect-install-changes.result }}" != "success" ]; then
echo "❌ Install change detection failed"
exit 1
fi
if [ "${{ needs.detect-install-changes.outputs.should-run }}" != "true" ]; then
echo "✅ No install-related files changed; install tests skipped"
exit 0
fi
if [ "${{ needs.test-native-linux.result }}" != "success" ] || \
[ "${{ needs.test-native-macos.result }}" != "success" ] || \
[ "${{ needs.test-linux-distros.result }}" != "success" ] || \
[ "${{ needs.test-bun-checks.result }}" != "success" ] || \
[ "${{ needs.test-scenarios.result }}" != "success" ]; then
echo "❌ Some tests failed"
exit 1
fi
echo "✅ All tests passed!"