forked from finos/git-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only use include on PRs, otherwise ignore
reconcile package-lock from main
- Loading branch information
1 parent
03d57c5
commit 1fc80f3
Showing
3 changed files
with
478 additions
and
44 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,41 @@ | ||
/* eslint-disable max-len */ | ||
'use strict'; | ||
|
||
const { exec } = require('child_process'); | ||
const { execFileSync } = require('child_process'); | ||
|
||
console.log('Generating coverage report for changed files...'); | ||
const files = []; | ||
exec('git diff --name-only HEAD~1', (err, stdout, stderr) => { | ||
if (err) { | ||
console.error(err + stderr); | ||
return; | ||
} | ||
files.push(...stdout.split('\n')); | ||
}); | ||
|
||
module.exports = { | ||
include: files, | ||
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; |
Oops, something went wrong.