Skip to content

Commit faffb4e

Browse files
committed
chore: sha and branch are null in push event
1 parent af1f799 commit faffb4e

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,5 @@ jobs:
286286
- name: Merge coverage (Delta)
287287
run: npm run test-merge-coverage:ci:affected
288288
- name: Report Coverage with Flags
289-
run: node ./scripts/codecov-upload-flags.mjs ${{ github.sha }} ${{ github.event.pull_request.head.label }}
289+
run: node ./scripts/codecov-upload-flags.mjs ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.head.label }}
290290

scripts/codecov-upload-flags.mjs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,6 @@ import path from 'path';
99
const commitSha = process.argv[2];
1010
const branchName = process.argv[3];
1111

12-
if (typeof commitSha !== 'string') {
13-
console.log('Error: Commit sha missing. Exiting');
14-
process.exit(-1);
15-
}
16-
if (typeof branchName !== 'string') {
17-
console.log('Warn: Branch name missing.');
18-
}
19-
20-
2112
const readPkg = (dir) => JSON.parse(readFileSync(path.join(dir, 'package.json'), 'utf8'));
2213
const pkgInfo = readPkg('.');
2314
const pkgFiles = pkgInfo.workspaces.map((exp) => globSync(path.join(exp, 'package.json')));
@@ -39,16 +30,19 @@ const pkgsWithFlag = pkgFiles.flat().map((f) => {
3930
// we don't need xcrun or pycoverage plugins
4031
'--plugin gcov',
4132
'--gcov-executable gcov',
42-
'--sha', commitSha,
4333
'--file', report,
4434
'--flag', flag,
4535
// limit any scan to the pacakge folder
4636
'--dir', path,
4737
];
4838

49-
if (branchName) {
39+
if (typeof commitSha === 'string') {
40+
command.push('--sha', commitSha);
41+
}
42+
if (typeof branchName === 'string') {
5043
command.push('--branch', branchName);
5144
}
45+
5246
return { name, flag, path, report, command: command.join(' ') };
5347
});
5448

0 commit comments

Comments
 (0)