@cnc-tools/storm 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-info.js +1 -1
- package/dist/commands/exec/command.d.ts +32 -0
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/outcomes.d.ts +67 -0
- package/dist/commands/exec/outcomes.js +50 -0
- package/dist/commands/exec/run-command.d.ts +17 -11
- package/dist/commands/exec/run-command.js +33 -16
- package/dist/commands/runs/facts.d.ts +2 -2
- package/dist/commands/runs/facts.js +1 -1
- package/dist/commands/runs/list/outcomes.js +1 -1
- package/dist/commands/runs/logs/outcomes.js +1 -1
- package/dist/commands/runs/show/outcomes.js +3 -3
- package/dist/commands/vitest/command.d.ts +32 -0
- package/dist/commands/vitest/outcomes.d.ts +16 -0
- package/dist/core/run.d.ts +6 -1
- package/dist/core/run.js +1 -1
- package/dist/resources/testserver/commands/create/command.d.ts +6 -4
- package/dist/resources/testserver/commands/create/command.js +15 -6
- package/dist/resources/testserver/events.d.ts +4 -2
- package/dist/resources/testserver/pool/create.d.ts +4 -1
- package/dist/resources/testserver/pool/create.js +3 -1
- package/dist/resources/testserver/pool/gateways.d.ts +6 -0
- package/dist/resources/testserver/pool/live/pool-records.js +6 -2
- package/dist/resources/testserver/pool/pull-request.d.ts +18 -11
- package/dist/resources/testserver/pool/pull-request.js +43 -10
- package/dist/resources/testserver/presentation.js +2 -1
- package/dist/resources/testserver/provider.js +15 -7
- package/dist/runner/index.d.ts +2 -1
- package/dist/runner/index.js +1 -0
- package/dist/runner/prepare.d.ts +7 -6
- package/dist/runner/prepare.js +1 -1
- package/dist/runner/ready.d.ts +6 -0
- package/dist/runner/ready.js +33 -5
- package/dist/runner/recipe.d.ts +33 -6
- package/dist/runner/recipe.js +150 -22
- package/dist/runner/secrets.d.ts +42 -0
- package/dist/runner/secrets.js +44 -0
- package/dist/runner/snapshot-build.d.ts +5 -2
- package/dist/runner/snapshot-build.js +12 -5
- package/dist/runner/snapshot-cache.d.ts +3 -3
- package/dist/runner/snapshot-cache.js +2 -2
- package/dist/runner/snapshot-key.d.ts +19 -12
- package/dist/runner/snapshot-key.js +25 -16
- package/dist/runner/snapshot-save.d.ts +5 -3
- package/dist/runner/snapshot-save.js +7 -5
- package/dist/runner/steps.d.ts +6 -1
- package/dist/runner/steps.js +5 -2
- package/package.json +2 -3
- package/skills/overview.md +1 -0
- package/skills/testserver-builds.md +4 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Saving a runner run's runner sandbox as a branch snapshot once its command ended (`--save-snapshot`): reset the
|
|
2
2
|
// working tree to its base and empty the temp directories, save the sandbox as a runner snapshot, and record it in the
|
|
3
|
-
// cache for the run's branch in its checkout. The snapshot keeps the rest of what the command
|
|
4
|
-
// wrote included.
|
|
3
|
+
// cache for the run's branch in its checkout. The snapshot keeps the rest of what the command and the recipe's steps
|
|
4
|
+
// left, a resource's token or a runner secret they wrote included.
|
|
5
5
|
import { lineSplitter, outputTail, splitLines } from "./output.js";
|
|
6
6
|
import { SNAPSHOT_EXPIRATION_MS } from "./snapshot-cache.js";
|
|
7
7
|
import { REMOTE_ROOT, RESET_TO_BASE } from "./snapshot-key.js";
|
|
@@ -50,9 +50,11 @@ export function scrubTempScript(directories = TEMP_DIRECTORIES) {
|
|
|
50
50
|
* branch's entry in that checkout at that base; the snapshot it replaces is left to expire, since a run on this
|
|
51
51
|
* machine may be starting from it. Nothing here changes the run's outcome: each way it ends is a note.
|
|
52
52
|
*
|
|
53
|
-
* It searches nothing for the run's secrets: the snapshot keeps what the command
|
|
54
|
-
*
|
|
55
|
-
*
|
|
53
|
+
* It searches nothing for the run's secrets: the snapshot keeps what the command and the recipe's steps wrote to
|
|
54
|
+
* `$HOME`, the ignored files and `.git`, as a kept runner sandbox does. A resource's token is limited to one test
|
|
55
|
+
* resource. A runner secret a step that got it left behind is not: the recipe must not leave one, since later steps
|
|
56
|
+
* and commands on the snapshot can read it (`README.md`). Only a later run on the branch from this checkout starts
|
|
57
|
+
* from the snapshot.
|
|
56
58
|
*/
|
|
57
59
|
export async function saveBranchSnapshot(context, request, control, progress) {
|
|
58
60
|
const save = await saveOnce(context, request, control, progress);
|
package/dist/runner/steps.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Clock } from "../time/index.ts";
|
|
2
2
|
import { type RunnerFailure, type RunnerProgress, type RunnerSandboxCall, type RunnerStage, type RunnerStepPhase } from "./events.ts";
|
|
3
3
|
import type { RunnerSandbox, RunnerSandboxFailure, RunnerSandboxGateway, RunnerStartFailure } from "./gateways.ts";
|
|
4
|
+
import type { RunnerSecrets } from "./secrets.ts";
|
|
4
5
|
/** Every step's environment: no Git hook, prompt or update check gets in the way. */
|
|
5
6
|
export declare const STEP_ENV: Readonly<Record<string, string>>;
|
|
6
7
|
/**
|
|
@@ -21,7 +22,10 @@ export type StepOutcome = {
|
|
|
21
22
|
readonly kind: "sandbox-failed";
|
|
22
23
|
readonly failure: RunnerSandboxFailure;
|
|
23
24
|
};
|
|
24
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Runs `script` in `sandbox` as a step labeled `label`, reporting it under `phase`. Its environment is `STEP_ENV` and
|
|
27
|
+
* `secrets`: for a recipe's step, the runner secrets that step names; storm's own steps pass none.
|
|
28
|
+
*/
|
|
25
29
|
export declare function runStep(context: {
|
|
26
30
|
readonly runnerSandboxes: RunnerSandboxGateway;
|
|
27
31
|
readonly clock: Clock;
|
|
@@ -30,6 +34,7 @@ export declare function runStep(context: {
|
|
|
30
34
|
readonly phase: RunnerStepPhase;
|
|
31
35
|
readonly label: string;
|
|
32
36
|
readonly script: string;
|
|
37
|
+
readonly secrets?: RunnerSecrets;
|
|
33
38
|
}, progress: RunnerProgress, signal: AbortSignal): Promise<StepOutcome>;
|
|
34
39
|
/** A Sandbox failure other than an abort, as the runner reports it. */
|
|
35
40
|
export declare function sandboxApiFailure(operation: RunnerSandboxCall, failure: Exclude<RunnerStartFailure, {
|
package/dist/runner/steps.js
CHANGED
|
@@ -9,7 +9,10 @@ export const STEP_ENV = {
|
|
|
9
9
|
COREPACK_ENABLE_STRICT: "0",
|
|
10
10
|
npm_config_update_notifier: "false",
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Runs `script` in `sandbox` as a step labeled `label`, reporting it under `phase`. Its environment is `STEP_ENV` and
|
|
14
|
+
* `secrets`: for a recipe's step, the runner secrets that step names; storm's own steps pass none.
|
|
15
|
+
*/
|
|
13
16
|
export async function runStep(context, request, progress, signal) {
|
|
14
17
|
const { phase, label } = request;
|
|
15
18
|
const startedAt = context.clock.now().getTime();
|
|
@@ -23,7 +26,7 @@ export async function runStep(context, request, progress, signal) {
|
|
|
23
26
|
queue.add({ kind: "step-output", phase, stream, line });
|
|
24
27
|
}
|
|
25
28
|
};
|
|
26
|
-
const ran = await context.runnerSandboxes.runScript(request.sandbox, { script: request.script, env: STEP_ENV }, ({ stream, data }) => emit(stream, splitters[stream].push(data)), signal);
|
|
29
|
+
const ran = await context.runnerSandboxes.runScript(request.sandbox, { script: request.script, env: { ...STEP_ENV, ...request.secrets } }, ({ stream, data }) => emit(stream, splitters[stream].push(data)), signal);
|
|
27
30
|
emit("stdout", splitters.stdout.flush());
|
|
28
31
|
emit("stderr", splitters.stderr.flush());
|
|
29
32
|
await queue.flush();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cnc-tools/storm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Run a command against Vercel Testserver sandboxes",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -90,8 +90,7 @@
|
|
|
90
90
|
"registry": "https://registry.npmjs.org/"
|
|
91
91
|
},
|
|
92
92
|
"dependencies": {
|
|
93
|
-
"@
|
|
94
|
-
"@vercel/clinkr": "npm:clinkr@^0.9.1",
|
|
93
|
+
"@vercel/clinkr": "npm:clinkr@^0.10.0",
|
|
95
94
|
"@vercel/sandbox": "3.9.0",
|
|
96
95
|
"zod": "^4.6.5"
|
|
97
96
|
},
|
package/skills/overview.md
CHANGED
|
@@ -19,6 +19,7 @@ commands: all
|
|
|
19
19
|
- A run is **active** while it goes on. A run is **finished** when it has ended and saved its test results. `runs show` shows test results only for a finished run.
|
|
20
20
|
- A **test result** is the final result of one test: `pass`, `fail` or `skip`, with its errors. The command saves test results only with the Vitest adapter's `stormReporter`.
|
|
21
21
|
- **Test output** is what one test printed to the console, stdout and stderr together. storm keeps the last 8 MiB of the test output of each test. `droppedChars` counts the characters that storm did not keep.
|
|
22
|
+
- A **runner secret** is a variable in your environment that the `secrets` key of the runner recipe declares, such as an npm token for a private package. A runner run reads it on the machine that starts the run. The run does not start when the variable is not set, is empty, holds a line break or has fewer than 8 characters. A step of the recipe gets the variable only when the `secrets` key of that step names it. The command does not get it. storm shows the value as `<token>` in all that it prints and writes. storm does not write the value to a file. A step can leave the value in the sandbox, and a runner snapshot then keeps it. Do not let a step leave the value.
|
|
22
23
|
- A **run log** is a log in the run directory. The **command log** (`command`) holds all the output of the command. It also holds output that no test owns: output from a `beforeAll`, a global setup, a raw `process.stdout.write`, or a child process. A **step log** (`install`, `build`, `apply`, `snapshot`) holds the output of one step of a runner run.
|
|
23
24
|
|
|
24
25
|
## Commands
|
|
@@ -18,9 +18,9 @@ Use this skill to choose the Testserver build of a run. Use it also when a chang
|
|
|
18
18
|
- The **head commit** of a pull request is the newest commit on its branch, such as `87343a6781b4f540893958e49e8eedaf5bb2b4ad`. Each PR build comes from the workflow run for one head commit.
|
|
19
19
|
- A **PR build reference** gives a vercel/api pull request as the build. Write it as `pr:<N>`, such as `pr:104196`, or as the URL of the pull request, such as `https://github.com/vercel/api/pull/104196`. storm changes the URL to `pr:<N>`.
|
|
20
20
|
|
|
21
|
-
A run with `pr:<N>` uses
|
|
21
|
+
A run with `pr:<N>` uses a PR build of the head commit of the pull request. If no PR build of that head commit exists, the run stops. It does not wait, and it does not use a PR build of an older head commit.
|
|
22
22
|
|
|
23
|
-
storm reads the head commit
|
|
23
|
+
storm reads the head commit from GitHub on this machine. If the pool has a Testserver sandbox that was made for `pr:<N>` on the head commit, storm uses the PR build of the newest such Testserver sandbox. It does this only if that PR build has not expired. Then storm reads only the head commit from GitHub. If the workflow ran again on the same head commit, storm can use an older PR build of that head commit from the pool. If the pool has no usable PR build, storm reads the runs of the `Testserver` workflow and uses the newest PR build of the head commit. storm uses the first GitHub token that it finds: `GITHUB_TOKEN`, `GH_TOKEN`, or the output of `gh auth token`. The token must be able to read vercel/api and its Actions. The token stays on this machine.
|
|
24
24
|
|
|
25
25
|
## Choose a build
|
|
26
26
|
|
|
@@ -48,6 +48,8 @@ To make one Testserver sandbox on the PR build, run `storm pool create --build p
|
|
|
48
48
|
|
|
49
49
|
With `--testserver-no-create`, a run with `pr:<N>` uses only the Testserver sandboxes in the pool on that PR build. It does not make new ones.
|
|
50
50
|
|
|
51
|
+
To make runs more reliable, for example before a demo, make the Testserver sandboxes first. Run `storm pool create --build pr:<N> --json` one time for each Testserver sandbox. Then a run with `pr:<N>` reads only the head commit from GitHub. Its line `Build: …` ends with `(from the pool)`. A Testserver sandbox lives for its TTL, 5 hours or less. After a new push to the pull request, the runs do not use these Testserver sandboxes.
|
|
52
|
+
|
|
51
53
|
## If a run stops
|
|
52
54
|
|
|
53
55
|
Read `reason` in the error document. Read the facts of the error in `data`.
|