Skip to content

MAT-7896 update github actions to v4 #288

MAT-7896 update github actions to v4

MAT-7896 update github actions to v4 #288

# - perform a clean install of node dependencies
# - lint the source code for errors
# - build the source code
# - run tests and capture code coverage
# - run end-to-end tests
# - upload the code coverage report to Codacy
# - upload the code coverage report to Codecov
name: Continuous Integration
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
node_matrix:
strategy:
fail-fast: false
matrix:
version: [20, 21, 18]
name: Checkout, install, lint, build and test with coverage
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node.js (matrix)
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
- name: Cache node modules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
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 node dependencies
run: npm ci
- name: Audit dependencies for security vulnerabilities
run: npm audit --omit=dev --audit-level=${{ vars.NPM_AUDIT_LEVEL }}
- name: Lint the source code
run: npm run-script lint
- name: Check prettier formatting
run: npm run-script check-format
- name: Build the source code
run: npm run build
- name: Execute test coverage
run: npm run-script coverage
- name: Store the coverage report as an artifact
uses: actions/upload-artifact@v4
with:
name: coverage
path: src/coverage/lcov.info
upload-codacy-coverage:
name: Upload code coverage to Codacy
needs: node_matrix
runs-on: ubuntu-latest
steps:
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage
- name: Upload code coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: lcov.info
upload-codecov-coverage:
name: Upload code coverage to Codecov
needs: node_matrix
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download coverage artifact
uses: actions/download-artifact@v4
with:
name: coverage
- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: lcov.info
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}