Remove sizebot race condition (#15735)

Sometimes the status of the `build` job is not in the first page of
the `/statuses` endpoint. The combined `/status` endpoint consolidates
the entries, though, so it always appears there.
This commit is contained in:
Andrew Clark 2019-05-24 18:55:28 -07:00 committed by GitHub
parent 393924879f
commit 5fe97dbe19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,9 +126,13 @@ function git(args) {
try {
let baseCIBuildId = null;
const statusesResponse = await fetch(
`https://api.github.com/repos/facebook/react/commits/${baseCommit}/statuses`
`https://api.github.com/repos/facebook/react/commits/${baseCommit}/status`
);
const statuses = await statusesResponse.json();
const {statuses, state} = await statusesResponse.json();
if (state === 'failure') {
warn(`Base commit is broken: ${baseCommit}`);
return;
}
for (let i = 0; i < statuses.length; i++) {
const status = statuses[i];
// This must match the name of the CI job that creates the build artifacts
@ -139,8 +143,8 @@ function git(args) {
)[1];
break;
}
if (status.state === 'failure') {
warn(`Base commit is broken: ${baseCommit}`);
if (status.state === 'pending') {
warn(`Build job for base commit is still pending: ${baseCommit}`);
return;
}
}