Consolidate CI workflows #34
Workflow file for this run
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: | |
pull_request: | |
branches: [ main, prod-beta, prod-stable, stage-beta, stage-stable ] | |
push: | |
branches: [ main, prod-beta, prod-stable, stage-beta, stage-stable ] | |
env: | |
BRANCH: ${{ github.base_ref }} | |
NODEJS_VERSION: '18' | |
jobs: | |
units: | |
name: Units | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODEJS_VERSION }} | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install dependencies | |
run: npm install | |
- name: Test | |
id: test_run | |
run: npm test -- --collect-coverage --max-workers=4 | |
- uses: actions/upload-artifact@v4 | |
if: ${{ steps.test_run.outcome == 'success' }} | |
name: Save coverage report | |
with: | |
name: coverage_report | |
path: coverage/ | |
retention-days: 10 | |
sanity: | |
if: ${{ github.event_name == 'pull_request' }} | |
name: Sanity | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ env.NODEJS_VERSION }} | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install dependencies | |
run: npm install | |
- name: Lint | |
run: npm run lint | |
- name: Build | |
run: npm run build | |
coverage: | |
name: Coverage | |
needs: [units] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download coverage report | |
uses: actions/download-artifact@v4 | |
with: | |
name: coverage_report | |
path: coverage | |
- name: Upload coverage report | |
if: ${{ success() }} | |
uses: codecov/codecov-action@v4.2.0 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
directory: coverage | |
plugin: pycoverage # Only run one plugin so that all do not run. There is no way to disable plugins entirely. |