Skip to content

Commit 389950c

Browse files
committed
wip: create PR that demonstrates bug
1 parent 52ea7a7 commit 389950c

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- run: pnpm build
3232
- run: pnpm lint
3333
- run: pnpm format:check
34-
- run: pnpm test:integration
34+
- run: pnpm test:integration ghbug
3535
env:
3636
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3737
HEAD_OID: ${{ github.base_ref }}

src/test/integration/ghbug.test.ts

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { getOctokit } from "@actions/github";
2+
import { promises as fs } from "fs";
3+
4+
import { ENV, REPO, ROOT_TEST_BRANCH_PREFIX } from "./env.js";
5+
import { deleteBranches } from "./util.js";
6+
import {
7+
createRefMutation,
8+
getRepositoryMetadata,
9+
} from "../../github/graphql/queries.js";
10+
import git from "isomorphic-git";
11+
12+
const octokit = getOctokit(ENV.GITHUB_TOKEN);
13+
14+
const TEST_BRANCH_PREFIX = `${ROOT_TEST_BRANCH_PREFIX}-ghbug`;
15+
16+
describe("demonstrate bug with", () => {
17+
const branches: string[] = [];
18+
19+
// Set timeout to 1 minute
20+
jest.setTimeout(60 * 1000);
21+
22+
let repositoryId: string;
23+
let shas: string[] = [];
24+
25+
beforeAll(async () => {
26+
const response = await getRepositoryMetadata(octokit, {
27+
owner: REPO.owner,
28+
name: REPO.repository,
29+
baseRef: "HEAD",
30+
targetRef: "HEAD",
31+
});
32+
if (!response?.id) {
33+
throw new Error("Repository not found");
34+
}
35+
repositoryId = response.id;
36+
// Get most recent 10 commits
37+
const log = await git.log({ fs, dir: process.cwd(), depth: 10 });
38+
shas = log.map((commit) => commit.oid);
39+
});
40+
41+
for (let i = 0; i < 10; i++) {
42+
describe(`Create branches from HEAD~${i}`, () => {
43+
it(`GraphQL: createRef mutation`, async () => {
44+
const branch = `${TEST_BRANCH_PREFIX}-graphql-${i}`;
45+
branches.push(branch);
46+
// Create test directory
47+
48+
await createRefMutation(octokit, {
49+
input: {
50+
repositoryId,
51+
name: `refs/heads/${branch}`,
52+
oid: shas[i],
53+
},
54+
});
55+
});
56+
57+
it(`REST: createRef mutation`, async () => {
58+
const branch = `${TEST_BRANCH_PREFIX}-rest-${i}`;
59+
branches.push(branch);
60+
// Create test directory
61+
await octokit.rest.git.createRef({
62+
owner: REPO.owner,
63+
repo: REPO.repository,
64+
ref: `refs/heads/${branch}`,
65+
sha: shas[i] ?? "",
66+
});
67+
});
68+
});
69+
}
70+
71+
afterAll(async () => {
72+
console.info("Cleaning up test branches");
73+
74+
await deleteBranches(octokit, branches);
75+
});
76+
});

0 commit comments

Comments
 (0)