From e679dc7c9408ac9d068ff4ffc296a12e4e1e1d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Fri, 15 May 2026 08:33:45 +0200 Subject: [PATCH 1/4] Test rest commits --- src/test/integration/node.test.ts | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/test/integration/node.test.ts b/src/test/integration/node.test.ts index 304bfa3..abb1f8f 100644 --- a/src/test/integration/node.test.ts +++ b/src/test/integration/node.test.ts @@ -263,6 +263,57 @@ describe("node", () => { }); }); + it("can create a commit using the REST git API", async () => { + const branch = `${TEST_BRANCH_PREFIX}-rest-git-${Date.now()}`; + const filePath = "rest-git-api-test.txt"; + + const baseRef = await octokit.rest.git.getRef({ + ...REPO, + ref: "heads/main", + }); + const baseOid = baseRef.data.object.sha; + + const baseCommit = await octokit.rest.git.getCommit({ + ...REPO, + commit_sha: baseOid, + }); + + const tree = await octokit.rest.git.createTree({ + ...REPO, + base_tree: baseCommit.data.tree.sha, + tree: [ + { + path: filePath, + mode: "100644", + type: "blob", + content: "Hello from the REST git API!\n", + }, + ], + }); + + const commit = await octokit.rest.git.createCommit({ + ...REPO, + message: "Test REST git commit", + tree: tree.data.sha, + parents: [baseOid], + }); + + await octokit.rest.git.createRef({ + ...REPO, + ref: `refs/heads/${branch}`, + sha: commit.data.sha, + }); + + await waitForGitHubToBeReady(); + + const branchRef = await octokit.rest.git.getRef({ + ...REPO, + ref: `heads/${branch}`, + }); + + expect(branchRef.data.object.sha).toEqual(commit.data.sha); + }); + describe("existing branches", () => { it("can commit to existing branch when force is true", async () => { const branch = `${TEST_BRANCH_PREFIX}-existing-branch-force`; From a269b8edd1f13cdc2b4b8b8d82eb7b8e5e0131e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Fri, 15 May 2026 08:59:18 +0200 Subject: [PATCH 2/4] Test graphql too --- src/test/integration/node.test.ts | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/test/integration/node.test.ts b/src/test/integration/node.test.ts index abb1f8f..603cd20 100644 --- a/src/test/integration/node.test.ts +++ b/src/test/integration/node.test.ts @@ -314,6 +314,42 @@ describe("node", () => { expect(branchRef.data.object.sha).toEqual(commit.data.sha); }); + it("can create a commit using the GraphQL commit path", async () => { + const branch = `${TEST_BRANCH_PREFIX}-graphql-git-${Date.now()}`; + const filePath = "graphql-git-api-test.txt"; + + await commitFilesFromBuffers({ + octokit, + ...REPO, + branch, + base: { + branch: "main", + }, + message: { + headline: "Test GraphQL git commit", + body: "Created through commitFilesFromBuffers", + }, + fileChanges: { + additions: [ + { + path: filePath, + contents: Buffer.from("Hello from the GraphQL commit path!\n"), + }, + ], + }, + log, + }); + + await waitForGitHubToBeReady(); + + const branchRef = await octokit.rest.git.getRef({ + ...REPO, + ref: `heads/${branch}`, + }); + + expect(branchRef.data.object.sha).toBeTruthy(); + }); + describe("existing branches", () => { it("can commit to existing branch when force is true", async () => { const branch = `${TEST_BRANCH_PREFIX}-existing-branch-force`; From 93bb6b1c5c3baf29ba4ebb0e9fab3172e49433d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Fri, 15 May 2026 11:28:39 +0200 Subject: [PATCH 3/4] try to open PRs --- src/test/integration/node.test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/test/integration/node.test.ts b/src/test/integration/node.test.ts index 603cd20..9d8e6cf 100644 --- a/src/test/integration/node.test.ts +++ b/src/test/integration/node.test.ts @@ -93,6 +93,21 @@ describe("node", () => { } }; + const createPullRequestForBranch = async (branch: string, title: string) => { + const pullRequest = await octokit.rest.pulls.create({ + ...REPO, + title, + head: branch, + base: "main", + body: `CI-created integration test PR for \`${branch}\`.`, + }); + + expect(pullRequest.data.state).toEqual("open"); + expect(pullRequest.data.head.ref).toEqual(branch); + + return pullRequest.data.html_url; + }; + let testTargetCommit: string; /** * For tests, important that this commit is not an ancestor of TEST_TARGET_COMMIT, @@ -312,6 +327,13 @@ describe("node", () => { }); expect(branchRef.data.object.sha).toEqual(commit.data.sha); + + const pullRequestUrl = await createPullRequestForBranch( + branch, + `test: REST git API branch ${branch}`, + ); + + expect(pullRequestUrl).toContain(`/pull/`); }); it("can create a commit using the GraphQL commit path", async () => { @@ -348,6 +370,13 @@ describe("node", () => { }); expect(branchRef.data.object.sha).toBeTruthy(); + + const pullRequestUrl = await createPullRequestForBranch( + branch, + `test: GraphQL commit path branch ${branch}`, + ); + + expect(pullRequestUrl).toContain(`/pull/`); }); describe("existing branches", () => { From 4ec6ce7881c8f65427a8f0483f53d0114d6397b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Fri, 15 May 2026 11:33:38 +0200 Subject: [PATCH 4/4] add missing perm --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a852dcc..afdb74c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: permissions: contents: write + pull-requests: write jobs: ci-checks: