Skip to content

Commit 41447d8

Browse files
committed
Move ref default to cli.ts
1 parent d4f77a8 commit 41447d8

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

packages/compass-smoke-tests/src/cli.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env npx ts-node
2+
import cp from 'node:child_process';
23
import assert from 'node:assert/strict';
34
import yargs from 'yargs';
45
import { hideBin } from 'yargs/helpers';
@@ -57,6 +58,15 @@ function getDefaultArch() {
5758
}
5859
}
5960

61+
function getDefaultRef() {
62+
// TODO: Read this from an environment variable if possible
63+
return cp
64+
.spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
65+
encoding: 'utf8',
66+
})
67+
.stdout.trim();
68+
}
69+
6070
yargs(hideBin(process.argv))
6171
.scriptName('smoke-tests')
6272
.detectLocale(false)
@@ -128,6 +138,7 @@ yargs(hideBin(process.argv))
128138
.option('ref', {
129139
type: 'string',
130140
description: 'Git reference to dispatch the workflow from',
141+
default: getDefaultRef(),
131142
})
132143
.option('version', {
133144
type: 'string',

packages/compass-smoke-tests/src/dispatch.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import cp from 'node:child_process';
21
import crypto from 'node:crypto';
32

43
import * as github from '@actions/github';
@@ -48,18 +47,9 @@ async function getWorkflowRunRetrying(
4847
);
4948
}
5049

51-
function getDefaultRef() {
52-
// TODO: Read this from an environment variable if possible
53-
return cp
54-
.spawnSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
55-
encoding: 'utf8',
56-
})
57-
.stdout.trim();
58-
}
59-
6050
type DispatchOptions = {
6151
githubToken: string;
62-
ref: string | undefined;
52+
ref: string;
6353
version: string;
6454
bucketName: string;
6555
bucketKeyPrefix: string;
@@ -72,7 +62,7 @@ type DispatchOptions = {
7262

7363
export async function dispatchAndWait({
7464
githubToken,
75-
ref = getDefaultRef(),
65+
ref,
7666
version,
7767
bucketName,
7868
bucketKeyPrefix,

0 commit comments

Comments
 (0)