use our tools #3911
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
workflow_dispatch: | |
concurrency: | |
group: branch-node--test--${{ github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
# Test node 14/16/18/20 on ubuntu | |
# Test node 20 on macos/windows | |
# Enable annotations only for node 20 + ubuntu | |
matrix: | |
os: [ubuntu-latest] | |
node: [16, 18, 20] | |
include: | |
- os: macos-latest | |
node: 20 | |
- os: windows-latest | |
node: 20 | |
- os: ubuntu-latest | |
is_base_os_version: true | |
- node: 20 | |
is_base_node_version: true | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 1 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: npm ci | |
run: | | |
npm ci --ignore-scripts | |
- name: determine modified workspaces | |
run: | | |
echo "MODIFIED_WORKSPACES=$(node './.github/bin/modified-workspaces/log-modified-workspaces.mjs')" >> $GITHUB_ENV | |
env: | |
GITHUB_ACTION_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Build and PostCSS Tape tests must all work and pass : | |
# - with exact dependencies from package-lock.json | |
# - without requiring postinstall scripts from dependencies to run | |
- name: build | |
run: | | |
npm run build --if-present $MODIFIED_WORKSPACES | |
if: matrix.is_base_node_version && matrix.is_base_os_version | |
- name: docs | |
run: npm run docs | |
if: matrix.is_base_node_version && matrix.is_base_os_version | |
- name: repo is clean after "build", "lint" and "docs" steps | |
run: | | |
git diff --quiet --exit-code | |
# Basic tests | |
- name: test | |
run: npm run test --if-present $MODIFIED_WORKSPACES | |
env: | |
ENABLE_ANNOTATIONS_FOR_NODE: ${{ matrix.is_base_node_version }} | |
ENABLE_ANNOTATIONS_FOR_OS: ${{ matrix.is_base_os_version }} | |
# CLI Tests | |
# running "npm install" places the cli in node_modules/bin | |
- name: test:cli | |
run: | | |
npm install --ignore-scripts | |
npm run test:cli --if-present $MODIFIED_WORKSPACES | |
# Browser Tests | |
# running "npm ci" again, but allowing scripts so that Chrome is installed | |
- name: test:browser | |
run: | | |
npm ci | |
npm run test:browser --if-present $MODIFIED_WORKSPACES | |
if: matrix.is_base_node_version && matrix.is_base_os_version | |
# E2E Tests | |
- name: test:e2e | |
run: | | |
cd e2e | |
npm install | |
npm run build | |
npm run test | |
if: matrix.is_base_node_version && matrix.is_base_os_version |