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.
Andrew Clark committed
May 24, 2019 at 18:55 UTC
5fe97dbe19917b4c49618073ccc5632b593ec9fa
1 file changed
+8
-4
dangerfile.js
+8
-4
@@ -126,9 +126,13 @@ function git(args) {
126
try {
127
let baseCIBuildId = null;
128
const statusesResponse = await fetch(
129
- `https://api.github.com/repos/facebook/react/commits/${baseCommit}/statuses`
129
+ `https://api.github.com/repos/facebook/react/commits/${baseCommit}/status`
130
);
131
- const statuses = await statusesResponse.json();
131
+ const {statuses, state} = await statusesResponse.json();
132
+ if (state === 'failure') {
133
+ warn(`Base commit is broken: ${baseCommit}`);
134
+ return;
135
+ }
136
for (let i = 0; i < statuses.length; i++) {
137
const status = statuses[i];
138
// This must match the name of the CI job that creates the build artifacts
@@ -139,8 +143,8 @@ function git(args) {
143
)[1];
144
break;
145
}
142
- if (status.state === 'failure') {
143
- warn(`Base commit is broken: ${baseCommit}`);
146
+ if (status.state === 'pending') {
147
+ warn(`Build job for base commit is still pending: ${baseCommit}`);
148
return;
149
}
150
}