Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit 2e540e8

Browse files
authored
Only delay if actually waiting for CI (#342)
Instead of waiting unconditionally for one minute after the last push, only wait if the CI result is actually `missing`. Update snapshots.
1 parent c91f075 commit 2e540e8

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

src/_tests/fixtures/44343-pending-travis/mutations.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
[
2+
{
3+
"mutation": "mutation ($input: RemoveLabelsFromLabelableInput!) {\n removeLabelsFromLabelable(input: $input) {\n __typename\n }\n}\n",
4+
"variables": {
5+
"input": {
6+
"labelIds": [
7+
"MDU6TGFiZWwyMTU0ODU3ODAw"
8+
],
9+
"labelableId": "MDExOlB1bGxSZXF1ZXN0NDEwODAzMTcz"
10+
}
11+
}
12+
},
213
{
314
"mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n",
415
"variables": {

src/_tests/fixtures/44343-pending-travis/result.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"shouldClose": false,
1515
"shouldMerge": false,
16-
"shouldUpdateLabels": false,
17-
"shouldUpdateProjectColumn": false,
16+
"shouldUpdateLabels": true,
17+
"shouldUpdateProjectColumn": true,
1818
"shouldRemoveFromActiveColumns": false
1919
}

src/_tests/fixtures/44343-pre-travis/mutations.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
[
2+
{
3+
"mutation": "mutation ($input: RemoveLabelsFromLabelableInput!) {\n removeLabelsFromLabelable(input: $input) {\n __typename\n }\n}\n",
4+
"variables": {
5+
"input": {
6+
"labelIds": [
7+
"MDU6TGFiZWwyMTU0ODU3ODAw"
8+
],
9+
"labelableId": "MDExOlB1bGxSZXF1ZXN0NDEwODAzMTcz"
10+
}
11+
}
12+
},
213
{
314
"mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n",
415
"variables": {

src/_tests/fixtures/44343-pre-travis/result.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"shouldClose": false,
1515
"shouldMerge": false,
16-
"shouldUpdateLabels": false,
17-
"shouldUpdateProjectColumn": false,
16+
"shouldUpdateLabels": true,
17+
"shouldUpdateProjectColumn": true,
1818
"shouldRemoveFromActiveColumns": false
1919
}

src/compute-pr-actions.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,14 @@ export function process(prInfo: BotResult,
321321
}
322322
// CI is missing
323323
else if (info.ciResult === "missing") {
324-
label("Where is GH Actions?");
324+
// This bot is faster than CI in coming back to give a response, and so the bot starts flipping between
325+
// a 'where is CI'-ish state and a 'got CI deets' state. To work around this, we wait a
326+
// minute since the last timeline push action before label/project states can be updated
327+
if (dayjs(info.now).diff(info.lastPushDate, "minutes") >= 1) {
328+
label("Where is GH Actions?");
329+
} else {
330+
delete context.targetColumn;
331+
}
325332
}
326333
// CI is green
327334
else if (info.ciResult === "pass") {
@@ -355,13 +362,6 @@ export function process(prInfo: BotResult,
355362
// Timeline-related actions
356363
info.staleness?.doTimelineActions(context);
357364

358-
// This bot is faster than CI in coming back to give a response, and so the bot starts flipping between
359-
// a 'where is CI'-ish state and a 'got CI deets' state. To work around this, we wait a
360-
// minute since the last timeline push action before label/project states can be updated
361-
const tooEarlyForLabelsOrProjects = dayjs(info.now).diff(info.lastPushDate, "minutes") < 1;
362-
context.shouldUpdateLabels = !tooEarlyForLabelsOrProjects;
363-
context.shouldUpdateProjectColumn = !tooEarlyForLabelsOrProjects;
364-
365365
return context;
366366
}
367367

0 commit comments

Comments
 (0)