Repository navigation
Expand file tree
/
Copy pathdispatch-qa2-e2e.js
More file actions
69 lines (56 loc) · 1.71 KB
/
Copy pathdispatch-qa2-e2e.js
File metadata and controls
69 lines (56 loc) · 1.71 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env node
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { parseArgs } from 'node:util';
import { dispatchAppTestsEvent } from './lib/github-app/index.js';
const __filename = fileURLToPath(import.meta.url);
const EVENT_TYPE = 'qa2_deploy_succeeded';
function isMainModule() {
if (!process.argv[1]) {
return false;
}
return path.resolve(process.argv[1]) === __filename;
}
export function buildClientPayload({ version, sourceSha, sourceRunUrl }) {
return {
source_repo: 'RoundingWell/app-frontend',
source_ref: `refs/tags/${ version }`,
source_sha: sourceSha,
source_run_url: sourceRunUrl,
organization: 'qa2',
stage: 'qa',
};
}
export function resolveInputs(values) {
const version = values.version;
const sourceSha = values['source-sha'];
const sourceRunUrl = values['source-run-url'];
if (!version || !sourceSha || !sourceRunUrl) {
throw new Error('--version, --source-sha, and --source-run-url are required');
}
return { version, sourceSha, sourceRunUrl };
}
export async function dispatchQa2E2E(values) {
const { version, sourceSha, sourceRunUrl } = resolveInputs(values);
const clientPayload = buildClientPayload({ version, sourceSha, sourceRunUrl });
await dispatchAppTestsEvent({
eventType: EVENT_TYPE,
clientPayload,
});
}
async function main() {
const { values } = parseArgs({
options: {
'version': { type: 'string' },
'source-sha': { type: 'string' },
'source-run-url': { type: 'string' },
},
});
await dispatchQa2E2E(values);
}
if (isMainModule()) {
main().catch(error => {
process.stderr.write(`Failed to dispatch QA2 E2E run: ${ error.message }\n`);
process.exit(1);
});
}