Skip to content

wip: create PR that demonstrates bug #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 2
fetch-depth: 20
- name: Use Node.js
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
Expand All @@ -31,7 +31,7 @@ jobs:
- run: pnpm build
- run: pnpm lint
- run: pnpm format:check
- run: pnpm test:integration
- run: pnpm test:integration ghbug
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_OID: ${{ github.base_ref }}
77 changes: 77 additions & 0 deletions src/test/integration/ghbug.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { getOctokit } from "@actions/github";
import { promises as fs } from "fs";

import { ENV, REPO, ROOT_TEST_BRANCH_PREFIX } from "./env.js";
import { deleteBranches } from "./util.js";
import {
createRefMutation,
getRepositoryMetadata,
} from "../../github/graphql/queries.js";
import git from "isomorphic-git";

const octokit = getOctokit(ENV.GITHUB_TOKEN);

const TEST_BRANCH_PREFIX = `${ROOT_TEST_BRANCH_PREFIX}-ghbug`;

describe("demonstrate bug with", () => {
const branches: string[] = [];

// Set timeout to 1 minute
jest.setTimeout(60 * 1000);

let repositoryId: string;
let shas: string[] = [];

beforeAll(async () => {
const response = await getRepositoryMetadata(octokit, {
owner: REPO.owner,
name: REPO.repository,
baseRef: "HEAD",
targetRef: "HEAD",
});
if (!response?.id) {
throw new Error("Repository not found");
}
repositoryId = response.id;
// Get most recent 10 commits
const log = await git.log({ fs, dir: process.cwd(), depth: 10 });
shas = log.map((commit) => commit.oid);
console.log("SHAS", shas);
});

for (let i = 0; i < 10; i++) {
describe(`Create branches from HEAD~${i}`, () => {
it(`GraphQL: createRef mutation`, async () => {
const branch = `${TEST_BRANCH_PREFIX}-graphql-${i}`;
branches.push(branch);
// Create test directory

await createRefMutation(octokit, {
input: {
repositoryId,
name: `refs/heads/${branch}`,
oid: shas[i],
},
});
});

it(`REST: createRef mutation`, async () => {
const branch = `${TEST_BRANCH_PREFIX}-rest-${i}`;
branches.push(branch);
// Create test directory
await octokit.rest.git.createRef({
owner: REPO.owner,
repo: REPO.repository,
ref: `refs/heads/${branch}`,
sha: shas[i] ?? "",
});
});
});
}

afterAll(async () => {
console.info("Cleaning up test branches");

await deleteBranches(octokit, branches);
});
});
Loading