Skip to content

Commit

Permalink
[ci] Fix download_base_build_for_sizebot (#26422)
Browse files Browse the repository at this point in the history
CircleCI now enforces passing a token when fetching artifacts. I'm also
deleting the old request-promise-json dependency because AFAIK we were
only using it to fetch json from circleci about the list of available
artifacts – which we can just do using node-fetch. Plus, the underlying
request package it uses has been deprecated since 2019.
  • Loading branch information
poteto committed Mar 17, 2023
1 parent 6854a3c commit 6310087
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 311 deletions.
1 change: 0 additions & 1 deletion scripts/release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"prompt-promise": "^1.0.3",
"puppeteer": "^1.11.0",
"pushstate-server": "^3.0.1",
"request-promise-json": "^1.0.4",
"semver": "^5.4.1"
}
}
8 changes: 7 additions & 1 deletion scripts/release/shared-commands/download-build-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ const run = async ({build, cwd, releaseChannel}) => {
}

// Download and extract artifact
const {CIRCLE_CI_API_TOKEN} = process.env;
if (CIRCLE_CI_API_TOKEN == null) {
throw new Error(
`Expected a CircleCI token to download artifacts, got ${CIRCLE_CI_API_TOKEN}`
);
}
await exec(`rm -rf ./build`, {cwd});
await exec(
`curl -L $(fwdproxy-config curl) ${buildArtifacts.url} | tar -xvz`,
`curl -L $(fwdproxy-config curl) ${buildArtifacts.url} -H "Circle-Token: ${CIRCLE_CI_API_TOKEN}" | tar -xvz`,
{
cwd,
}
Expand Down
16 changes: 13 additions & 3 deletions scripts/release/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {createPatch} = require('diff');
const {hashElement} = require('folder-hash');
const {existsSync, readFileSync, writeFileSync} = require('fs');
const {readJson, writeJson} = require('fs-extra');
const http = require('request-promise-json');
const fetch = require('node-fetch');
const logUpdate = require('log-update');
const {join} = require('path');
const createLogger = require('progress-estimator');
Expand Down Expand Up @@ -59,9 +59,19 @@ const extractCommitFromVersionNumber = version => {
};

const getArtifactsList = async buildID => {
const {CIRCLE_CI_API_TOKEN} = process.env;
if (CIRCLE_CI_API_TOKEN == null) {
throw new Error(
`Expected a CircleCI token to download artifacts, got ${CIRCLE_CI_API_TOKEN}`
);
}
const jobArtifactsURL = `https://circleci.com/api/v1.1/project/github/facebook/react/${buildID}/artifacts`;
const jobArtifacts = await http.get(jobArtifactsURL, true);
return jobArtifacts;
const jobArtifacts = await fetch(jobArtifactsURL, {
headers: {
'Circle-Token': CIRCLE_CI_API_TOKEN,
},
});
return jobArtifacts.json();
};

const getBuildInfo = async () => {
Expand Down
Loading

0 comments on commit 6310087

Please sign in to comment.