Skip to content

Commit

Permalink
fix: report on code coverage only and block ci if tests failure
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSlome committed Mar 22, 2024
1 parent f044286 commit a76c1fc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
59 changes: 29 additions & 30 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ name: Node.js CI

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]

permissions:
pull-requests: write

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -23,33 +22,33 @@ jobs:
mongodb-version: [4.4]

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: supercharge/mongodb-github-action@v1.10.0
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Install dependencies
run: npm i

- name: Test
id: test
run: |
npm run test-coverage-ci || echo "Silently ignoring coverage threshold limit..."
- name: Upload test coverage report
uses: codecov/codecov-action@v4.1.0
with:
files: ./coverage/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Start MongoDB
uses: supercharge/mongodb-github-action@v1.10.0
with:
mongodb-version: ${{ matrix.mongodb-version }}

- name: Install dependencies
run: npm i

- name: Test
id: test
run: |
npm run test-coverage-ci
- name: Upload test coverage report
uses: codecov/codecov-action@v4.1.0
with:
files: ./coverage/lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
# - name: Exit if coverage condition not met
# if: ${{ steps.test.outputs.exit_code }} != 0
# run: exit ${{ steps.test.outputs.exit_code }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"server-test": "mocha --exit",
"test": "mocha --exit",
"test-coverage": "nyc npm run test",
"test-coverage-ci": "nyc --reporter=lcovonly --reporter=text --check-coverage npm run test",
"test-coverage-ci": "nyc --reporter=lcovonly --reporter=text npm run test",
"prepare": "node ./scripts/prepare.js",
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx,json}\" \"test/**/*.{js,jsx,ts,tsx,json}\"",
"lint:fix": "eslint --fix \"src/**/*.{js,jsx,ts,tsx,json}\" \"test/**/*.{js,jsx,ts,tsx,json}\"",
Expand Down

0 comments on commit a76c1fc

Please sign in to comment.