Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions ansible/www-standalone/tools/promote/check_assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ async function execute () {
caution = true
console.log(` \u001b[33m\u001b[1m⚠\u001b[22m\u001b[39m The following assets are expected for ${line} but are currently missing from staging:`)
notInActual.forEach((a) => console.log(` • ${a}`))
console.log('... Canceling the promotion')
process.exit(1)
}

// bogus unexpected files found in staging, not good
Expand Down
22 changes: 10 additions & 12 deletions ansible/www-standalone/tools/promote/check_assets.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ async function executeMe (stagingDir, distDir) {
return new Promise((resolve, reject) => {
const args = [ '--no-warnings', join(import.meta.dirname, 'check_assets.js'), stagingDir, distDir ];
execFile(process.execPath, args, (err, stdout, stderr) => {
if (err) {
return reject(err);
}
if (stderr) {
console.log('STDERR:', stderr);
}
resolve(stdout);
// Return both stdout and exit code, even if there's an error
const exitCode = err ? (err.code || 1) : 0;
resolve({ stdout, exitCode });
});
});
}
Expand Down Expand Up @@ -86,7 +85,8 @@ const testcases = [
' • node-v10.1.0-linux-armv6l.tar.gz\n' +
' • node-v10.1.0-linux-armv6l.tar.xz\n' +
' • node-v10.1.0.pkg\n' +
' \u001b[33mPromote if you are certain this is the the correct course of action\u001b[39m\n',
'... Canceling the promotion\n',
expectedExitCode: 1,
setup: async function setup (version, fixtureStagingDir, fixtureDistDir) {
await makeFixture(version, true, fixtureStagingDir);
await Promise.all([
Expand Down Expand Up @@ -159,11 +159,8 @@ const testcases = [
' • node-v9.9.9-linux-x86.tar.xz\n' +
' • node-v9.9.9-sunos-x86.tar.gz\n' +
' • node-v9.9.9-sunos-x86.tar.xz\n' +
' \u001b[31m\u001b[1m✖\u001b[22m\u001b[39m The following assets were found in staging but are not expected for v9.x:\n' +
' • docs/apilinks.json\n' +
' Does the expected assets list for v9.x need to be updated?\n' +
' https://github.com/nodejs/build/tree/main/ansible/www-standalone/tools/promote/expected_assets/v9.x\n' +
' \u001b[33mPromote if you are certain this is the the correct course of action\u001b[39m\n',
'... Canceling the promotion\n',
expectedExitCode: 1,
setup: async function setup (version, fixtureStagingDir, fixtureDistDir) {
// use the 10.x list, which is missing the x86 files, it'll check the 9.x
const expectedAssets = await loadExpectedAssets(version, 'v10.x');
Expand Down Expand Up @@ -303,14 +300,15 @@ describe(`${basename(import.meta.filename, '.test.mjs')} tests`, async () => {
afterEach(async (context) => {
await rm(context.testDir, { recursive: true, force: true, maxRetries: 10 });
});
for (const { name, version, expectedStdout, setup } of testcases) {
for (const { name, version, expectedStdout, expectedExitCode = 0, setup } of testcases) {
it(name, async (context) => {
const fixtureStagingDir = join(context.fixtureStagingDir, version);
const fixtureDistDir = join(context.fixtureDistDir, version);
await setup(version, fixtureStagingDir, fixtureDistDir);

const stdout = await executeMe(fixtureStagingDir, fixtureDistDir);
const { stdout, exitCode } = await executeMe(fixtureStagingDir, fixtureDistDir);
assert.strictEqual(stdout, expectedStdout);
assert.strictEqual(exitCode, expectedExitCode);
});
}
});
2 changes: 1 addition & 1 deletion ansible/www-standalone/tools/promote/promote_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ srcdir=$release_srcdir
dstdir=$release_dstdir
dirmatch=$release_dirmatch

node --no-warnings /home/staging/tools/promote/check_assets.js $srcdir/$2 $dstdir/$2
node --no-warnings /home/staging/tools/promote/check_assets.js $srcdir/$2 $dstdir/$2 || exit 1

relative_srcdir=${srcdir/$staging_rootdir/"$site/"}
relative_dstdir=${dstdir/$dist_rootdir/"$site/"}
Expand Down