Skip to content

Fix CI #15393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2019
Merged

Fix CI #15393

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
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ jobs:
- store_artifacts:
path: ./build.tgz

- store_artifacts:
path: ./scripts/rollup/results.json

- store_artifacts:
path: ./scripts/error-codes/codes.json
59 changes: 51 additions & 8 deletions dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//
// `DANGER_GITHUB_API_TOKEN=[ENV_ABOVE] yarn danger pr https://github.com/facebook/react/pull/11865

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

const {generateResultsArray} = require('./scripts/rollup/stats');
Expand Down Expand Up @@ -108,18 +108,61 @@ function git(args) {
// Use git locally to grab the commit which represents the place
// where the branches differ
const upstreamRepo = danger.github.pr.base.repo.full_name;
if (upstreamRepo !== 'facebook/react') {
// Exit unless we're running in the main repo
return;
}

const upstreamRef = danger.github.pr.base.ref;
await git(`remote add upstream https://github.com/${upstreamRepo}.git`);
await git(`remote add upstream https://github.com/facebook/react.git`);
await git('fetch upstream');
const mergeBaseCommit = await git(`merge-base HEAD upstream/${upstreamRef}`);
const baseCommit = await git(`merge-base HEAD upstream/${upstreamRef}`);

let resultsResponse = null;
try {
let baseCIBuildId = null;
const statusesResponse = await fetch(
`https://api.github.com/repos/facebook/react/commits/${baseCommit}/statuses`
);
const statuses = await statusesResponse.json();
for (let i = 0; i < statuses.length; i++) {
const status = statuses[i];
if (status.context === 'ci/circleci' && status.state === 'success') {
baseCIBuildId = /\/facebook\/react\/([0-9]+)/.exec(
status.target_url
)[1];
}
}

if (baseCIBuildId === null) {
warn(`Base commit is broken: ${baseCommit}`);
return;
}

const commitURL = sha =>
`http://react.zpao.com/builds/master/_commits/${sha}/results.json`;
const response = await fetch(commitURL(mergeBaseCommit));
const baseArtifactsInfoResponse = await fetch(
`https://circleci.com/api/v1.1/project/github/facebook/react/${baseCIBuildId}/artifacts`
);
const baseArtifactsInfo = await baseArtifactsInfoResponse.json();

for (let i = 0; i < baseArtifactsInfo.length; i++) {
const info = baseArtifactsInfo[i];
if (info.path === 'home/circleci/project/scripts/results.json') {
resultsResponse = await fetch(info.url);
}
}
} catch (error) {
warn(`Failed to fetch build artifacts for base commit: ${baseCommit}`);
return;
}

if (resultsResponse === null) {
warn(`Could not find build artifacts for base commit: ${baseCommit}`);
return;
}

// Take the JSON of the build response and
// make an array comparing the results for printing
const previousBuildResults = await response.json();
const previousBuildResults = await resultsResponse.json();
const results = generateResultsArray(
currentBuildResults,
previousBuildResults
Expand Down Expand Up @@ -212,7 +255,7 @@ function git(args) {
<details>
<summary>Details of bundled changes.</summary>

<p>Comparing: ${mergeBaseCommit}...${danger.github.pr.head.sha}</p>
<p>Comparing: ${baseCommit}...${danger.github.pr.head.sha}</p>


${allTables.join('\n')}
Expand Down
2 changes: 1 addition & 1 deletion packages/scheduler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scheduler",
"version": "0.14.0",
"version": "0.13.6",
"description": "Cooperative scheduler for the browser environment.",
"main": "index.js",
"repository": {
Expand Down
15 changes: 2 additions & 13 deletions scripts/circleci/build.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
#!/bin/bash

set -e
#!/bin/bash

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

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