Skip to content

Commit d8bc225

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

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
1616
with:
17-
fetch-depth: 2
17+
fetch-depth: 20
1818
- name: Use Node.js
1919
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
2020
with:
@@ -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

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
console.log("SHAS", shas);
40+
});
41+
42+
for (let i = 0; i < 10; i++) {
43+
describe(`Create branches from HEAD~${i}`, () => {
44+
it(`GraphQL: createRef mutation`, async () => {
45+
const branch = `${TEST_BRANCH_PREFIX}-graphql-${i}`;
46+
branches.push(branch);
47+
// Create test directory
48+
49+
await createRefMutation(octokit, {
50+
input: {
51+
repositoryId,
52+
name: `refs/heads/${branch}`,
53+
oid: shas[i],
54+
},
55+
});
56+
});
57+
58+
it(`REST: createRef mutation`, async () => {
59+
const branch = `${TEST_BRANCH_PREFIX}-rest-${i}`;
60+
branches.push(branch);
61+
// Create test directory
62+
await octokit.rest.git.createRef({
63+
owner: REPO.owner,
64+
repo: REPO.repository,
65+
ref: `refs/heads/${branch}`,
66+
sha: shas[i] ?? "",
67+
});
68+
});
69+
});
70+
}
71+
72+
afterAll(async () => {
73+
console.info("Cleaning up test branches");
74+
75+
await deleteBranches(octokit, branches);
76+
});
77+
});

0 commit comments

Comments
 (0)