Skip to content

Commit fff0f8c

Browse files
committed
chore: remove any path resolution from inputs
1 parent 2511656 commit fff0f8c

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
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.workspace}} ${{ github.event.pull_request.head.label }} ${{ github.event.pull_request.head.sha }}
289+
run: node ./scripts/codecov-upload-flags.mjs ${{ github.event.pull_request.head.label }} ${{ github.event.pull_request.head.sha }}
290290

scripts/codecov-upload-flags.mjs

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

6-
const ROOT_DIR = process.argv[2];
6+
// Usage
7+
// node ./scripts/codecov-upload-flags.mjs
8+
79
const branchName = process.argv[3];
810
const commitSha = process.argv[4];
911

10-
if (typeof ROOT_DIR !== 'string') {
11-
console.log('Workspace missing! Exiting');
12-
process.exit(-1);
13-
}
1412
if (typeof branchName !== 'string') {
1513
console.log('Branch name missing! Exiting');
1614
process.exit(-1);
@@ -21,11 +19,8 @@ if (typeof commitSha !== 'string') {
2119
}
2220

2321
const readPkg = (dir) => JSON.parse(readFileSync(path.join(dir, 'package.json'), 'utf8'));
24-
const execCmd = (cmd, opts = {}) => execSync(cmd, {cwd: process.argv[2], encoding: 'utf-8', stdio: 'inherit', ...opts});
25-
26-
const pkgInfo = readPkg(ROOT_DIR);
22+
const pkgInfo = readPkg('.');
2723
const pkgFiles = pkgInfo.workspaces.map((exp) => globSync(path.join(exp, 'package.json')));
28-
const codecovPath = path.resolve(ROOT_DIR, 'codecov');
2924
const pkgsWithFlag = pkgFiles.flat().map((f) => {
3025
const path = f.replace('package.json', '');
3126
const info = readPkg(path);
@@ -70,16 +65,17 @@ if (!url) {
7065
process.exit(-1);
7166
}
7267

68+
const execOpts = {encoding: 'utf-8', stdio: 'inherit'};
7369
if (existsSync(codecovPath)) {
7470
console.log(`Codecov binary found.`);
7571
} else {
7672
console.log(`Codecov binary missing. Downloading from ${url}`);
77-
execCmd(`curl -O "${url}"`);
78-
console.log(`Verifying codecov binary downloaded to ${codecovPath}`);
79-
execCmd(`echo "$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)" | gpg --no-default-keyring --import`);
80-
execCmd(`curl -O "${url}.SHA256SUM"`);
81-
execCmd(`curl -O "${url}.SHA256SUM.sig"`);
82-
execCmd(`gpg --verify "${codecovPath}.SHA256SUM.sig" "${codecovPath}.SHA256SUM"`);
73+
execSync(`curl -O "${url}"`, execOpts);
74+
console.log(`Verifying codecov binary downloaded to "./codecov"`);
75+
execSync(`echo "$(curl -s https://keybase.io/codecovsecurity/pgp_keys.asc)" | gpg --no-default-keyring --import`, execOpts);
76+
execSync(`curl -O "${url}.SHA256SUM"`, execOpts);
77+
execSync(`curl -O "${url}.SHA256SUM.sig"`, execOpts);
78+
execSync(`gpg --verify "codecov.SHA256SUM.sig" "codecov.SHA256SUM"`, execOpts);
8379
}
8480
// make sure we have exec perms
8581
chmodSync(codecovPath, 0o555);
@@ -88,6 +84,6 @@ chmodSync(codecovPath, 0o555);
8884
for (const pkg of pkgsWithFlag) {
8985
if (existsSync(pkg.report)) {
9086
console.log(`\n\nCODECOV: Uploading report of "${pkg.name}" with flag "${pkg.flag}"\n${pkg.command}`);
91-
execCmd(pkg.command);
87+
execSync(pkg.command, execOpts);
9288
}
9389
}

0 commit comments

Comments
 (0)