Skip to content

Commit 3b7027b

Browse files
committed
Work around GitHub API changes ("timeouts" waiting for workflows)
When GitGitGadget triggers a workflow, it wants to verify that said workflow actually got started. Since the GitHub API to dispatch a `workflow_dispatch` does not wait until the workflow has been created, we are left with the unfortunate option to poll for the created workflow. To make this a little less painful, we list only the workflow runs that have been started after the workflow dispatch has been dispatched. This condition uses the operator `=>`. That used to work fine for many, many years. The `=>` operator (where the equal sign comes _before_ the greater-than sign) might not be canonical in C or JavaScript programs, but that's what the documentation recommended to use, so use it we did. However, recently we got a lot of errors in the server logs (not shown to the user). They basically say that a 30 second timeout waiting for the workflows to start has not been enough, and so it "timed out waiting for the workflow". The real reason for the "timeout" was, of course, that it did not find _any_ workflows. The list of workflow runs was empty. Because GitHub no longer recognizes that form of the operator. I'm unaware of any communication about this change, so it caught me by surprise. Whatever the reason or absence of a heads-up: My tests show that the GitHub API no longer accepts `=>` as the "greater or equal" operator. Who knows what this construct is now interpreted as, the short version is: What used to work no longer does. In my tests, the operator `>=` _does_ actually work. So let's just use that and move on, and immediately forget about this sad chapter in GitGitGadget's life story. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 43da0f3 commit 3b7027b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

GitGitGadget/trigger-workflow-dispatch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const waitForWorkflowRun = async (context, token, owner, repo, workflow_id, afte
2626
context,
2727
token,
2828
'GET',
29-
`/repos/${owner}/${repo}/actions/runs?actor=${actor}&event=workflow_dispatch&created=>${after}`
29+
`/repos/${owner}/${repo}/actions/runs?actor=${actor}&event=workflow_dispatch&created>=${after}`
3030
)
3131
const filtered = res.workflow_runs.filter(e => e.path === `.github/workflows/${workflow_id}`)
3232
if (filtered.length > 0) return filtered

__tests__/trigger-workflow-dispatch.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const mockHTTPSRequest = jest.fn(async (_context, _hostname, method, requestPath
77
}
88
}
99
if (method === 'GET' && requestPath === '/user') return { login: 'the actor' }
10-
if (method === 'GET' && requestPath === '/repos/hello/world/actions/runs?actor=the actor&event=workflow_dispatch&created=>2023-01-23T01:23:45.000Z') {
10+
if (method === 'GET' && requestPath === '/repos/hello/world/actions/runs?actor=the actor&event=workflow_dispatch&created>=2023-01-23T01:23:45.000Z') {
1111
return {
1212
workflow_runs: [
1313
{ path: 'not this one.yml' },

0 commit comments

Comments
 (0)