Skip to content

Commit

Permalink
Allow aritfacts download even if CI is broken (facebook#24666)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
acdlite authored Jun 3, 2022
1 parent d300ceb commit 7a5b822
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ jobs:
command: |
git fetch origin main
cd ./scripts/release && yarn && cd ../../
scripts/release/download-experimental-build.js --commit=$(git merge-base HEAD origin/main)
scripts/release/download-experimental-build.js --commit=$(git merge-base HEAD origin/main) --allowBrokenCI
mv ./build ./base-build
- run:
# TODO: The `download-experimental-build` script copies the npm
Expand Down Expand Up @@ -570,7 +570,7 @@ workflows:
- "16.0"
- "16.5" # schedule package
- "16.8" # hooks
- "17.0"
- "17.0"
- "18.0"
- run_devtools_e2e_tests_for_versions:
requires:
Expand All @@ -581,7 +581,7 @@ workflows:
- "16.0"
- "16.5" # schedule package
- "16.8" # hooks
- "17.0"
- "17.0"
- "18.0"

# Used to publish a prerelease manually via the command line
Expand Down
4 changes: 2 additions & 2 deletions scripts/release/shared-commands/get-build-id-for-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function scrapeBuildIDFromStatus(status) {
return /\/facebook\/react\/([0-9]+)/.exec(status.target_url)[1];
}

async function getBuildIdForCommit(sha) {
async function getBuildIdForCommit(sha, allowBrokenCI = false) {
const retryLimit = Date.now() + RETRY_TIMEOUT;
retry: while (true) {
const statusesResponse = await fetch(
Expand All @@ -34,7 +34,7 @@ async function getBuildIdForCommit(sha) {
}

const {statuses, state} = await statusesResponse.json();
if (state === 'failure') {
if (!allowBrokenCI && state === 'failure') {
throw new Error(`Base commit is broken: ${sha}`);
}
for (let i = 0; i < statuses.length; i++) {
Expand Down
9 changes: 8 additions & 1 deletion scripts/release/shared-commands/parse-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ const paramDefinitions = [
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 () => {
Expand Down Expand Up @@ -61,7 +68,7 @@ module.exports = async () => {
try {
if (params.build === null) {
params.build = await logPromise(
getBuildIdForCommit(params.commit),
getBuildIdForCommit(params.commit, params.allowBrokenCI),
theme`Getting build ID for commit "${params.commit}"`
);
}
Expand Down

0 comments on commit 7a5b822

Please sign in to comment.