Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
node-version: 22
- run: npm ci --ignore-scripts
- run: npm run build
- uses: actions/upload-artifact@v7
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: dist
path: dist/
Expand All @@ -34,7 +34,7 @@ jobs:
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: latest
- uses: actions/download-artifact@v8
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
Expand All @@ -59,13 +59,37 @@ jobs:
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@v8
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
- run: npm ci --ignore-scripts
- run: npm run test:unit

smoke:
name: Smoke test on Node.js ${{ matrix.node-version }} @ ${{ matrix.os }}
needs: build
strategy:
fail-fast: false
matrix:
node-version:
- 18.0.0
- 18.x
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: dist
path: dist/
# No `npm ci` on purpose: this must only use the built code & builtins
- run: npm run test:smoke

bun-build:
name: Build on Bun (latest) @ ubuntu-latest
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"lint": "tsc --noEmit && eslint src && publint",
"prepare": "npm run build",
"test": "npm run build && npm run test:unit",
"test:unit": "vitest run"
"test:unit": "vitest run",
"test:smoke": "node test/smoke.mjs"
},
"repository": {
"type": "git",
Expand Down
23 changes: 23 additions & 0 deletions test/smoke.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import assert from 'node:assert/strict';
import {execPath as node} from 'node:process';
import {x, xSync, NonZeroExitError} from '../dist/main.mjs';

const result = await x(node, ['-e', 'process.stdout.write("hello")']);
assert.equal(result.stdout, 'hello');
assert.equal(result.exitCode, 0);

const lines = [];
for await (const line of x(node, ['-e', 'console.log("a"); console.log("b")'])) {
lines.push(line);
}
assert.deepEqual(lines, ['a', 'b']);

await assert.rejects(async () => {
await x(node, ['-e', 'process.exit(3)'], {throwOnError: true});
}, NonZeroExitError);

const syncResult = xSync(node, ['-e', 'process.stdout.write("hello")']);
assert.equal(syncResult.stdout, 'hello');
assert.equal(syncResult.exitCode, 0);

console.log(`smoke test passed on Node.js ${process.version}`);