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

Commit

Permalink
Only delay if actually waiting for CI (#342)
Browse files Browse the repository at this point in the history
Instead of waiting unconditionally for one minute after the last push,
only wait if the CI result is actually `missing`.

Update snapshots.
  • Loading branch information
jablko authored Jan 30, 2021
1 parent c91f075 commit 2e540e8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
11 changes: 11 additions & 0 deletions src/_tests/fixtures/44343-pending-travis/mutations.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
[
{
"mutation": "mutation ($input: RemoveLabelsFromLabelableInput!) {\n removeLabelsFromLabelable(input: $input) {\n __typename\n }\n}\n",
"variables": {
"input": {
"labelIds": [
"MDU6TGFiZWwyMTU0ODU3ODAw"
],
"labelableId": "MDExOlB1bGxSZXF1ZXN0NDEwODAzMTcz"
}
}
},
{
"mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n",
"variables": {
Expand Down
4 changes: 2 additions & 2 deletions src/_tests/fixtures/44343-pending-travis/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"shouldClose": false,
"shouldMerge": false,
"shouldUpdateLabels": false,
"shouldUpdateProjectColumn": false,
"shouldUpdateLabels": true,
"shouldUpdateProjectColumn": true,
"shouldRemoveFromActiveColumns": false
}
11 changes: 11 additions & 0 deletions src/_tests/fixtures/44343-pre-travis/mutations.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
[
{
"mutation": "mutation ($input: RemoveLabelsFromLabelableInput!) {\n removeLabelsFromLabelable(input: $input) {\n __typename\n }\n}\n",
"variables": {
"input": {
"labelIds": [
"MDU6TGFiZWwyMTU0ODU3ODAw"
],
"labelableId": "MDExOlB1bGxSZXF1ZXN0NDEwODAzMTcz"
}
}
},
{
"mutation": "mutation ($input: UpdateIssueCommentInput!) {\n updateIssueComment(input: $input) {\n __typename\n }\n}\n",
"variables": {
Expand Down
4 changes: 2 additions & 2 deletions src/_tests/fixtures/44343-pre-travis/result.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"shouldClose": false,
"shouldMerge": false,
"shouldUpdateLabels": false,
"shouldUpdateProjectColumn": false,
"shouldUpdateLabels": true,
"shouldUpdateProjectColumn": true,
"shouldRemoveFromActiveColumns": false
}
16 changes: 8 additions & 8 deletions src/compute-pr-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,14 @@ export function process(prInfo: BotResult,
}
// CI is missing
else if (info.ciResult === "missing") {
label("Where is GH Actions?");
// This bot is faster than CI in coming back to give a response, and so the bot starts flipping between
// a 'where is CI'-ish state and a 'got CI deets' state. To work around this, we wait a
// minute since the last timeline push action before label/project states can be updated
if (dayjs(info.now).diff(info.lastPushDate, "minutes") >= 1) {
label("Where is GH Actions?");
} else {
delete context.targetColumn;
}
}
// CI is green
else if (info.ciResult === "pass") {
Expand Down Expand Up @@ -355,13 +362,6 @@ export function process(prInfo: BotResult,
// Timeline-related actions
info.staleness?.doTimelineActions(context);

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

return context;
}

Expand Down

0 comments on commit 2e540e8

Please sign in to comment.