Skip to content

Commit 33ccf12

Browse files
committed
ci: add pkg.pr.new preview workflow
1 parent fa34016 commit 33ccf12

4 files changed

Lines changed: 112 additions & 1 deletion

File tree

.github/workflows/pkg-pr-new.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish to pkg.pr.new
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/pkg-pr-new.yml"
7+
- "package.json"
8+
- "pnpm-lock.yaml"
9+
- "pnpm-workspace.yaml"
10+
- "packages/secure-exec/**"
11+
push:
12+
branches:
13+
- main
14+
paths:
15+
- ".github/workflows/pkg-pr-new.yml"
16+
- "package.json"
17+
- "pnpm-lock.yaml"
18+
- "pnpm-workspace.yaml"
19+
- "packages/secure-exec/**"
20+
21+
concurrency:
22+
group: pkg-pr-new-${{ github.event.pull_request.number || github.ref }}
23+
cancel-in-progress: true
24+
25+
jobs:
26+
publish:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: read
30+
pull-requests: write
31+
steps:
32+
- name: Checkout repository
33+
uses: actions/checkout@v4
34+
35+
- name: Enable Corepack
36+
run: corepack enable
37+
38+
- name: Set up Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: "22"
42+
cache: pnpm
43+
cache-dependency-path: pnpm-lock.yaml
44+
45+
- name: Install dependencies
46+
run: pnpm install --frozen-lockfile
47+
48+
- name: Build package
49+
run: pnpm --filter secure-exec build
50+
51+
- name: Publish to pkg.pr.new
52+
run: pnpm dlx pkg-pr-new publish "./packages/secure-exec" --packageManager pnpm

packages/secure-exec/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
"type": "module",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",
7+
"files": [
8+
"dist"
9+
],
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/rivet-dev/secure-exec.git",
13+
"directory": "packages/secure-exec"
14+
},
715
"exports": {
816
".": {
917
"import": "./dist/index.js",
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { readFile } from "node:fs/promises";
2+
import path from "node:path";
3+
import { fileURLToPath } from "node:url";
4+
import { describe, expect, it } from "vitest";
5+
6+
const TESTS_ROOT = path.dirname(fileURLToPath(import.meta.url));
7+
const PACKAGE_ROOT = path.resolve(TESTS_ROOT, "..");
8+
const WORKSPACE_ROOT = path.resolve(PACKAGE_ROOT, "..", "..");
9+
const WORKFLOW_PATH = path.join(
10+
WORKSPACE_ROOT,
11+
".github",
12+
"workflows",
13+
"pkg-pr-new.yml",
14+
);
15+
const PACKAGE_MANIFEST_PATH = path.join(PACKAGE_ROOT, "package.json");
16+
17+
describe("pkg.pr.new publish policy", () => {
18+
it("publishes only the secure-exec package preview", async () => {
19+
const workflowSource = await readFile(WORKFLOW_PATH, "utf8");
20+
21+
expect(workflowSource).toContain("name: Publish to pkg.pr.new");
22+
expect(workflowSource).toContain(
23+
'pnpm dlx pkg-pr-new publish "./packages/secure-exec" --packageManager pnpm',
24+
);
25+
expect(workflowSource).not.toContain("'packages/*'");
26+
expect(workflowSource).not.toContain("'./packages/**/*'");
27+
expect(workflowSource).not.toContain("--template");
28+
});
29+
30+
it("packages only built artifacts for preview publishing", async () => {
31+
const packageManifest = JSON.parse(
32+
await readFile(PACKAGE_MANIFEST_PATH, "utf8"),
33+
) as {
34+
files?: string[];
35+
repository?: {
36+
type?: string;
37+
url?: string;
38+
directory?: string;
39+
};
40+
};
41+
42+
expect(packageManifest.files).toEqual(["dist"]);
43+
expect(packageManifest.repository).toEqual({
44+
type: "git",
45+
url: "https://github.com/rivet-dev/secure-exec.git",
46+
directory: "packages/secure-exec",
47+
});
48+
});
49+
});

packages/secure-exec/tests/runtime-driver/node/runtime.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ describe("runtime driver specific: node", () => {
5757
it("accepts Node-only exec options", async () => {
5858
const runtime = createRuntime();
5959
const result = await runtime.exec(`console.log("node-exec-options-ok");`, {
60-
cpuTimeLimitMs: 50,
60+
// Keep the limit low enough to exercise the node-only option path
61+
// without coupling the test to machine-specific startup jitter.
62+
cpuTimeLimitMs: 250,
6163
timingMitigation: "off",
6264
});
6365
expect(result.code).toBe(0);

0 commit comments

Comments
 (0)