Skip to content

ci: add code coverage to be sent to Codecov #45

ci: add code coverage to be sent to Codecov

ci: add code coverage to be sent to Codecov #45

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 16.x, 18.x, 20.x ]
mongodb-version: [ ^4.0.0, ^5.0.0 ]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Setup MongoDB
run: pnpm install mongodb@${{ matrix.mongodb-version }}
- name: Build
run: pnpm run build
- name: Test
run: pnpm run test:coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
publish:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: latest
- name: Setup Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: 'https://registry.npmjs.org'
scope: '@fizzbuds'
cache: 'pnpm'
- name: Increase patch and commit
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github'
pnpm version patch
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build and Publish
run: pnpm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Push Commit
run: git push --follow-tags