ci: use npm script for test:coverage #312
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, develop] | |
pull_request: | |
branches: [master, develop] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build, lint, and test on Node ${{ matrix.node }} and ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
node: ["18.x", "20.x"] | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: Setup Node ${{ matrix.node }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
cache: "pnpm" | |
- name: Install | |
run: pnpm install | |
- name: Lint | |
run: pnpm lint | |
- name: Test | |
run: pnpm test:coverage | |
- name: Cache Coverage | |
id: cache-coverage | |
uses: actions/cache@v4 | |
with: | |
path: ./coverage | |
key: ${{ runner.os }}-coverage | |
- name: Upload coverage to Coveralls | |
if: steps.cache-coverage.outputs.cache-hit == 'true' | |
uses: coverallsapp/[email protected] | |
with: | |
path-to-lcov: ./coverage/lcov.info | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload coverage to Codecov | |
if: steps.cache-coverage.outputs.cache-hit == 'true' | |
uses: codecov/codecov-action@v4 | |
with: | |
directory: ./coverage | |
verbose: true | |
- name: Build | |
run: pnpm build | |
release: | |
name: Release | |
if: ${{ github.ref == 'refs/heads/master' }} | |
needs: [build] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Setup PNPM | |
uses: pnpm/action-setup@v3 | |
with: | |
version: 8 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: .nvmrc | |
cache: "pnpm" | |
- name: Install | |
run: pnpm install | |
- name: Build | |
run: pnpm build | |
- name: Release | |
run: pnpm semantic-release | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GIT_AUTHOR_NAME: ${{ secrets.SEMANTIC_RELEASE_GIT_NAME }} | |
GIT_AUTHOR_EMAIL: ${{ secrets.SEMANTIC_RELEASE_GIT_EMAIL }} | |
GIT_COMMITTER_NAME: ${{ secrets.SEMANTIC_RELEASE_GIT_NAME }} | |
GIT_COMMITTER_EMAIL: ${{ secrets.SEMANTIC_RELEASE_GIT_EMAIL }} |