From 2e540e8f416127f01bd69070725f5bfc016821ce Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Fri, 29 Jan 2021 23:23:38 -0700 Subject: [PATCH] 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. --- .../fixtures/44343-pending-travis/mutations.json | 11 +++++++++++ .../fixtures/44343-pending-travis/result.json | 4 ++-- .../fixtures/44343-pre-travis/mutations.json | 11 +++++++++++ src/_tests/fixtures/44343-pre-travis/result.json | 4 ++-- src/compute-pr-actions.ts | 16 ++++++++-------- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/_tests/fixtures/44343-pending-travis/mutations.json b/src/_tests/fixtures/44343-pending-travis/mutations.json index d8e409326..854a140f7 100644 --- a/src/_tests/fixtures/44343-pending-travis/mutations.json +++ b/src/_tests/fixtures/44343-pending-travis/mutations.json @@ -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": { diff --git a/src/_tests/fixtures/44343-pending-travis/result.json b/src/_tests/fixtures/44343-pending-travis/result.json index 4b4abbd85..909ba1ecb 100644 --- a/src/_tests/fixtures/44343-pending-travis/result.json +++ b/src/_tests/fixtures/44343-pending-travis/result.json @@ -13,7 +13,7 @@ ], "shouldClose": false, "shouldMerge": false, - "shouldUpdateLabels": false, - "shouldUpdateProjectColumn": false, + "shouldUpdateLabels": true, + "shouldUpdateProjectColumn": true, "shouldRemoveFromActiveColumns": false } diff --git a/src/_tests/fixtures/44343-pre-travis/mutations.json b/src/_tests/fixtures/44343-pre-travis/mutations.json index d8e409326..854a140f7 100644 --- a/src/_tests/fixtures/44343-pre-travis/mutations.json +++ b/src/_tests/fixtures/44343-pre-travis/mutations.json @@ -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": { diff --git a/src/_tests/fixtures/44343-pre-travis/result.json b/src/_tests/fixtures/44343-pre-travis/result.json index 4b4abbd85..909ba1ecb 100644 --- a/src/_tests/fixtures/44343-pre-travis/result.json +++ b/src/_tests/fixtures/44343-pre-travis/result.json @@ -13,7 +13,7 @@ ], "shouldClose": false, "shouldMerge": false, - "shouldUpdateLabels": false, - "shouldUpdateProjectColumn": false, + "shouldUpdateLabels": true, + "shouldUpdateProjectColumn": true, "shouldRemoveFromActiveColumns": false } diff --git a/src/compute-pr-actions.ts b/src/compute-pr-actions.ts index 794c44423..d8e138620 100644 --- a/src/compute-pr-actions.ts +++ b/src/compute-pr-actions.ts @@ -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") { @@ -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; }