Tests #136
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: Tests | |
on: | |
pull_request: | |
branches: | |
- 'master' | |
push: | |
branches: | |
- '*' | |
paths-ignore: | |
- 'README.md' | |
- 'LICENSE' | |
- 'CODE_OF_CONDUCT.md' | |
- 'CONTRIBUTING.md' | |
jobs: | |
tests: | |
strategy: | |
matrix: | |
node-version: [ 16.x, 18.x ] | |
os: [ ubuntu-latest, windows-latest, macos-latest ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- 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: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Print NPM version | |
run: npm -v | |
- name: Install dependencies | |
run: npm install | |
- name: Build | |
run: npm run build | |
- name: Tests | |
run: npm run test | |
- name: Publish Dry Run | |
run: npm publish --dry-run | |
code-coverage: | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
- uses: actions/checkout@v4 | |
- 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: Use Node.js 16.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 16.x | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm install | |
- name: Lint | |
run: npm run lint-ci | |
- name: Generate code coverage report | |
run: npm run test-coverage | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: ${{ (success() || failure()) && github.ref == 'refs/heads/master' }} | |
with: | |
name: Test results | |
path: junit.xml | |
reporter: jest-junit | |
- name: Upload coverage report to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |