forked from spiceai/spiceai
-
Notifications
You must be signed in to change notification settings - Fork 0
606 lines (538 loc) · 18.9 KB
/
install_scripts_test.yml
File metadata and controls
606 lines (538 loc) · 18.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
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
---
name: Install Scripts Test
on:
pull_request:
branches:
- trunk
- release-*
- release/*
paths:
- 'install/**'
- 'test/scripts/install-scripts-test.sh'
- '.github/workflows/install_scripts_test.yml'
push:
branches:
- trunk
paths:
- 'install/**'
- 'test/scripts/install-scripts-test.sh'
- '.github/workflows/install_scripts_test.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
# Unit tests for install script logic
test-install-scripts:
name: Test Install Scripts (${{ matrix.os }}, ${{ matrix.shell }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- os: linux-x64
runner: ubuntu-24.04
shell: bash
- os: linux-x64
runner: ubuntu-24.04
shell: zsh
- os: linux-x64
runner: ubuntu-24.04
shell: sh
# Linux ARM64
- os: linux-arm64
runner: ubuntu-24.04-arm
shell: bash
- os: linux-arm64
runner: ubuntu-24.04-arm
shell: zsh
# macOS ARM64 (Apple Silicon)
- os: macos-arm64
runner: macos-latest
shell: bash
- os: macos-arm64
runner: macos-latest
shell: zsh
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install zsh (Ubuntu)
if: contains(matrix.os, 'linux') && matrix.shell == 'zsh'
run: sudo apt-get update && sudo apt-get install -y zsh
- name: Run install script tests
shell: ${{ matrix.shell }} {0}
run: |
chmod +x test/scripts/install-scripts-test.sh
${{ matrix.shell }} test/scripts/install-scripts-test.sh --live
# Test shell detection and PATH configuration
test-shell-detection:
name: Shell Detection (${{ matrix.os }}, ${{ matrix.shell }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64
- os: linux-x64
runner: ubuntu-24.04
shell: bash
- os: linux-x64
runner: ubuntu-24.04
shell: zsh
# Linux ARM64
- os: linux-arm64
runner: ubuntu-24.04-arm
shell: bash
# macOS ARM64
- os: macos-arm64
runner: macos-latest
shell: bash
- os: macos-arm64
runner: macos-latest
shell: zsh
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install zsh (Ubuntu)
if: contains(matrix.os, 'linux') && matrix.shell == 'zsh'
run: sudo apt-get update && sudo apt-get install -y zsh
- name: Create shell profile
shell: ${{ matrix.shell }} {0}
run: |
if [ "${{ matrix.shell }}" = "bash" ]; then
touch ~/.bashrc
touch ~/.bash_profile
elif [ "${{ matrix.shell }}" = "zsh" ]; then
touch ~/.zshrc
fi
- name: Test install.sh with shell detection
shell: ${{ matrix.shell }} {0}
env:
SHELL: /bin/${{ matrix.shell }}
run: |
chmod +x install/install.sh
./install/install.sh
# Verify binary was installed
if [ ! -f "$HOME/.spice/bin/spice" ]; then
echo "ERROR: spice binary not found at $HOME/.spice/bin/spice"
exit 1
fi
# Verify binary is executable
if [ ! -x "$HOME/.spice/bin/spice" ]; then
echo "ERROR: spice binary is not executable"
exit 1
fi
# Verify it runs
"$HOME/.spice/bin/spice" version
- name: Verify PATH instructions
shell: ${{ matrix.shell }} {0}
run: |
# Check that the shell profile was updated with PATH
profile_file=""
if [ "${{ matrix.shell }}" = "bash" ]; then
if [ -f ~/.bash_profile ]; then
profile_file=~/.bash_profile
elif [ -f ~/.bashrc ]; then
profile_file=~/.bashrc
fi
elif [ "${{ matrix.shell }}" = "zsh" ]; then
profile_file=~/.zshrc
fi
if [ -n "$profile_file" ] && [ -f "$profile_file" ]; then
if grep -q ".spice/bin" "$profile_file"; then
echo "✓ PATH configuration found in $profile_file"
else
echo "⚠ PATH configuration not found in $profile_file (may require manual setup)"
fi
fi
# Test custom install directories
test-custom-install-dir:
name: Custom Install Dir (${{ matrix.os }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux-x64
runner: ubuntu-24.04
- os: linux-arm64
runner: ubuntu-24.04-arm
- os: macos-arm64
runner: macos-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Test install.sh with custom directory
run: |
export SPICE_CLI_INSTALL_DIR="${{ github.workspace }}/custom-spice-bin"
mkdir -p "$SPICE_CLI_INSTALL_DIR"
chmod +x install/install.sh
./install/install.sh
# Verify binary location
if [ ! -f "$SPICE_CLI_INSTALL_DIR/spice" ]; then
echo "ERROR: spice not installed to custom directory"
ls -la "$SPICE_CLI_INSTALL_DIR" || true
exit 1
fi
"$SPICE_CLI_INSTALL_DIR/spice" version
- name: Test install-spiced.sh with custom directory
env:
VARIANT: models
SPICED_INSTALL_DIR: ${{ github.workspace }}/custom-spiced-bin
run: |
mkdir -p "$SPICED_INSTALL_DIR"
chmod +x install/install-spiced.sh
./install/install-spiced.sh
# Verify binary location
if [ ! -f "$SPICED_INSTALL_DIR/spiced" ]; then
echo "ERROR: spiced not installed to custom directory"
ls -la "$SPICED_INSTALL_DIR" || true
exit 1
fi
"$SPICED_INSTALL_DIR/spiced" --version
# Test all spiced variants across architectures
test-spiced-variants:
name: Spiced Variant (${{ matrix.os }}, ${{ matrix.variant }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
# Linux x86_64 variants
- os: linux-x64
runner: ubuntu-24.04
variant: ''
- os: linux-x64
runner: ubuntu-24.04
variant: models
# Linux ARM64 variants
- os: linux-arm64
runner: ubuntu-24.04-arm
variant: ''
- os: linux-arm64
runner: ubuntu-24.04-arm
variant: models
# macOS ARM64 variants
- os: macos-arm64
runner: macos-latest
variant: ''
- os: macos-arm64
runner: macos-latest
variant: models
- os: macos-arm64
runner: macos-latest
variant: metal
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Test install-spiced.sh with variant '${{ matrix.variant }}'
env:
VARIANT: ${{ matrix.variant }}
SPICED_INSTALL_DIR: ${{ github.workspace }}/bin
run: |
mkdir -p bin
chmod +x install/install-spiced.sh
./install/install-spiced.sh
./bin/spiced --version
# Test specific version installation
test-specific-version:
name: Specific Version Install (${{ matrix.os }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- os: linux-x64
runner: ubuntu-24.04
- os: linux-arm64
runner: ubuntu-24.04-arm
- os: macos-arm64
runner: macos-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Get a known release version
id: get_version
run: |
# Get the latest release tag and strip the 'v' prefix (scripts add it back)
VERSION=$(curl -sS "https://api.github.com/repos/spiceai/spiceai/releases/latest" | grep '"tag_name"' | head -1 | sed 's/.*: "v\?\(.*\)",/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Testing with version: $VERSION"
- name: Test install.sh with specific version
env:
SPICE_CLI_INSTALL_DIR: ${{ github.workspace }}/bin-cli
run: |
mkdir -p "$SPICE_CLI_INSTALL_DIR"
chmod +x install/install.sh
./install/install.sh ${{ steps.get_version.outputs.version }}
"$SPICE_CLI_INSTALL_DIR/spice" version
- name: Test install-spiced.sh with specific version
env:
VARIANT: models
SPICED_INSTALL_DIR: ${{ github.workspace }}/bin-spiced
run: |
mkdir -p "$SPICED_INSTALL_DIR"
chmod +x install/install-spiced.sh
./install/install-spiced.sh ${{ steps.get_version.outputs.version }}
"$SPICED_INSTALL_DIR/spiced" --version
# Test HTTP client fallback (curl vs wget)
test-http-clients:
name: HTTP Client (${{ matrix.client }})
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
client: [curl, wget]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Remove alternative HTTP client
run: |
if [ "${{ matrix.client }}" = "curl" ]; then
# Hide wget so script must use curl
sudo mv /usr/bin/wget /usr/bin/wget.bak 2>/dev/null || true
else
# Hide curl so script must use wget
sudo mv /usr/bin/curl /usr/bin/curl.bak 2>/dev/null || true
fi
- name: Verify only ${{ matrix.client }} is available
run: |
if [ "${{ matrix.client }}" = "curl" ]; then
which curl
! which wget || echo "wget still available (ok if it fails)"
else
which wget
! which curl || echo "curl still available (ok if it fails)"
fi
- name: Test install.sh with ${{ matrix.client }}
env:
SPICE_CLI_INSTALL_DIR: ${{ github.workspace }}/bin
run: |
mkdir -p "$SPICE_CLI_INSTALL_DIR"
chmod +x install/install.sh
./install/install.sh
"$SPICE_CLI_INSTALL_DIR/spice" version
- name: Restore HTTP clients
if: always()
run: |
sudo mv /usr/bin/wget.bak /usr/bin/wget 2>/dev/null || true
sudo mv /usr/bin/curl.bak /usr/bin/curl 2>/dev/null || true
# Test error handling
test-error-handling:
name: Error Handling
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Test invalid version handling
run: |
chmod +x install/install-spiced.sh
export SPICED_INSTALL_DIR="${{ github.workspace }}/bin"
mkdir -p "$SPICED_INSTALL_DIR"
# This should fail gracefully with a non-existent version
if ./install/install-spiced.sh v0.0.0-nonexistent 2>&1; then
echo "ERROR: Script should have failed for non-existent version"
exit 1
else
echo "✓ Script correctly failed for non-existent version"
fi
- name: Test invalid CUDA variant on non-Linux
if: runner.os == 'macOS'
run: |
chmod +x install/install-spiced.sh
export SPICED_INSTALL_DIR="${{ github.workspace }}/bin"
export VARIANT="cuda"
export CUDA_VERSION="90"
mkdir -p "$SPICED_INSTALL_DIR"
# This should fail on macOS
if ./install/install-spiced.sh 2>&1; then
echo "ERROR: CUDA variant should not be allowed on macOS"
exit 1
else
echo "✓ Script correctly rejected CUDA variant on macOS"
fi
# Test on Windows with WSL
test-windows-wsl:
name: Windows WSL (${{ matrix.distro }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
distro: [Ubuntu-24.04]
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Setup WSL
uses: Vampire/setup-wsl@2d33ce25ddebc8780792ec86a25a0557e1c7de96 # v6
with:
distribution: ${{ matrix.distro }}
additional-packages: curl wget
- name: Run install script tests in WSL
shell: wsl-bash {0}
run: |
chmod +x test/scripts/install-scripts-test.sh
./test/scripts/install-scripts-test.sh --live
- name: Test install.sh in WSL
shell: wsl-bash {0}
run: |
chmod +x install/install.sh
export SPICE_CLI_INSTALL_DIR="$HOME/.spice/bin"
./install/install.sh
if [ ! -f "$SPICE_CLI_INSTALL_DIR/spice" ]; then
echo "ERROR: spice binary not found"
exit 1
fi
"$SPICE_CLI_INSTALL_DIR/spice" version
- name: Test install-spiced.sh in WSL
shell: wsl-bash {0}
env:
VARIANT: models
run: |
chmod +x install/install-spiced.sh
export SPICED_INSTALL_DIR="$HOME/bin"
mkdir -p "$SPICED_INSTALL_DIR"
./install/install-spiced.sh
if [ ! -f "$SPICED_INSTALL_DIR/spiced" ]; then
echo "ERROR: spiced binary not found"
exit 1
fi
"$SPICED_INSTALL_DIR/spiced" --version
# Test native Windows with PowerShell
test-windows-native:
name: Windows Native (PowerShell)
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Test Install.ps1
shell: pwsh
run: |
# Run the PowerShell installer
.\install\Install.ps1
# Verify the binary was installed
$spicePath = Join-Path $HOME ".spice\bin\spice.exe"
if (-not (Test-Path $spicePath)) {
Write-Error "ERROR: spice.exe not found at $spicePath"
exit 1
}
# Verify it runs
& $spicePath version
- name: Verify PATH was updated
shell: pwsh
run: |
$userPath = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::User)
$spiceBinDir = Join-Path $HOME ".spice\bin"
if ($userPath -like "*$spiceBinDir*") {
Write-Host "✓ PATH was updated to include $spiceBinDir"
} else {
Write-Host "⚠ PATH does not contain $spiceBinDir"
Write-Host "Current User PATH: $userPath"
}
# Test Windows PowerShell with custom directory
test-windows-custom-dir:
name: Windows Custom Dir (PowerShell)
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Test Install.ps1 with custom directory
shell: pwsh
run: |
# Create custom install directory
$customDir = Join-Path $env:GITHUB_WORKSPACE "custom-spice-bin"
New-Item -Path $customDir -ItemType Directory -Force | Out-Null
# Modify script to use custom directory (inline for testing)
$content = Get-Content .\install\Install.ps1 -Raw
$content = $content -replace '\$spiceCliInstallDir = Join-Path \$HOME \$spiceBin', "`$spiceCliInstallDir = `"$customDir`""
$content | Set-Content .\install\Install-Custom.ps1
# Run the modified script
.\install\Install-Custom.ps1
# Verify binary location
$spicePath = Join-Path $customDir "spice.exe"
if (-not (Test-Path $spicePath)) {
Write-Error "ERROR: spice.exe not found at $spicePath"
Get-ChildItem $customDir
exit 1
}
# Verify it runs
& $spicePath version
# Test Windows PowerShell error handling
test-windows-errors:
name: Windows Error Handling (PowerShell)
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Test PowerShell script syntax
shell: pwsh
run: |
# Check for syntax errors using AST
$errors = $null
$tokens = $null
[System.Management.Automation.Language.Parser]::ParseFile(
(Join-Path $PWD "install\Install.ps1"),
[ref]$tokens,
[ref]$errors
) | Out-Null
if ($errors.Count -gt 0) {
Write-Error "PowerShell syntax errors found:"
$errors | ForEach-Object { Write-Error $_.Message }
exit 1
}
Write-Host "✓ No syntax errors in Install.ps1"
- name: Test PSScriptAnalyzer (if available)
shell: pwsh
continue-on-error: true
run: |
# Install and run PSScriptAnalyzer
Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser
$results = Invoke-ScriptAnalyzer -Path .\install\Install.ps1 -Severity Error
if ($results.Count -gt 0) {
Write-Warning "PSScriptAnalyzer found issues:"
$results | Format-Table -AutoSize
} else {
Write-Host "✓ No critical issues found by PSScriptAnalyzer"
}
# Validate scripts with shellcheck
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: Install shellcheck
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Run shellcheck on install.sh
run: |
shellcheck -e SC2034,SC2086,SC2155,SC2223,SC1090 install/install.sh
- name: Run shellcheck on install-spiced.sh
run: |
shellcheck -e SC2034,SC2086,SC2155,SC2223,SC1090 install/install-spiced.sh
- name: Run shellcheck on test script
run: |
shellcheck -e SC2034,SC2086,SC2155 test/scripts/install-scripts-test.sh