diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86f2825..2637e83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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/ @@ -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/ @@ -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 diff --git a/package.json b/package.json index a1cb01e..556f759 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/smoke.mjs b/test/smoke.mjs new file mode 100644 index 0000000..0e40135 --- /dev/null +++ b/test/smoke.mjs @@ -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}`);