Skip to content

Commit

Permalink
feat: set codecov to informational, remove dead code in nyc config
Browse files Browse the repository at this point in the history
- remove the parsing of changed files for PRs via nyc.config.js
- add codecov.yml and set reports to informational only (dont block PRs)
- add codecov badge to README
  • Loading branch information
coopernetes committed Feb 7, 2024
1 parent b37a0d4 commit 5d623a5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 43 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ jobs:
run: |
npm run test-coverage-ci || echo "Silently ignoring coverage threshold limit..."
- name: Check if a valid lcov.info file is generated
id: check-lcov-non-empty
run: |
if [ -s "./coverage/lcov.info" ]; then
echo "lcov.info is not empty."
echo "isNotEmpty=true" >> $GITHUB_OUTPUT
else
echo "lcov.info is empty."
echo "isNotEmpty=false" >> $GITHUB_OUTPUT
fi
# - name: Check if a valid lcov.info file is generated
# id: check-lcov-non-empty
# run: |
# if [ -s "./coverage/lcov.info" ]; then
# echo "lcov.info is not empty."
# echo "isNotEmpty=true" >> $GITHUB_OUTPUT
# else
# echo "lcov.info is empty."
# echo "isNotEmpty=false" >> $GITHUB_OUTPUT
# fi

- name: Upload test coverage report
if: ${{ steps.check-lcov-non-empty.outputs.isNotEmpty == 'true'}}
# if: ${{ steps.check-lcov-non-empty.outputs.isNotEmpty == 'true'}}
uses: codecov/codecov-action@v4.0.1
with:
files: ./coverage/lcov.info
Expand Down
8 changes: 8 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
32 changes: 0 additions & 32 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
/* eslint-disable max-len */
'use strict';

// const { execFileSync } = require('child_process');

const opts = {
branches: 80,
lines: 80,
functions: 80,
statements: 80,
};

// Only generate coverage report for changed files in PR
// see: https://github.com/actions/checkout/issues/438#issuecomment-1446882066
// https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
// if (process.env.GITHUB_BASE_REF !== undefined) {
// console.log('Generating coverage report for changed files...');
// try {
// const baseRef = execFileSync('git', [
// 'rev-parse',
// `origin/${process.env.GITHUB_BASE_REF}`,
// ])
// .toString()
// .replace('\n', '');
// const headRef = process.env.GITHUB_SHA;
// const stdout = execFileSync('git', [
// 'diff',
// '--name-only',
// `${baseRef}..${headRef}`,
// ]).toString();
// opts = {
// ...opts,
// include: stdout.split('\n'),
// };
// } catch (error) {
// console.log('Error: ', error);
// }
// }

console.log('nyc config: ', opts);
module.exports = opts;

0 comments on commit 5d623a5

Please sign in to comment.