build: run tests using actual build (#23)
* build: run tests using actual build * build: build script that includes hashbang prepending * ci: missing /bin/zsh
This commit is contained in:
parent
540ce0bbbb
commit
ec2e46e04d
9 changed files with 54 additions and 12 deletions
8
.github/workflows/nodejs.yml
vendored
8
.github/workflows/nodejs.yml
vendored
|
@ -44,11 +44,13 @@ jobs:
|
||||||
key: ${{ runner.os }}-build-${{env.cache-name}}-${{ hashFiles('**/yarn.lock') }}-node-${{ matrix.node-version }}
|
key: ${{ runner.os }}-build-${{env.cache-name}}-${{ hashFiles('**/yarn.lock') }}-node-${{ matrix.node-version }}
|
||||||
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
|
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
|
||||||
run: corepack enable && yarn
|
run: corepack enable && yarn
|
||||||
|
|
||||||
integration:
|
integration:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: dependencies
|
needs: dependencies
|
||||||
name: Integration tests
|
name: Integration tests
|
||||||
|
env:
|
||||||
|
SHELL: /usr/bin/bash
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [16, 18]
|
node-version: [16, 18]
|
||||||
|
@ -95,6 +97,8 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [16, 18]
|
node-version: [16, 18]
|
||||||
|
|
||||||
|
env:
|
||||||
|
SHELL: /usr/bin/bash
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
@ -115,6 +119,8 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: dependencies
|
needs: dependencies
|
||||||
|
env:
|
||||||
|
SHELL: /usr/bin/bash
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
node-version: [16, 18]
|
node-version: [16, 18]
|
||||||
|
|
|
@ -16,9 +16,10 @@
|
||||||
"prebuild": "rm -rf dist",
|
"prebuild": "rm -rf dist",
|
||||||
"lint": "rome format src tests && rome check src tests",
|
"lint": "rome format src tests && rome check src tests",
|
||||||
"lint:fix": "rome format src tests --write && rome check src tests --apply",
|
"lint:fix": "rome format src tests --write && rome check src tests --apply",
|
||||||
"test": "ts-node ./src/cli.ts ./tests",
|
"test": "$SHELL ./script/test-suite",
|
||||||
"test:integration": "/usr/bin/bash ./script/integration-tests",
|
"test:integration": "$SHELL ./script/integration-tests",
|
||||||
"build": "tsc --project ."
|
"build:ts": "tsc --project .",
|
||||||
|
"build": "$SHELL ./script/build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.15.10",
|
"@types/node": "^18.15.10",
|
||||||
|
|
18
script/build
Normal file
18
script/build
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
yarn build:ts
|
||||||
|
|
||||||
|
# Certain files need hashbangs as they are executables.
|
||||||
|
|
||||||
|
NODE_HASHBANG="#!/usr/bin/env node"
|
||||||
|
|
||||||
|
addHashbang() {
|
||||||
|
echo $1
|
||||||
|
echo $NODE_HASHBANG > $1_prefixed
|
||||||
|
cat $1 >> $1_prefixed
|
||||||
|
mv $1_prefixed $1
|
||||||
|
}
|
||||||
|
|
||||||
|
addHashbang dist/cli.js
|
||||||
|
addHashbang dist/collector.js
|
||||||
|
addHashbang dist/worker.js
|
23
script/test-suite
Normal file
23
script/test-suite
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
#
|
||||||
|
# Tests are executed using a built version of the runner.
|
||||||
|
#
|
||||||
|
# This will first build the package, install it in a temporary
|
||||||
|
# environment and run the test suite with it.
|
||||||
|
#
|
||||||
|
|
||||||
|
yarn pack --out integration-build.tgz
|
||||||
|
|
||||||
|
mkdir .tests
|
||||||
|
|
||||||
|
echo "{}" > .tests/package.json
|
||||||
|
touch .tests/yarn.lock
|
||||||
|
|
||||||
|
(
|
||||||
|
cd .tests
|
||||||
|
yarn add ../integration-build.tgz ts-node
|
||||||
|
yarn womm ../tests --ts --workers=2
|
||||||
|
)
|
||||||
|
|
||||||
|
rm -rf .tests
|
|
@ -1,5 +1,3 @@
|
||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
import helpText from './help'
|
import helpText from './help'
|
||||||
import parseArgs from './argumentParser'
|
import parseArgs from './argumentParser'
|
||||||
import { getContext, redText, assertTsNodeInstall } from './utils'
|
import { getContext, redText, assertTsNodeInstall } from './utils'
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#!/usr/bin/env ts-node
|
|
||||||
|
|
||||||
import { type Context } from './types'
|
import { type Context } from './types'
|
||||||
import { getContext, spawnProcess } from './utils'
|
import { getContext, spawnProcess } from './utils'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#!/usr/bin/env ts-node
|
|
||||||
|
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
import { getContext, spawnProcess } from './utils'
|
import { getContext, spawnProcess } from './utils'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
import { describe, test, expect } from '../src'
|
import { describe, test, expect } from 'works-on-my-machine'
|
||||||
|
|
||||||
describe('Equality', () => {
|
describe('Equality', () => {
|
||||||
test.each([1, 'expectations', true])('Equality (value=%s)', (value: unknown) => {
|
test.each([1, 'expectations', true])('Equality (value=%s)', (value: unknown) => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import assert from 'assert'
|
import assert from 'assert'
|
||||||
|
|
||||||
import { it, test, expect, describe } from '../src'
|
import { it, test, expect, describe } from 'works-on-my-machine'
|
||||||
|
|
||||||
describe.each([it, test])('Runs tests', (fn: unknown) => {
|
describe.each([it, test])('Runs tests', (fn: unknown) => {
|
||||||
const testFn = fn as typeof test
|
const testFn = fn as typeof test
|
||||||
|
|
Reference in a new issue