Skip to content

Commit 110f89c

Browse files
authored
ci: fix release-day flakes in upgrade test and snap test (#1645)
## Summary Right after a release commit lands on main, the dev build's `package.json` version equals npm latest. Two CI checks were hard-coded to assert outputs that only happen when those versions differ, so they fail on every release-day PR run. **CLI E2E `Test upgrade (bash/pwsh/cmd)`** (ci.yml) — asserted `UPDATED_VERSION != INITIAL_VERSION` after `vp upgrade --force`. When dev == latest, the upgrade runs end-to-end but the version is unchanged. - Fix: assert on the `current` install dir basename (`local-dev-<ts>/` → `<version>/`) instead. The dir flip proves the download/extract/swap and rollback flows ran. Node's `fs.realpathSync` resolves both Unix symlinks and Windows junctions, so all three shells share the same helper. **Snap test `command-upgrade-check`** (`packages/cli/snap-tests-global/command-upgrade-check/`) — recorded the "Update available" output of `vp upgrade --check`. When dev == latest, the actual output is "Already up to date". - Fix: query the `alpha` dist-tag instead. Alpha is always a different version from latest (currently `0.1.21-alpha.7`), so the "Update available" branch is always taken. Semver normalization masks the actual version, so the snap body is unchanged. ## Failure examples - Upgrade test: https://github.com/voidzero-dev/vite-plus/actions/runs/26112690623/job/76915605617 - Snap test: https://github.com/voidzero-dev/vite-plus/actions/runs/26148842387/job/76910949450 (also blocks #1635) ## Test plan - [ ] CI passes on this PR. - [ ] After next release, both checks still pass on the post-release-day merge-to-main run. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: changes only affect CI assertions and snapshot test inputs, not production code. Main risk is masking a real regression if install directory swapping semantics change. > > **Overview** > Makes the CI `vp upgrade` E2E checks resilient to release-day runs by **asserting on the `.vite-plus/current` install directory target** (via `fs.realpathSync`) instead of comparing CLI versions, across bash/pwsh/cmd. > > Stabilizes the `command-upgrade-check` snapshot by running `vp upgrade --check` against the `alpha` dist-tag so the *"Update available"* branch is consistently exercised. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e4556ae. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 12368da commit 110f89c

3 files changed

Lines changed: 53 additions & 51 deletions

File tree

.github/workflows/ci.yml

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,21 @@ jobs:
419419
- name: Test upgrade (bash)
420420
shell: bash
421421
run: |
422-
# Helper to read the installed CLI version from package.json
423-
get_cli_version() {
424-
node -p "require(require('path').resolve(process.env.USERPROFILE || process.env.HOME, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"
422+
# Resolve `current` (symlink on Unix, junction on Windows) and return
423+
# the install dir basename — "local-dev-<timestamp>" for the dev
424+
# build, "<version>" for a downloaded release. Node's realpathSync
425+
# handles symlinks and junctions uniformly.
426+
get_current_dirname() {
427+
node -p "require('path').basename(require('fs').realpathSync(require('path').resolve(process.env.USERPROFILE || process.env.HOME, '.vite-plus', 'current')))"
425428
}
426429
427-
# Save initial (dev build) version
428-
INITIAL_VERSION=$(get_cli_version)
429-
echo "Initial version: $INITIAL_VERSION"
430+
# Assert on the `current` target dir, not the version: right after a
431+
# release commit on main, the dev build's version equals npm latest,
432+
# so `vp upgrade --force` succeeds but the version is unchanged.
433+
# The dir flip (dev → release → dev) is the real signal that the
434+
# download/extract/swap and rollback flows ran end-to-end.
435+
INITIAL_DIR=$(get_current_dirname)
436+
echo "Initial install dir: $INITIAL_DIR"
430437
431438
# --check queries npm registry and prints update status
432439
vp upgrade --check
@@ -438,24 +445,22 @@ jobs:
438445
439446
ls -la ~/.vite-plus/
440447
441-
# Verify version changed after update
442-
UPDATED_VERSION=$(get_cli_version)
443-
echo "Updated version: $UPDATED_VERSION"
444-
if [ "$UPDATED_VERSION" == "$INITIAL_VERSION" ]; then
445-
echo "Error: version should have changed after upgrade (still $INITIAL_VERSION)"
448+
UPDATED_DIR=$(get_current_dirname)
449+
echo "Updated install dir: $UPDATED_DIR"
450+
if [ "$UPDATED_DIR" == "$INITIAL_DIR" ]; then
451+
echo "Error: current install dir should have changed after upgrade (still $INITIAL_DIR)"
446452
exit 1
447453
fi
448454
449-
# rollback to the previous version
455+
# rollback to the previous install
450456
vp upgrade --rollback
451457
vp --version
452458
vp env doctor
453459
454-
# Verify version restored after rollback
455-
ROLLBACK_VERSION=$(get_cli_version)
456-
echo "Rollback version: $ROLLBACK_VERSION"
457-
if [ "$ROLLBACK_VERSION" != "$INITIAL_VERSION" ]; then
458-
echo "Error: version should have been restored after rollback (expected $INITIAL_VERSION, got $ROLLBACK_VERSION)"
460+
ROLLBACK_DIR=$(get_current_dirname)
461+
echo "Rollback install dir: $ROLLBACK_DIR"
462+
if [ "$ROLLBACK_DIR" != "$INITIAL_DIR" ]; then
463+
echo "Error: current install dir should have been restored after rollback (expected $INITIAL_DIR, got $ROLLBACK_DIR)"
459464
exit 1
460465
fi
461466
@@ -467,14 +472,13 @@ jobs:
467472
. (Join-Path $vpHome 'env.ps1')
468473
Get-ChildItem $vpHome
469474
470-
# Helper to read the installed CLI version from package.json
471-
function Get-CliVersion {
472-
node -p "require(require('path').resolve(process.env.USERPROFILE || process.env.HOME, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"
475+
# See bash block above for why we assert on the install dir basename.
476+
function Get-CurrentDirname {
477+
node -p "require('path').basename(require('fs').realpathSync(require('path').resolve(process.env.USERPROFILE || process.env.HOME, '.vite-plus', 'current')))"
473478
}
474479
475-
# Save initial (dev build) version
476-
$initialVersion = Get-CliVersion
477-
Write-Host "Initial version: $initialVersion"
480+
$initialDir = Get-CurrentDirname
481+
Write-Host "Initial install dir: $initialDir"
478482
479483
# --check queries npm registry and prints update status
480484
vp upgrade --check
@@ -486,34 +490,32 @@ jobs:
486490
487491
Get-ChildItem $vpHome
488492
489-
# Verify version changed after update
490-
$updatedVersion = Get-CliVersion
491-
Write-Host "Updated version: $updatedVersion"
492-
if ($updatedVersion -eq $initialVersion) {
493-
Write-Error "Error: version should have changed after upgrade (still $initialVersion)"
493+
$updatedDir = Get-CurrentDirname
494+
Write-Host "Updated install dir: $updatedDir"
495+
if ($updatedDir -eq $initialDir) {
496+
Write-Error "Error: current install dir should have changed after upgrade (still $initialDir)"
494497
exit 1
495498
}
496499
497-
# rollback to the previous version
500+
# rollback to the previous install
498501
vp upgrade --rollback
499502
vp --version
500503
vp env doctor
501504
502-
# Verify version restored after rollback
503-
$rollbackVersion = Get-CliVersion
504-
Write-Host "Rollback version: $rollbackVersion"
505-
if ($rollbackVersion -ne $initialVersion) {
506-
Write-Error "Error: version should have been restored after rollback (expected $initialVersion, got $rollbackVersion)"
505+
$rollbackDir = Get-CurrentDirname
506+
Write-Host "Rollback install dir: $rollbackDir"
507+
if ($rollbackDir -ne $initialDir) {
508+
Write-Error "Error: current install dir should have been restored after rollback (expected $initialDir, got $rollbackDir)"
507509
exit 1
508510
}
509511
510512
- name: Test upgrade (cmd)
511513
if: ${{ matrix.os == 'windows-latest' }}
512514
shell: cmd
513515
run: |
514-
REM Save initial (dev build) version
515-
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"`) do set INITIAL_VERSION=%%v
516-
echo Initial version: %INITIAL_VERSION%
516+
REM See bash block above for why we assert on the install dir basename.
517+
for /f "usebackq delims=" %%v in (`node -p "require('path').basename(require('fs').realpathSync(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current')))"`) do set INITIAL_DIR=%%v
518+
echo Initial install dir: %INITIAL_DIR%
517519
518520
REM --check queries npm registry and prints update status
519521
vp upgrade --check
@@ -525,24 +527,22 @@ jobs:
525527
526528
dir "%USERPROFILE%\.vite-plus\"
527529
528-
REM Verify version changed after update
529-
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"`) do set UPDATED_VERSION=%%v
530-
echo Updated version: %UPDATED_VERSION%
531-
if "%UPDATED_VERSION%"=="%INITIAL_VERSION%" (
532-
echo Error: version should have changed after upgrade, still %INITIAL_VERSION%
530+
for /f "usebackq delims=" %%v in (`node -p "require('path').basename(require('fs').realpathSync(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current')))"`) do set UPDATED_DIR=%%v
531+
echo Updated install dir: %UPDATED_DIR%
532+
if "%UPDATED_DIR%"=="%INITIAL_DIR%" (
533+
echo Error: current install dir should have changed after upgrade, still %INITIAL_DIR%
533534
exit /b 1
534535
)
535536
536-
REM rollback to the previous version
537+
REM rollback to the previous install
537538
vp upgrade --rollback
538539
vp --version
539540
vp env doctor
540541
541-
REM Verify version restored after rollback
542-
for /f "usebackq delims=" %%v in (`node -p "require(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current', 'node_modules', 'vite-plus', 'package.json')).version"`) do set ROLLBACK_VERSION=%%v
543-
echo Rollback version: %ROLLBACK_VERSION%
544-
if not "%ROLLBACK_VERSION%"=="%INITIAL_VERSION%" (
545-
echo Error: version should have been restored after rollback, expected %INITIAL_VERSION%, got %ROLLBACK_VERSION%
542+
for /f "usebackq delims=" %%v in (`node -p "require('path').basename(require('fs').realpathSync(require('path').resolve(process.env.USERPROFILE, '.vite-plus', 'current')))"`) do set ROLLBACK_DIR=%%v
543+
echo Rollback install dir: %ROLLBACK_DIR%
544+
if not "%ROLLBACK_DIR%"=="%INITIAL_DIR%" (
545+
echo Error: current install dir should have been restored after rollback, expected %INITIAL_DIR%, got %ROLLBACK_DIR%
546546
exit /b 1
547547
)
548548
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
> vp upgrade --check # check for updates without installing
1+
> vp upgrade --check --tag alpha # alpha tag avoids release-day flake (dev version equals npm latest right after a release, hiding the Update-available branch)
22
info: checking for updates...
3-
info: found vite-plus@<semver> (current: <semver>)
3+
info: found vite-plus@<semver>
44
Update available: <semver> → <semver>
55
Run `vp upgrade` to update.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"ignoredPlatforms": ["win32", { "os": "linux", "libc": "musl" }],
3-
"commands": ["vp upgrade --check # check for updates without installing"]
3+
"commands": [
4+
"vp upgrade --check --tag alpha # alpha tag avoids release-day flake (dev version equals npm latest right after a release, hiding the Update-available branch)"
5+
]
46
}

0 commit comments

Comments
 (0)