Skip to content

Commit de75903

Browse files
authored
Fix CI (#15393)
* Revert "Bump scheduler version to 0.14.0" This reverts commit 687e4fb. * Store results.json as CI build artifact
1 parent 687e4fb commit de75903

File tree

4 files changed

+57
-22
lines changed

4 files changed

+57
-22
lines changed

Diff for: .circleci/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,8 @@ jobs:
4646
- store_artifacts:
4747
path: ./build.tgz
4848

49+
- store_artifacts:
50+
path: ./scripts/rollup/results.json
51+
4952
- store_artifacts:
5053
path: ./scripts/error-codes/codes.json

Diff for: dangerfile.js

+51-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
//
2626
// `DANGER_GITHUB_API_TOKEN=[ENV_ABOVE] yarn danger pr https://github.com/facebook/react/pull/11865
2727

28-
const {markdown, danger} = require('danger');
28+
const {markdown, danger, warn} = require('danger');
2929
const fetch = require('node-fetch');
3030

3131
const {generateResultsArray} = require('./scripts/rollup/stats');
@@ -108,18 +108,61 @@ function git(args) {
108108
// Use git locally to grab the commit which represents the place
109109
// where the branches differ
110110
const upstreamRepo = danger.github.pr.base.repo.full_name;
111+
if (upstreamRepo !== 'facebook/react') {
112+
// Exit unless we're running in the main repo
113+
return;
114+
}
115+
111116
const upstreamRef = danger.github.pr.base.ref;
112-
await git(`remote add upstream https://github.com/${upstreamRepo}.git`);
117+
await git(`remote add upstream https://github.com/facebook/react.git`);
113118
await git('fetch upstream');
114-
const mergeBaseCommit = await git(`merge-base HEAD upstream/${upstreamRef}`);
119+
const baseCommit = await git(`merge-base HEAD upstream/${upstreamRef}`);
120+
121+
let resultsResponse = null;
122+
try {
123+
let baseCIBuildId = null;
124+
const statusesResponse = await fetch(
125+
`https://api.github.com/repos/facebook/react/commits/${baseCommit}/statuses`
126+
);
127+
const statuses = await statusesResponse.json();
128+
for (let i = 0; i < statuses.length; i++) {
129+
const status = statuses[i];
130+
if (status.context === 'ci/circleci' && status.state === 'success') {
131+
baseCIBuildId = /\/facebook\/react\/([0-9]+)/.exec(
132+
status.target_url
133+
)[1];
134+
}
135+
}
136+
137+
if (baseCIBuildId === null) {
138+
warn(`Base commit is broken: ${baseCommit}`);
139+
return;
140+
}
115141

116-
const commitURL = sha =>
117-
`http://react.zpao.com/builds/master/_commits/${sha}/results.json`;
118-
const response = await fetch(commitURL(mergeBaseCommit));
142+
const baseArtifactsInfoResponse = await fetch(
143+
`https://circleci.com/api/v1.1/project/github/facebook/react/${baseCIBuildId}/artifacts`
144+
);
145+
const baseArtifactsInfo = await baseArtifactsInfoResponse.json();
146+
147+
for (let i = 0; i < baseArtifactsInfo.length; i++) {
148+
const info = baseArtifactsInfo[i];
149+
if (info.path === 'home/circleci/project/scripts/results.json') {
150+
resultsResponse = await fetch(info.url);
151+
}
152+
}
153+
} catch (error) {
154+
warn(`Failed to fetch build artifacts for base commit: ${baseCommit}`);
155+
return;
156+
}
157+
158+
if (resultsResponse === null) {
159+
warn(`Could not find build artifacts for base commit: ${baseCommit}`);
160+
return;
161+
}
119162

120163
// Take the JSON of the build response and
121164
// make an array comparing the results for printing
122-
const previousBuildResults = await response.json();
165+
const previousBuildResults = await resultsResponse.json();
123166
const results = generateResultsArray(
124167
currentBuildResults,
125168
previousBuildResults
@@ -212,7 +255,7 @@ function git(args) {
212255
<details>
213256
<summary>Details of bundled changes.</summary>
214257
215-
<p>Comparing: ${mergeBaseCommit}...${danger.github.pr.head.sha}</p>
258+
<p>Comparing: ${baseCommit}...${danger.github.pr.head.sha}</p>
216259
217260
218261
${allTables.join('\n')}

Diff for: packages/scheduler/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scheduler",
3-
"version": "0.14.0",
3+
"version": "0.13.6",
44
"description": "Cooperative scheduler for the browser environment.",
55
"main": "index.js",
66
"repository": {

Diff for: scripts/circleci/build.sh

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
1-
#!/bin/bash
2-
3-
set -e
1+
#!/bin/bash
42

5-
# On master, download the bundle sizes from last master build so that
6-
# the size printed in the CI logs for master commits is accurate.
7-
# We don't do it for pull requests because those are compared against
8-
# the merge base by Dangerfile instead. See https://github.com/facebook/react/pull/12606.
9-
if [ -z "$CI_PULL_REQUEST" ]; then
10-
curl -o scripts/rollup/results.json http://react.zpao.com/builds/master/latest/results.json
11-
else
12-
# If build fails, cause danger to fail/abort too
13-
rm scripts/rollup/results.json
14-
fi
3+
set -e
154

165
yarn build --extract-errors
176
# Note: since we run the full build including extracting error codes,

0 commit comments

Comments
 (0)