Skip to content

Commit 8312986

Browse files
authored
feat: support all installation methods in upgrade command (#97)
* feat: use GitHub Releases for all version checks, add proto and local upgrade support - Switch upgrade command and background update-check from npm registry to GitHub Releases API so all install methods get accurate version info - Add proto toolchain detection: when archgate is installed via proto, `archgate upgrade` runs `proto install archgate latest --pin` - Add local dev dependency detection: when running from node_modules, detect the project's package manager via lockfile and run the appropriate update command (e.g. `bun add -d archgate@latest`) - DRY up the upgrade flows by extracting shared version check into the command action and reusing runExternalUpgrade for all external paths - Reuse fetchLatestGitHubVersion from binary-upgrade helper in update-check to eliminate duplicated fetch logic * test: add smoke tests for all upgrade install method detection paths Add CI smoke tests (Windows + Linux) for binary, proto, and node_modules install paths. Add unit tests for install method detection helpers.
1 parent 5d9cc71 commit 8312986

5 files changed

Lines changed: 468 additions & 114 deletions

File tree

.github/workflows/smoke-test.yml

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,54 @@ jobs:
6262
exit 1
6363
}
6464
65+
- name: Smoke test binary from install dir
66+
shell: pwsh
67+
run: |
68+
# Simulate binary install at %APPDATA%\archgate\
69+
$installDir = Join-Path $env:APPDATA "archgate"
70+
New-Item -Path $installDir -ItemType Directory -Force | Out-Null
71+
Copy-Item "dist/archgate-smoke-test.exe" (Join-Path $installDir "archgate.exe")
72+
$output = & (Join-Path $installDir "archgate.exe") --version 2>&1
73+
Write-Host "archgate version from binary install dir: $output"
74+
if ($LASTEXITCODE -ne 0) {
75+
Write-Error "Binary exited with code $LASTEXITCODE"
76+
exit 1
77+
}
78+
Remove-Item -Path $installDir -Recurse -Force -ErrorAction SilentlyContinue
79+
80+
- name: Smoke test binary from proto dir
81+
shell: pwsh
82+
run: |
83+
# Simulate proto install at ~/.proto/tools/archgate/<version>/
84+
$protoDir = Join-Path $env:USERPROFILE ".proto" "tools" "archgate" "0.0.0"
85+
New-Item -Path $protoDir -ItemType Directory -Force | Out-Null
86+
Copy-Item "dist/archgate-smoke-test.exe" (Join-Path $protoDir "archgate.exe")
87+
$output = & (Join-Path $protoDir "archgate.exe") --version 2>&1
88+
Write-Host "archgate version from proto dir: $output"
89+
if ($LASTEXITCODE -ne 0) {
90+
Write-Error "Binary exited with code $LASTEXITCODE"
91+
exit 1
92+
}
93+
Remove-Item -Path (Join-Path $env:USERPROFILE ".proto") -Recurse -Force -ErrorAction SilentlyContinue
94+
95+
- name: Smoke test binary from node_modules
96+
shell: pwsh
97+
run: |
98+
# Simulate local dev dependency install
99+
$projectDir = Join-Path $env:TEMP "archgate-local-smoke"
100+
$binDir = Join-Path $projectDir "node_modules" ".bin"
101+
New-Item -Path $binDir -ItemType Directory -Force | Out-Null
102+
Set-Content -Path (Join-Path $projectDir "package.json") -Value "{}"
103+
Set-Content -Path (Join-Path $projectDir "bun.lock") -Value ""
104+
Copy-Item "dist/archgate-smoke-test.exe" (Join-Path $binDir "archgate.exe")
105+
$output = & (Join-Path $binDir "archgate.exe") --version 2>&1
106+
Write-Host "archgate version from node_modules: $output"
107+
if ($LASTEXITCODE -ne 0) {
108+
Write-Error "Binary exited with code $LASTEXITCODE"
109+
exit 1
110+
}
111+
Remove-Item -Path $projectDir -Recurse -Force -ErrorAction SilentlyContinue
112+
65113
- name: Smoke test install.ps1
66114
shell: pwsh
67115
env:
@@ -107,13 +155,61 @@ jobs:
107155
Remove-Item -Path $installDir -Recurse -Force -ErrorAction SilentlyContinue
108156
109157
linux:
110-
name: Linux Install Script Smoke Test
158+
name: Linux Smoke Test
111159
runs-on: ubuntu-latest
112160
timeout-minutes: 10
113161
if: github.event.pull_request.draft == false
114162
steps:
115163
- name: Checkout code
116164
uses: actions/checkout@v4
165+
with:
166+
fetch-depth: 0
167+
168+
- uses: moonrepo/setup-toolchain@v0
169+
with:
170+
auto-install: true
171+
172+
- name: Install dependencies
173+
run: bun install --frozen-lockfile
174+
175+
- name: Build Linux binary
176+
run: bun build src/cli.ts --compile --bytecode --outfile dist/archgate-smoke-test
177+
178+
- name: Smoke test binary
179+
run: |
180+
chmod +x dist/archgate-smoke-test
181+
output=$(dist/archgate-smoke-test --version 2>&1)
182+
echo "archgate version: $output"
183+
184+
- name: Smoke test binary from ~/.archgate/bin/
185+
run: |
186+
mkdir -p ~/.archgate/bin
187+
cp dist/archgate-smoke-test ~/.archgate/bin/archgate
188+
chmod +x ~/.archgate/bin/archgate
189+
output=$(~/.archgate/bin/archgate --version 2>&1)
190+
echo "archgate version from binary install dir: $output"
191+
rm -rf ~/.archgate/bin
192+
193+
- name: Smoke test binary from proto dir
194+
run: |
195+
mkdir -p ~/.proto/tools/archgate/0.0.0
196+
cp dist/archgate-smoke-test ~/.proto/tools/archgate/0.0.0/archgate
197+
chmod +x ~/.proto/tools/archgate/0.0.0/archgate
198+
output=$(~/.proto/tools/archgate/0.0.0/archgate --version 2>&1)
199+
echo "archgate version from proto dir: $output"
200+
rm -rf ~/.proto/tools/archgate
201+
202+
- name: Smoke test binary from node_modules
203+
run: |
204+
project_dir=$(mktemp -d)
205+
mkdir -p "$project_dir/node_modules/.bin"
206+
echo '{}' > "$project_dir/package.json"
207+
touch "$project_dir/bun.lock"
208+
cp dist/archgate-smoke-test "$project_dir/node_modules/.bin/archgate"
209+
chmod +x "$project_dir/node_modules/.bin/archgate"
210+
output=$("$project_dir/node_modules/.bin/archgate" --version 2>&1)
211+
echo "archgate version from node_modules: $output"
212+
rm -rf "$project_dir"
117213
118214
- name: Smoke test install.sh
119215
env:

0 commit comments

Comments
 (0)