From 6cc417bb42fd526d7dd3c142f4264c0fa8c5ab09 Mon Sep 17 00:00:00 2001 From: Mark Wubben Date: Tue, 27 Jun 2023 21:32:26 +0200 Subject: [PATCH] Set up CI to test the new watcher * Run tests on macOS * Use Bash shell * Run watch mode test separately and serially --- .github/workflows/ci.yml | 8 +++++--- ava.config.js | 6 +++++- package.json | 3 +-- scripts/ci.sh | 9 +++++++++ scripts/test.sh | 8 ++++++++ 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100755 scripts/ci.sh create mode 100755 scripts/test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a3612a32..3d7654762 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: fail-fast: false matrix: node-version: [^16.18, ^18.16, ^20.3] - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v3 - name: Enable symlinks @@ -29,7 +29,8 @@ jobs: node-version: ${{ matrix.node-version }} cache: npm - run: npm install --no-audit - - run: npm run cover + - run: ./scripts/ci.sh + shell: bash - uses: codecov/codecov-action@v3 with: files: coverage/lcov.info @@ -83,7 +84,8 @@ jobs: with: node-version-file: package.json - run: npm install --no-package-lock --no-audit - - run: npm run cover + - run: ./scripts/ci.sh + shell: bash xo: name: Lint source files diff --git a/ava.config.js b/ava.config.js index 57992596c..559513382 100644 --- a/ava.config.js +++ b/ava.config.js @@ -1,5 +1,9 @@ +import process from 'node:process'; + +const skipWatchMode = process.env.TEST_AVA_SKIP_WATCH_MODE ? ['!test/watch-mode/**'] : []; + export default { // eslint-disable-line import/no-anonymous-default-export - files: ['test/**', '!test/**/{fixtures,helpers}/**'], + files: ['test/**', '!test/**/{fixtures,helpers}/**', ...skipWatchMode], ignoredByWatcher: ['{coverage,docs,media,test-types,test-tap}/**'], environmentVariables: { AVA_FAKE_SCM_ROOT: '.fake-root', // This is an internal test flag. diff --git a/package.json b/package.json index 9caa52a58..ad3fa2e9b 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,7 @@ "node": "^16.18 || ^18.16 || ^20.3" }, "scripts": { - "cover": "c8 --report=none test-ava && c8 --report=none --no-clean tap && c8 report", - "test": "xo && tsc --noEmit && npm run -s cover" + "test": "./scripts/test.sh" }, "files": [ "entrypoints", diff --git a/scripts/ci.sh b/scripts/ci.sh new file mode 100755 index 000000000..390570328 --- /dev/null +++ b/scripts/ci.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -ex + +TEST_AVA_SKIP_WATCH_MODE=1 npx c8 --report=none npx test-ava +# Reduce concurrency and be generous with timeouts to give watch mode tests a +# better chance of succeeding in a CI environment. +npx c8 --report=none --no-clean npx test-ava --serial --timeout 30s test/watch-mode +npx c8 --report=none --no-clean npx tap +npx c8 report diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 000000000..ccc8bd9ab --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -ex + +npx xo +npx tsc --noEmit +npx c8 --report=none npx test-ava +npx c8 --report=none --no-clean npx tap +npx c8 report