Skip to content

Commit eee2b43

Browse files
committed
chore: merge main into pm selection isolation
2 parents 5569acc + 17ad495 commit eee2b43

15 files changed

Lines changed: 236 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -924,15 +924,17 @@ jobs:
924924
# flavors on Linux and macOS: the local flavor uses the packages/cli build
925925
# from this job, the global flavor reuses the installed release binary via
926926
# VP_SNAP_GLOBAL_VP (no vp_global_cli compile; build-upstream builds or
927-
# cache-restores it). One leg per OS: the suite is not sharded. Windows
928-
# runs in cli-snapshot-test-windows via the cross-compiled archive.
927+
# cache-restores it). Three shards per OS split the trials across runners.
928+
# Windows runs in cli-snapshot-test-windows via the cross-compiled archive.
929929
cli-snapshot-test:
930-
name: CLI snapshot test (${{ matrix.target }})
930+
name: CLI snapshot test (${{ matrix.target }}, shard ${{ matrix.shard }}/3)
931931
needs:
932932
- download-previous-rolldown-binaries
933933
strategy:
934934
fail-fast: false
935935
matrix:
936+
os: [namespace-profile-linux-x64-default, namespace-profile-mac-default]
937+
shard: [1, 2, 3]
936938
include:
937939
- os: namespace-profile-linux-x64-default
938940
target: x86_64-unknown-linux-gnu
@@ -1020,18 +1022,23 @@ jobs:
10201022
cargo test -p vp_cli_snapshots
10211023
env:
10221024
RUST_BACKTRACE: '1'
1025+
VP_SNAP_SHARD: ${{ matrix.shard }}/3
10231026

10241027
# Runs the PTY snapshot suite (crates/vp_cli_snapshots) on Windows with
10251028
# BOTH vp flavors, without a Rust toolchain on the runner: the test binary
10261029
# and vpt arrive cross-compiled in the nextest archive from
10271030
# build-windows-tests, the global vp comes prebuilt from build-windows-cli,
10281031
# and the JS CLI is built here (skip-native) for the local flavor.
10291032
cli-snapshot-test-windows:
1030-
name: CLI snapshot test (Windows)
1033+
name: CLI snapshot test (Windows, shard ${{ matrix.shard }}/3)
10311034
needs:
10321035
- download-previous-rolldown-binaries
10331036
- build-windows-cli
10341037
- build-windows-tests
1038+
strategy:
1039+
fail-fast: false
1040+
matrix:
1041+
shard: [1, 2, 3]
10351042
# Runs on the Namespace Windows runner. This is a PTY snapshot suite that
10361043
# opens a pseudo-console (ConPTY) and spawns vp into it. It previously stayed
10371044
# on GitHub-hosted windows-latest because Namespace's Windows runners ran
@@ -1129,7 +1136,7 @@ jobs:
11291136
export VP_SNAP_PWSH_BIN="$(cygpath -w "$(command -v pwsh.exe)")"
11301137
# --no-fail-fast: on a snapshot suite every diff is diagnostic
11311138
# signal; cancelling on the first failure hides the rest.
1132-
cargo-nextest nextest run --archive-file windows-snapshot-tests.tar.zst --workspace-remap . --no-fail-fast
1139+
cargo-nextest nextest run --archive-file windows-snapshot-tests.tar.zst --workspace-remap . --no-fail-fast --partition hash:${{ matrix.shard }}/3
11331140
env:
11341141
RUST_BACKTRACE: '1'
11351142
# Keep Windows env parity with the `test` recipe in justfile.

crates/vp_cli_snapshots/tests/cli_snapshots/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ cases). Prerequisites: both flavors need `cargo build -p vp_global_cli`
5656
older than `src`, so a forgotten rebuild never silently tests stale
5757
local-CLI code.
5858

59+
CI runs three shards per platform. Linux and macOS use `VP_SNAP_SHARD=1/3`
60+
(then `2/3` and `3/3`) to distribute the ordered trials round-robin. Sharding
61+
happens before name filtering, so filtered runs keep the same assignment.
62+
Leave the variable unset to run the whole suite. Windows uses the existing
63+
nextest runner with `--partition hash:1/3` (then `2/3` and `3/3`).
64+
5965
Environment overrides, mainly for CI:
6066

6167
| Variable | Effect |
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "kami",
3+
"private": true,
4+
"devDependencies": {
5+
"typescript": "~6.0.2",
6+
"vite": "catalog:",
7+
"vite-plus": "catalog:"
8+
}
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "home-workspace",
3+
"private": true,
4+
"dependencies": {
5+
"kami": "workspace:*"
6+
},
7+
"devEngines": {
8+
"packageManager": {
9+
"name": "pnpm",
10+
"version": "11.25.0"
11+
}
12+
}
13+
}

crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_upgrade_parent_workspace/home/pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
packages:
2+
- apps-ts/*
3+
catalog:
4+
vite: 8.2.2
5+
vite-plus: 0.3.1
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { existsSync, mkdirSync, realpathSync, symlinkSync, writeFileSync } from 'node:fs';
2+
import path from 'node:path';
3+
4+
const installDir = path.resolve('home/.vite-plus');
5+
mkdirSync(installDir, { recursive: true });
6+
7+
// Reuse the runner's managed runtime in the installation under the parent workspace.
8+
const runtime = path.join(process.env.VP_HOME, 'js_runtime');
9+
if (existsSync(runtime)) {
10+
symlinkSync(realpathSync(runtime), path.join(installDir, 'js_runtime'), 'junction');
11+
}
12+
13+
if (process.argv.includes('--valid-lockfile')) {
14+
writeFileSync('home/apps-ts/kami/package.json', '{"name":"kami","private":true}\n');
15+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[[case]]
2+
name = "command_upgrade_parent_workspace_stale_lockfile"
3+
vp = "global"
4+
skip-platforms = ["windows"]
5+
comment = "Regression test for #2639: an upgrade invoked outside a parent pnpm workspace must not read its stale lockfile."
6+
steps = [
7+
{ argv = ["node", "setup.mjs"], snapshot = false },
8+
# Pin the released payload so the test also runs when the checkout version is unpublished.
9+
{ argv = ["vp", "upgrade", "0.3.1", "--force"], envs = [["VP_HOME", "${workspace}/home/.vite-plus"]], timeout = 120000, snapshot = false },
10+
{ argv = ["vpt", "stat-file", "home/.vite-plus/current/node_modules/vite-plus/package.json", "--assert", "file"] },
11+
{ argv = ["vpt", "stat-file", "home/node_modules", "home/apps-ts/kami/node_modules", "--assert", "missing"] },
12+
{ argv = ["vpt", "print-file", "home/pnpm-lock.yaml"], comment = "The parent workspace lockfile is unchanged." },
13+
]
14+
15+
[[case]]
16+
name = "command_upgrade_parent_workspace_valid_lockfile"
17+
vp = "global"
18+
skip-platforms = ["windows"]
19+
comment = "An upgrade must install its own dependencies even when the parent workspace lockfile is valid."
20+
steps = [
21+
{ argv = ["node", "setup.mjs", "--valid-lockfile"], snapshot = false },
22+
{ argv = ["vp", "upgrade", "0.3.1", "--force"], envs = [["VP_HOME", "${workspace}/home/.vite-plus"]], timeout = 120000, snapshot = false },
23+
{ argv = ["vpt", "stat-file", "home/.vite-plus/current/node_modules/vite-plus/package.json", "--assert", "file"] },
24+
{ argv = ["vpt", "stat-file", "home/node_modules", "home/apps-ts/kami/node_modules", "--assert", "missing"] },
25+
{ argv = ["vpt", "print-file", "home/pnpm-lock.yaml"], comment = "The parent workspace lockfile is unchanged." },
26+
]
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# command_upgrade_parent_workspace_stale_lockfile
2+
3+
Regression test for #2639: an upgrade invoked outside a parent pnpm workspace must not read its stale lockfile.
4+
5+
## `node setup.mjs`
6+
7+
8+
## `VP_HOME=${workspace}/home/.vite-plus vp upgrade 0.3.1 --force`
9+
10+
11+
## `vpt stat-file home/.vite-plus/current/node_modules/vite-plus/package.json --assert file`
12+
13+
```
14+
home/.vite-plus/current/node_modules/vite-plus/package.json: file
15+
```
16+
17+
## `vpt stat-file home/node_modules home/apps-ts/kami/node_modules --assert missing`
18+
19+
```
20+
home/node_modules: missing
21+
home/apps-ts/kami/node_modules: missing
22+
```
23+
24+
## `vpt print-file home/pnpm-lock.yaml`
25+
26+
The parent workspace lockfile is unchanged.
27+
28+
```
29+
lockfileVersion: '9.0'
30+
31+
settings:
32+
autoInstallPeers: true
33+
excludeLinksFromLockfile: false
34+
35+
importers:
36+
.:
37+
dependencies:
38+
kami:
39+
specifier: workspace:*
40+
version: link:apps-ts/kami
41+
apps-ts/kami: {}
42+
```
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# command_upgrade_parent_workspace_valid_lockfile
2+
3+
An upgrade must install its own dependencies even when the parent workspace lockfile is valid.
4+
5+
## `node setup.mjs --valid-lockfile`
6+
7+
8+
## `VP_HOME=${workspace}/home/.vite-plus vp upgrade 0.3.1 --force`
9+
10+
11+
## `vpt stat-file home/.vite-plus/current/node_modules/vite-plus/package.json --assert file`
12+
13+
```
14+
home/.vite-plus/current/node_modules/vite-plus/package.json: file
15+
```
16+
17+
## `vpt stat-file home/node_modules home/apps-ts/kami/node_modules --assert missing`
18+
19+
```
20+
home/node_modules: missing
21+
home/apps-ts/kami/node_modules: missing
22+
```
23+
24+
## `vpt print-file home/pnpm-lock.yaml`
25+
26+
The parent workspace lockfile is unchanged.
27+
28+
```
29+
lockfileVersion: '9.0'
30+
31+
settings:
32+
autoInstallPeers: true
33+
excludeLinksFromLockfile: false
34+
35+
importers:
36+
.:
37+
dependencies:
38+
kami:
39+
specifier: workspace:*
40+
version: link:apps-ts/kami
41+
apps-ts/kami: {}
42+
```

0 commit comments

Comments
 (0)