Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/dev-version-bump.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ jobs:
# leaves the branch check passing, so the job would recreate the branch and then
# fail on `gh pr create` with "already exists" — turning a successful release red
# for a repair that was already queued.
open_prs="$(gh pr list --base dev --head "${branch}" --state open --json number --jq 'length')"
# `--head` matches only the branch name, including identically named fork
# branches. Count only pull requests whose head belongs to this repository;
# otherwise a fork can pre-open the predictable branch and suppress the bump.
open_prs="$(gh pr list --base dev --head "${branch}" --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository == false)] | length')"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Paginate the filtered pull-request lookup

When an upstream bump PR is already open and at least 30 same-named fork PRs precede it in gh pr list's results, the upstream PR is truncated before this jq filter runs: gh pr list --help documents a default --limit of 30. The filter then reports zero upstream PRs and falls through to gh pr create, which fails because that upstream PR already exists, turning a rerun into a red release job. Request sufficient results (or paginate) before filtering.

Useful? React with 👍 / 👎.

if [ "${open_prs}" != "0" ]; then
echo "::notice::a bump pull request for ${branch} is already open; nothing to do"
exit 0
Expand Down
7 changes: 7 additions & 0 deletions tests/bump-dev-version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { decideDevVersion } from "../scripts/bump-dev-version";
*/

const CLI = new URL("../scripts/bump-dev-version.ts", import.meta.url).pathname;
const WORKFLOW = new URL("../.github/workflows/dev-version-bump.yml", import.meta.url).pathname;

function tempPackageJson(version: string): string {
const dir = mkdtempSync(join(tmpdir(), "ocx-bump-"));
Expand All @@ -32,6 +33,12 @@ function tempPackageJson(version: string): string {
}

describe("dev version bump rule", () => {
test("the idempotency check ignores same-named pull requests from forks", () => {
const workflow = readFileSync(WORKFLOW, "utf8");
expect(workflow).toContain("--json number,isCrossRepository");
expect(workflow).toContain("select(.isCrossRepository == false)");
});

test("a stable release moves dev to the next minor", () => {
// e4a85d134 (2.33.0 -> 2.34.0) and 076ad3036 (2.34.0 -> 2.35.0).
expect(decideDevVersion("2.36.0", "2.36.0")).toMatchObject({ changed: true, version: "2.37.0" });
Expand Down
Loading