Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test PR #1

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ jobs:
node-version: [16.x]
mongodb-version: [4.4]

permissions:
pull-requests: write

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

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand All @@ -36,5 +41,17 @@ jobs:
run: npm i

- name: Test
run: npm test
id: test
run: |
npm run test-coverage-ci || echo "exit_code=$?" >> $GITHUB_OUTPUT

- name: Comment test coverage report on PR
uses: romeovs/[email protected]
with:
lcov-file: ./coverage/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Exit if coverage condition not met
if: ${{ steps.test.outputs.exit_code }} != 0
run: exit ${{ steps.test.outputs.exit_code }}

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,4 @@ This project is distributed under the Apache-2.0 license. See <a href="./LICENSE

If you have a query or require support with this project, [raise an issue](https://github.com/finos/git-proxy/issues). Otherwise, reach out to [[email protected]](mailto:[email protected]).


41 changes: 41 additions & 0 deletions nyc.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* eslint-disable max-len */
'use strict';

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

let 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;
Loading
Loading