68 lines
1.8 KiB
YAML
68 lines
1.8 KiB
YAML
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
|
|
name: Node.js CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and test
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
node-version: [16.x, 18.x, 20.x]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Test on Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
- run: npm ci
|
|
- run: npm run build --if-present
|
|
- run: npm test
|
|
|
|
coverage:
|
|
name: Code coverage
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
submodules: true
|
|
- name: Generate coverage report
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 18.x
|
|
- run: npm ci
|
|
- run: npm run build --if-present
|
|
- run: npm run coverage
|
|
- name: Upload coverage report to storage
|
|
uses: actions/upload-artifact@v1
|
|
with:
|
|
name: coverage
|
|
path: coverage/lcov.info
|
|
|
|
publish:
|
|
name: Publish code coverage report
|
|
needs: coverage
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Download coverage report from storage
|
|
uses: actions/download-artifact@v1
|
|
with:
|
|
name: coverage
|
|
- name: Upload coverage report to codacy
|
|
uses: actions/setup-node@v1
|
|
with:
|
|
node-version: 18.x
|
|
- run: |
|
|
( [[ "${CODACY_PROJECT_TOKEN}" != "" ]] && npm run coverage-publish ) || echo "Coverage report not published"
|
|
env:
|
|
CODACY_PROJECT_TOKEN: ${{secrets.CODACY_PROJECT_TOKEN}}
|