nrwl/nx-set-shas

Error: `Failed to determine PR number` when using a merge queue on non-main branch

tom-sherman opened this issue · 2 comments

The regex that infers the PR number from the ref is slightly wrong, it assumes the merge queue is named the main branch. I believe this can be the case for a variety of reasons (custom merge groups) but for us it came up when using a merge group on a different branch other than main.

const result = new RegExp(`^refs/heads/gh-readonly-queue/${mainBranchName}/pr-(\\d+)-${base_sha}$`).exec(head_ref);

Our ref was gh-readonly-queue/some-branch-name/pr-108-shaXXX, the main branch was main. So the regex didn't match.

Maybe this data can be inferred via an API call or from the event payload?

This is not something we can infer automatically. We suggest to create a new workflow/job for different "main" branches.

@meeroslav is nx-set-shas supposed to work in general when merging into a non-main branch? It should just compare against main all the time right?

If so, I'd expect this same behaviour for merge queues.

My suggestion here is to improve the heuristic to handle this case - there have been some assumptions made about the merge queue that are incorrect.