Skip to content

Commit 2598ed9

Browse files
committed
chore: pass sha and branch as parameters
1 parent 6971ea3 commit 2598ed9

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ 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
289+
run: node ./scripts/codecov-upload-flags.mjs ${{github.ref_name}} ${{github.sha}}
290290
# - name: Report Coverage
291291
# uses: codecov/codecov-action@v5
292292
# env:

scripts/codecov-upload-flags.mjs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@ import { globSync } from 'glob';
33
import { chmodSync, existsSync, readFileSync } from 'fs';
44
import path from 'path';
55

6+
const branchName = process.argv[2];
7+
const commitSha = process.argv[3];
8+
9+
if (typeof branchName !== 'string') {
10+
console.log('Branch name missing! Exiting');
11+
process.exit(-1);
12+
}
13+
if (typeof commitSha !== 'string') {
14+
console.log('Commit sha missing! Exiting');
15+
process.exit(-1);
16+
}
17+
618
const ROOT_DIR = process.cwd();
719
const readPkg = (dir) => JSON.parse(readFileSync(path.join(dir, 'package.json'), 'utf8'));
8-
const execCmd = (cmd, opts = {}) => execSync(cmd, {cwd: ROOT_DIR, encoding: 'utf-8', stdio: 'inherit', ...opts})
20+
const execCmd = (cmd, opts = {}) => execSync(cmd, {cwd: process.cwd(), encoding: 'utf-8', stdio: 'inherit', ...opts});
921

10-
const commitSha = execCmd('git rev-parse HEAD', {stdio: 'pipe'}).replace('\n', '');
11-
const branchName = execCmd('git rev-parse --abbrev-ref HEAD', {stdio: 'pipe'}).replace('\n', '');
1222
const pkgInfo = readPkg(ROOT_DIR);
1323
const pkgFiles = pkgInfo.workspaces.map((exp) => globSync(path.join(exp, 'package.json')));
1424
const codecovPath = path.resolve(ROOT_DIR, 'codecov');

0 commit comments

Comments
 (0)