Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ci] Use yargs to parse args to download-experimental-build #30375

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 54 additions & 16 deletions scripts/release/download-experimental-build-ghaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,66 @@

'use strict';

const {join} = require('path');
const {
addDefaultParamValue,
getPublicPackages,
handleError,
} = require('./utils');
const {join, relative} = require('path');
const {getPublicPackages, handleError} = require('./utils');
const yargs = require('yargs');
const clear = require('clear');
const theme = require('./theme');

const downloadBuildArtifacts = require('./shared-commands/download-build-artifacts');
const parseParams = require('./shared-commands/parse-params');
const printSummary = require('./download-experimental-build-commands/print-summary');
const argv = yargs.wrap(yargs.terminalWidth()).options({
releaseChannel: {
alias: 'r',
describe: 'Download the given release channel.',
requiresArg: true,
type: 'string',
choices: ['experimental', 'stable'],
default: 'experimental',
},
commit: {
alias: 'c',
describe: 'Commit hash to download.',
requiresArg: true,
type: 'string',
},
skipTests: {
requiresArg: false,
type: 'boolean',
default: false,
},
allowBrokenCI: {
requiresArg: false,
type: 'boolean',
default: false,
},
}).argv;

// Inlined from scripts/release/download-experimental-build-commands/print-summary.js
function printSummary(commit) {
const commandPath = relative(
process.env.PWD,
join(__dirname, '../download-experimental-build-ghaction.js')
);

clear();

const message = theme`
{caution An experimental build has been downloaded!}

You can download this build again by running:
{path ${commandPath}} --commit={commit ${commit}}
`;

console.log(message.replace(/\n +/g, '\n').trim());
}

const run = async () => {
try {
addDefaultParamValue('-r', '--releaseChannel', 'experimental');

const params = await parseParams();
params.cwd = join(__dirname, '..', '..');
params.packages = await getPublicPackages(true);
argv.cwd = join(__dirname, '..', '..');
argv.packages = await getPublicPackages(true);

await downloadBuildArtifacts(params);
console.log(argv);

printSummary(params);
printSummary(argv.commit);
} catch (error) {
handleError(error);
}
Expand Down
Loading