fix: support duplicate installations (#50) #163
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: CI | |
on: | |
push: | |
branches: [ master, beta ] | |
pull_request: | |
branches: [ master, beta ] | |
workflow_dispatch: | |
inputs: | |
os: | |
description: 'Operating System' | |
required: true | |
default: 'ubuntu-latest' | |
jobs: | |
sanity: | |
name: Standard Testing | |
runs-on: ${{ github.event.inputs.os || 'ubuntu-latest' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: '.nvmrc' | |
- uses: bahmutov/npm-install@v1 | |
with: | |
useLockFile: false | |
- name: Lint | |
run: npm run lint:ci | |
- name: Unit and Integration | |
run: npm test | |
- name: Build package for E2E | |
run: npm run build:e2e | |
- uses: bahmutov/npm-install@v1 | |
with: | |
useLockFile: false | |
working-directory: e2e | |
- name: Record fixtures | |
run: npm run build | |
working-directory: e2e | |
- name: Assert no Git changes | |
run: git diff --exit-code e2e/__fixtures__ | |
- name: Upload artifacts | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts-os-${{ matrix.os }} | |
path: artifacts/ | |
compatibility: | |
name: Compatibility Testing | |
needs: sanity | |
if: github.event_name != 'workflow_dispatch' | |
strategy: | |
matrix: | |
jest: | |
- '27.x.x' | |
- '28.x.x' | |
runs-on: ${{ github.event.inputs.os || 'ubuntu-latest' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: '.nvmrc' | |
- uses: bahmutov/npm-install@v1 | |
with: | |
useLockFile: false | |
- name: Build package for E2E | |
run: npm run build:e2e | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: 'e2e/.nvmrc' | |
- name: Update fixtures | |
run: npm run update-fixtures | |
env: | |
JEST_VERSION: ${{ matrix.jest }} | |
- name: Assert no Git changes | |
run: git diff --exit-code e2e/__fixtures__ | |
- name: Upload artifacts | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: artifacts-jest-${{ matrix.jest }} | |
path: artifacts/ | |
coverage: | |
name: Coverage Report | |
needs: [sanity, compatibility] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout (default) | |
if: github.event_name != 'pull_request' | |
uses: actions/checkout@v3 | |
- name: Checkout (pull request) | |
if: github.event_name == 'pull_request' | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Install dependencies | |
run: npm -g install "[email protected]" "[email protected]" | |
- name: Merge coverage reports | |
run: lcov-result-merger 'artifacts/**/lcov.info' 'artifacts/lcov.info' | |
- name: Upload coverage report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage | |
path: artifacts/lcov.info | |
- name: Generate coverage badge | |
run: lcov-badge2 -o docs/images/coverage.svg artifacts/lcov.info | |
- name: Commit and Push | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: docs/images/coverage.svg | |
message: 'chore: update coverage badge' | |
publish: | |
name: Publish | |
needs: [sanity, compatibility] | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: '.nvmrc' | |
- uses: bahmutov/npm-install@v1 | |
with: | |
useLockFile: false | |
- name: Semantic release | |
run: npx --no-install semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |