generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (26 loc) · 842 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const getCoverageFile = () => {
let coverage
try {
coverage = require('./coverage-compare/coverage-summary.json')
} catch {
console.log(`no coverage found`)
}
return coverage
}
function getSummary(coverage) {
return Object.keys(coverage.total).reduce((acc, curr, i) => {
return {
...acc,
[curr]: coverage.total[curr].pct
}
}, {})
}
const currentBranchName = await exec(`git rev-parse --abbrev-ref HEAD`)
await exec(`git checkout -f ${process.env.GITHUB_BASE_REF}`)
const baseCoverage = getCoverageFile()
await exec(`git checkout -f ${currentBranchName}`)
const branchCoverage = getCoverageFile()
const baseSummary = baseCoverage && getSummary(baseCoverage)
const branchSummary = branchCoverage && getSummary(branchCoverage)
console.log('base', baseSummary)
console.log('base', branchSummary)