fix testing code coverage percentage #28
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: Server CI/CD | |
on: | |
push: | |
branches: [ '**' ] | |
paths: | |
- 'server/**' | |
pull_request: | |
branches: [ main ] | |
paths: | |
- 'server/**' | |
jobs: | |
build_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- name: Install dependencies | |
working-directory: ./server | |
run: npm install | |
- name: Lint | |
working-directory: ./server | |
run: npm run lint | |
# Make sure you have a lint script in your package.json | |
- name: Run tests | |
working-directory: ./server | |
run: npm test | |
# This assumes you have a test script in your package.json | |
# - name: Build | |
# working-directory: ./server | |
# run: npm run build | |
# # Builds your application, make sure you have a build script in your package.json | |
# Conditional step for checking code coverage on main branch | |
- name: Check code coverage | |
if: github.ref == 'refs/heads/main' | |
run: "npm test -- --coverage --coverageThreshold=\"{\\\"global\\\": {\\\"branches\\\": 60, \\\"functions\\\": 60, \\\"lines\\\": 60, \\\"statements\\\": 60}}\"" | |
deploy: # deploy server, for later on | |
needs: build_and_test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v1 |