react/scripts/release/shared-commands/parse-params.js
Andrew Clark 7a5b8227c7
Allow aritfacts download even if CI is broken (#24666)
* Allow aritfacts download even if CI is broken

Adds an option to the download script to disable the CI check and
continue downloading the artifacts even if CI is broken.

I often rely on this to debug broken build artifacts. I was thinking
the sizebot should also use this when downloading the base artifacts
from main, since for the purposes of size tracking, it really doesn't
matter whether the base commit is broken.

* Sizebot should work even if base rev is broken

Sizebot works by downloading the build artifacts for the base revision
and comparing the fize sizes, but the download script will fail if
the base revision has a failing CI job. This happens more often than it
should because of flaky cron jobs, but even when it does, we shouldn't
let it affect the sizebot — for the purposes of tracking sizes, it
doesn't really matter whether the base revision is broken.
2022-06-02 21:55:35 -04:00

82 lines
1.9 KiB
JavaScript

#!/usr/bin/env node
'use strict';
const commandLineArgs = require('command-line-args');
const getBuildIdForCommit = require('./get-build-id-for-commit');
const theme = require('../theme');
const {logPromise} = require('../utils');
const paramDefinitions = [
{
name: 'build',
type: String,
description:
'CI build ID corresponding to the "process_artifacts_combined" task.',
defaultValue: null,
},
{
name: 'commit',
type: String,
description:
'GitHub commit SHA. When provided, automatically finds corresponding CI build.',
defaultValue: null,
},
{
name: 'skipTests',
type: Boolean,
description: 'Skip automated fixture tests.',
defaultValue: false,
},
{
name: 'releaseChannel',
alias: 'r',
type: String,
description: 'Release channel (stable, experimental, or latest)',
},
{
name: 'allowBrokenCI',
type: Boolean,
description:
'Continue even if CI is failing. Useful if you need to debug a broken build.',
defaultValue: false,
},
];
module.exports = async () => {
const params = commandLineArgs(paramDefinitions);
const channel = params.releaseChannel;
if (
channel !== 'experimental' &&
channel !== 'stable' &&
channel !== 'latest'
) {
console.error(
theme.error`Invalid release channel (-r) "${channel}". Must be "stable", "experimental", or "latest".`
);
process.exit(1);
}
if (params.build === null && params.commit === null) {
console.error(
theme.error`Either a --commit or --build param must be specified.`
);
process.exit(1);
}
try {
if (params.build === null) {
params.build = await logPromise(
getBuildIdForCommit(params.commit, params.allowBrokenCI),
theme`Getting build ID for commit "${params.commit}"`
);
}
} catch (error) {
console.error(theme.error(error));
process.exit(1);
}
return params;
};