From c85d565e0b936dd24e23a8189607719d5fa06cf5 Mon Sep 17 00:00:00 2001 From: Thomas Cooper Date: Wed, 7 Feb 2024 11:20:16 -0500 Subject: [PATCH 1/3] fix(ci): set CODECOV_TOKEN after action upgrade - codecov-action@v4 requires the token to be set - flags are not necessary at this time. its used to differentiate test types and/or sub-components in a monorepo. For now, we just want to see all test coverage across the whole project. --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index e147e28f1..a179d6b57 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -61,7 +61,7 @@ jobs: uses: codecov/codecov-action@v4.0.1 with: files: ./coverage/lcov.info - flags: unittests + 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 }} From b37a0d4316955c683ae1558fa9569b2449441e4f Mon Sep 17 00:00:00 2001 From: Thomas Cooper Date: Wed, 7 Feb 2024 11:28:27 -0500 Subject: [PATCH 2/3] fix: remove nyc include filter on PRs to test codecov - this commit will be reverted; DO NOT MERGE --- nyc.config.js | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/nyc.config.js b/nyc.config.js index 297160729..392b6e83d 100644 --- a/nyc.config.js +++ b/nyc.config.js @@ -1,9 +1,9 @@ /* eslint-disable max-len */ 'use strict'; -const { execFileSync } = require('child_process'); +// const { execFileSync } = require('child_process'); -let opts = { +const opts = { branches: 80, lines: 80, functions: 80, @@ -13,29 +13,29 @@ let opts = { // 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); - } -} +// 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; From 18c12f03211bbed10044189988acf6072e9664c6 Mon Sep 17 00:00:00 2001 From: Thomas Cooper Date: Wed, 7 Feb 2024 12:40:00 -0500 Subject: [PATCH 3/3] feat: set codecov to informational, remove dead code in nyc config - 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 --- .github/workflows/nodejs.yml | 13 ------------- README.md | 1 + codecov.yml | 8 ++++++++ nyc.config.js | 32 -------------------------------- 4 files changed, 9 insertions(+), 45 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index a179d6b57..c673c83d2 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -45,19 +45,7 @@ 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: Upload test coverage report - if: ${{ steps.check-lcov-non-empty.outputs.isNotEmpty == 'true'}} uses: codecov/codecov-action@v4.0.1 with: files: ./coverage/lcov.info @@ -65,4 +53,3 @@ jobs: # - name: Exit if coverage condition not met # if: ${{ steps.test.outputs.exit_code }} != 0 # run: exit ${{ steps.test.outputs.exit_code }} - diff --git a/README.md b/README.md index f4266f4c6..6e917d2da 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ [![FINOS - Incubating](https://cdn.jsdelivr.net/gh/finos/contrib-toolbox@master/images/badge-incubating.svg)](https://community.finos.org/docs/governance/Software-Projects/stages/incubating) [![NPM](https://img.shields.io/npm/v/@finos/git-proxy?colorA=00C586&colorB=000000)](https://www.npmjs.com/package/@finos/git-proxy) [![Build](https://img.shields.io/github/actions/workflow/status/finos/git-proxy/nodejs.yml?branch=main&label=CI&logo=github&colorA=00C586&colorB=000000)](https://github.com/finos/git-proxy/actions/workflows/nodejs.yml) +[![codecov](https://codecov.io/gh/finos/git-proxy/branch/main/graph/badge.svg)](https://codecov.io/gh/finos/git-proxy) [![Documentation](https://img.shields.io/badge/_-documentation-000000?colorA=00C586&logo=docusaurus&logoColor=FFFFFF&)](https://git-proxy.finos.org)
[![License](https://img.shields.io/github/license/finos/git-proxy?colorA=00C586&colorB=000000)](https://github.com/finos/git-proxy/blob/main/LICENSE) diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..bfdc9877d --- /dev/null +++ b/codecov.yml @@ -0,0 +1,8 @@ +coverage: + status: + project: + default: + informational: true + patch: + default: + informational: true diff --git a/nyc.config.js b/nyc.config.js index 392b6e83d..7b8a33f43 100644 --- a/nyc.config.js +++ b/nyc.config.js @@ -1,8 +1,3 @@ -/* eslint-disable max-len */ -'use strict'; - -// const { execFileSync } = require('child_process'); - const opts = { branches: 80, lines: 80, @@ -10,32 +5,5 @@ const opts = { 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;