github-action-required-labels icon indicating copy to clipboard operation
github-action-required-labels copied to clipboard

Action fails with "Not Found" when run in a merge queue

Open twyatt opened this issue 2 years ago • 10 comments

To reproduce, created a sample project repo at: https://github.com/JuulLabs/merge-queue-test

Without merge queue enabled, github-action-required-labels works (https://github.com/JuulLabs/merge-queue-test/pull/13) as expected:

GitHub Action run w/o merge queue
Run mheap/github-action-required-labels@v5
  with:
    mode: exactly
    count: 1
    labels: patch, minor, major, maintenance
    token: ***
    message: Label error. Requires {{errorString}} {{count}} of: {{ provided }}. Found: {{ applied }}
    add_comment: false

— https://github.com/JuulLabs/merge-queue-test/actions/runs/7154600875/job/19482310003

When merge queue is enabled, and github-action-required-labels runs from the queue, it fails (https://github.com/JuulLabs/merge-queue-test/pull/14) with:

Run mheap/github-action-required-labels@v5
  with:
    mode: exactly
    count: 1
    labels: patch, minor, major, maintenance
    token: ***
    message: Label error. Requires {{errorString}} {{count}} of: {{ provided }}. Found: {{ applied }}
    add_comment: false
Error: Not Found

— https://github.com/JuulLabs/merge-queue-test/actions/runs/7154628159/job/19482369364

twyatt avatar Dec 10 '23 01:12 twyatt

+1! The action seems to fail when in GitHub Merge-Queue

EugeneWImprint avatar May 28 '24 21:05 EugeneWImprint

Thanks both. I'll try to find some time to reproduce + fix

mheap avatar Jun 15 '24 12:06 mheap

Alright, I've managed to reproduce (merge queues are not easy if you've not used them before).

The issue is that the merge_queue event does not contain any context from the PR that was being merged. That means when we try to fetch the applied labels via the API it returns a 404 as there's no PR number available.

It looks as though a failing pull_request check will cause the PR not to be added to a merge queue. Is the issue that if you set label to be a required check for PR, it also becomes required for merge_queue?

mheap avatar Jun 16 '24 11:06 mheap

Is the issue that if you set label to be a required check for PR, it also becomes required for merge_queue?

It has been a while since I have given merged queues a try, but that is my recollection.

From what I remember, we were using label as a required check for PR merges and wanted to leverage merge queues. When enabling merge queues, label check began failing, blocking any ability to merge PRs with merge queues. We ultimately valued having a label check over being able to use merge queues, so we abandoned the merge queues feature in the hopes that the two would one day play nice together.

twyatt avatar Jun 16 '24 15:06 twyatt

It should work if you keep the label check on pull_request and split the merge_queue workflow in to a separate file. This would allow you to use the action with merge queues as it will only run on pull_request events

mheap avatar Jun 19 '24 13:06 mheap

It should work if you keep the label check on pull_request and split the merge_queue workflow in to a separate file.

Thanks for the tips! I'll give it a try soon.

twyatt avatar Jun 21 '24 20:06 twyatt

It should work if you keep the label check on pull_request and split the merge_queue workflow in to a separate file. This would allow you to use the action with merge queues as it will only run on pull_request events

If I'm understanding correctly, this did not work, unfortunately.

I tried with https://github.com/JuulLabs/merge-queue-test/pull/16, whereas I removed merge_group from the labels check, but in doing so: the merge queue never allows the PR to run in the merge queue:

Screenshot 2024-07-15 at 11 43 27 PM

It seems I'd have to remove the label check as a required check for merging to main, but I do want to make sure labels are assigned to PRs; so I'm not sure what the best option would be here?

twyatt avatar Jul 16 '24 06:07 twyatt

I believe the github.ref context variable is available in a merge queue. When I echoed it for https://github.com/JuulLabs/merge-queue-test/pull/17, github.ref evaluated to:

refs/heads/gh-readonly-queue/main/pr-17-a3c310584587d4b97c2df0cb46fe050cc46a15d6

Perhaps a bit clunky, but couldn't the PR number be parsed out of that variable?

twyatt avatar Jul 16 '24 07:07 twyatt

@twyatt I've given it a go. Can you test mheap/github-action-required-labels@merge-queue-support?

mheap avatar Sep 17 '24 14:09 mheap

@twyatt I've given it a go. Can you test mheap/github-action-required-labels@merge-queue-support?

Awesome, TY! I'll try to find some time soon to test it and report back.

twyatt avatar Sep 17 '24 16:09 twyatt

I gave mheap/github-action-required-labels@merge-queue-support a try, sadly, I still got the "Not Found" error:

Run mheap/github-action-required-labels@merge-queue-support
  with:
    mode: exactly
    count: 1
    labels: patch, minor, major, maintenance, renovate
    token: ***
    message: Label error. Requires {{errorString}} {{count}} of: {{ provided }}. Found: {{ applied }}
    add_comment: false
    use_regex: false
/usr/bin/docker run --name d374d726b772f662246c0867d9716766ad730_43acc1 --label 3d374d --workdir /github/workspace --rm -e "INPUT_MODE" -e "INPUT_COUNT" -e "INPUT_LABELS" -e "INPUT_TOKEN" -e "INPUT_MESSAGE" -e "INPUT_ADD_COMMENT" -e "INPUT_EXIT_TYPE" -e "INPUT_USE_REGEX" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_ENVIRONMENT" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e "ACTIONS_RESULTS_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/<redacted>":"/github/workspace" 3d374d:726b772f662246c0867d9716766ad730
(node:1) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Error: Not Found

Screenshot 2024-09-20 at 3 31 58 PM

Is there a way to enable additional logging, to get more details about what went wrong?

twyatt avatar Sep 20 '24 22:09 twyatt