Fix CI (#15393)
* Revert "Bump scheduler version to 0.14.0" This reverts commit 687e4fb6f7dcb13ca3c668bf5f3df4c0b281f58c. * Store results.json as CI build artifact
Andrew Clark committed
Apr 11, 2019 at 16:43 UTC
de75903272d114c412fea9cdcd725468cf05a06c
4 files changed
+57
-22
.circleci/config.yml
+3
@@ -46,5 +46,8 @@ jobs:
46
- store_artifacts:
47
path: ./build.tgz
48
49
+ - store_artifacts:
50
+ path: ./scripts/rollup/results.json
51
+
52
- store_artifacts:
53
path: ./scripts/error-codes/codes.json
dangerfile.js
+51
-8
@@ -25,7 +25,7 @@
25
//
26
// `DANGER_GITHUB_API_TOKEN=[ENV_ABOVE] yarn danger pr https://github.com/facebook/react/pull/11865
27
28
-const {markdown, danger} = require('danger');
28
+const {markdown, danger, warn} = require('danger');
29
const fetch = require('node-fetch');
30
31
const {generateResultsArray} = require('./scripts/rollup/stats');
@@ -108,18 +108,61 @@ function git(args) {
108
// Use git locally to grab the commit which represents the place
109
// where the branches differ
110
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
+
116
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`);
118
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
+ }
141
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
+ }
162
163
// Take the JSON of the build response and
164
// make an array comparing the results for printing
122
- const previousBuildResults = await response.json();
165
+ const previousBuildResults = await resultsResponse.json();
166
const results = generateResultsArray(
167
currentBuildResults,
168
previousBuildResults
@@ -212,7 +255,7 @@ function git(args) {
255
<details>
256
<summary>Details of bundled changes.</summary>
257
215
- <p>Comparing: ${mergeBaseCommit}...${danger.github.pr.head.sha}</p>
258
+ <p>Comparing: ${baseCommit}...${danger.github.pr.head.sha}</p>
259
260
261
${allTables.join('\n')}
packages/scheduler/package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "scheduler",
3
- "version": "0.14.0",
3
+ "version": "0.13.6",
4
"description": "Cooperative scheduler for the browser environment.",
5
"main": "index.js",
6
"repository": {
scripts/circleci/build.sh
+2
-13
@@ -1,17 +1,6 @@
1
-#!/bin/bash
2
-
3
-set -e
1
+#!/bin/bash
2
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
4
5
yarn build --extract-errors
6
# Note: since we run the full build including extracting error codes,