fix: use GITHUB_RUN_NUMBER for Forgejo job URLs and pin Bun version in CI

Forgejo uses the per-repo sequential run index (GITHUB_RUN_NUMBER) in
action URLs, not the internal DB run ID (GITHUB_RUN_ID). This caused
"View job" links to return 404. Fixed in all 4 URL construction sites:
create-initial comment, update-comment-link, and both prompt generators.

Also pins Bun to 1.2.21 in CI — Bun 1.3.9 broke spyOn(fs, ...) which
failed 18 upstream image-downloader tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Vlad MocanuandClaude Opus 4.6 committed 2026-02-25 21:07:40 +02:00
1 parent 6ebfb4914f
commit 23f15aecb9
6 files changed
+109 -10

No files matched your search

+41
View File
@@ -1,6 +1,7 @@
import { describe, it, expect, beforeEach, afterEach } from "bun:test";
import {
FORGEJO_SPINNER_HTML,
getForgejoRunIndex,
createForgejoJobRunLink,
createForgejoBranchLink,
createForgejoPrCompareUrl,
@@ -37,6 +38,46 @@ describe("FORGEJO_SPINNER_HTML", () => {
});
});
// ---------------------------------------------------------------------------
// getForgejoRunIndex
// ---------------------------------------------------------------------------
describe("getForgejoRunIndex", () => {
const origRunNumber = process.env.GITHUB_RUN_NUMBER;
const origRunId = process.env.GITHUB_RUN_ID;
afterEach(() => {
if (origRunNumber !== undefined) {
process.env.GITHUB_RUN_NUMBER = origRunNumber;
} else {
delete process.env.GITHUB_RUN_NUMBER;
}
if (origRunId !== undefined) {
process.env.GITHUB_RUN_ID = origRunId;
} else {
delete process.env.GITHUB_RUN_ID;
}
});
it("prefers GITHUB_RUN_NUMBER over GITHUB_RUN_ID", () => {
process.env.GITHUB_RUN_NUMBER = "661";
process.env.GITHUB_RUN_ID = "11943";
expect(getForgejoRunIndex()).toBe("661");
});
it("falls back to GITHUB_RUN_ID when GITHUB_RUN_NUMBER is not set", () => {
delete process.env.GITHUB_RUN_NUMBER;
process.env.GITHUB_RUN_ID = "11943";
expect(getForgejoRunIndex()).toBe("11943");
});
it("returns '0' when neither env var is set", () => {
delete process.env.GITHUB_RUN_NUMBER;
delete process.env.GITHUB_RUN_ID;
expect(getForgejoRunIndex()).toBe("0");
});
});
// ---------------------------------------------------------------------------
// createForgejoJobRunLink
// ---------------------------------------------------------------------------