diff --git a/.env.example b/.env.example index f3a5f4a..fe1c27d 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,6 @@ # needed got pnpm test:ci GITHUB_TOKEN='<...some token>' -GITHUB_REPOSITORY=s0/ghcommit +GITHUB_REPOSITORY=changesets/ghcommit # Debug Logging # RUNNER_DEBUG=1 \ No newline at end of file diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bbb98e4..62e323f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,7 +23,7 @@ jobs: run: | VERSION=$(cat package.json | grep '"packageManager": "pnpm@' | sed 's/.*"pnpm@\([^"]*\)".*/\1/') npm install -g pnpm@$VERSION - - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v 4.0.2 + - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v 4.2.3 with: path: ~/.pnpm-store key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} diff --git a/.github/workflows/release-and-publish.yaml b/.github/workflows/release-and-publish.yaml index 68a1958..6bc90ea 100644 --- a/.github/workflows/release-and-publish.yaml +++ b/.github/workflows/release-and-publish.yaml @@ -28,7 +28,7 @@ jobs: VERSION=$(cat package.json | grep '"packageManager": "pnpm@' | sed 's/.*"pnpm@\([^"]*\)".*/\1/') npm install -g pnpm@$VERSION - name: Cache pnpm modules - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v 4.0.2 + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v 4.2.3 with: path: ~/.pnpm-store key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 72a45d8..ede8505 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# @changesets/ghcommit + +## 1.3.0 + +### Minor Changes + +- 1324104: Migrating package to @changesets namespace + + Ownership of the repository has moved from https://github.com/s0/ghcommit + to https://github.com/changesets/ghcommit. As part of this we're also moving the + NPM package to the @changesets namespace. No functional changes have happened, + so this can be a drop-in replacement for `@s0/ghcommit`. + # @s0/ghcommit ## 1.2.1 diff --git a/README.md b/README.md index 20c77f7..d2b82ac 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# `@s0/ghcommit` +# `@changesets/ghcommit` -[![View on NPM](https://badgen.net/npm/v/@s0/ghcommit)](https://www.npmjs.com/package/@s0/ghcommit) +[![View on NPM](https://badgen.net/npm/v/@changesets/ghcommit)](https://www.npmjs.com/package/@changesets/ghcommit) NPM / TypeScript package to commit changes GitHub repositories using the GraphQL API. @@ -32,7 +32,7 @@ NPM / TypeScript package to commit changes GitHub repositories using the GraphQL Install using your favourite package manager: ``` -pnpm install @s0/ghcommit +pnpm install @changesets/ghcommit ``` ### Usage in github actions @@ -103,7 +103,7 @@ Example: ```ts import { context, getOctokit } from "@actions/github"; -import { commitChangesFromRepo } from "@s0/ghcommit/git"; +import { commitChangesFromRepo } from "@changesets/ghcommit/git"; const octokit = getOctokit(process.env.GITHUB_TOKEN); @@ -179,7 +179,7 @@ Example: ```ts import { context, getOctokit } from "@actions/github"; -import { commitFilesFromDirectory } from "@s0/ghcommit/fs"; +import { commitFilesFromDirectory } from "@changesets/ghcommit/fs"; const octokit = getOctokit(process.env.GITHUB_TOKEN); @@ -245,7 +245,7 @@ Example: ```ts import { context, getOctokit } from "@actions/github"; -import { commitFilesFromBuffers } from "@s0/ghcommit/node"; +import { commitFilesFromBuffers } from "@changesets/ghcommit/node"; const octokit = getOctokit(process.env.GITHUB_TOKEN); diff --git a/SECURITY.md b/SECURITY.md index 7ba3d11..7c9e960 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -8,4 +8,4 @@ ## Reporting a Vulnerability -Please select "Report a Vulnerability" on the [Security Tab](https://github.com/s0/ghcommit/security). We will investigate all legitimate reports and do our best to quickly fix the problem. +Please select "Report a Vulnerability" on the [Security Tab](https://github.com/changesets/ghcommit/security). We will investigate all legitimate reports and do our best to quickly fix the problem. diff --git a/package.json b/package.json index ceacea3..60c123b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "@s0/ghcommit", - "version": "1.2.1", + "name": "@changesets/ghcommit", + "version": "1.3.0", "private": false, "description": "Directly change files on github using the github API, to support GPG signing", "keywords": [ @@ -16,7 +16,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/s0/ghcommit.git" + "url": "https://github.com/changesets/ghcommit.git" }, "exports": { ".": { diff --git a/src/test/integration/git.test.ts b/src/test/integration/git.test.ts index c8f983a..e9bbd84 100644 --- a/src/test/integration/git.test.ts +++ b/src/test/integration/git.test.ts @@ -11,7 +11,7 @@ import { execFile } from "child_process"; import { getOctokit } from "@actions/github"; import { commitChangesFromRepo } from "../../git"; import { getRefTreeQuery } from "../../github/graphql/queries"; -import { deleteBranches } from "./util"; +import { deleteBranches, waitForGitHubToBeReady } from "./util"; import git from "isomorphic-git"; const octokit = getOctokit(ENV.GITHUB_TOKEN); @@ -194,6 +194,8 @@ describe("git", () => { log, }); + await waitForGitHubToBeReady(); + await makeFileChangeAssertions(branch); // Expect the OID to be the HEAD commit @@ -263,6 +265,8 @@ describe("git", () => { }, }); + await waitForGitHubToBeReady(); + await makeFileChangeAssertions(branch); await expectParentHasOid({ branch, oid }); diff --git a/src/test/integration/node.test.ts b/src/test/integration/node.test.ts index ed9fcbd..1ecb1e6 100644 --- a/src/test/integration/node.test.ts +++ b/src/test/integration/node.test.ts @@ -3,7 +3,7 @@ import { getOctokit } from "@actions/github"; import { ENV, REPO, ROOT_TEST_BRANCH_PREFIX, log } from "./env.js"; import { commitFilesFromBuffers } from "../../node.js"; -import { deleteBranches } from "./util.js"; +import { deleteBranches, waitForGitHubToBeReady } from "./util.js"; import { createRefMutation, getRefTreeQuery, @@ -169,6 +169,8 @@ describe("node", () => { log, }); + await waitForGitHubToBeReady(); + await expectBranchHasTree({ branch, // TODO: re-enable @@ -196,6 +198,8 @@ describe("node", () => { ...BASIC_FILE_CONTENTS, }); + await waitForGitHubToBeReady(); + // Don't test tree for this one as it will change over time / be unstable await expectBranchHasTree({ branch, @@ -220,6 +224,8 @@ describe("node", () => { ...BASIC_FILE_CONTENTS, }); + await waitForGitHubToBeReady(); + // Don't test tree for this one as it will change over time / be unstable await expectBranchHasTree({ branch, @@ -244,6 +250,8 @@ describe("node", () => { ...BASIC_FILE_CONTENTS, }); + await waitForGitHubToBeReady(); + await expectBranchHasTree({ branch, // TODO: re-enable @@ -280,6 +288,8 @@ describe("node", () => { force: true, }); + await waitForGitHubToBeReady(); + await expectBranchHasTree({ branch, // TODO: re-enable @@ -304,6 +314,8 @@ describe("node", () => { }, }); + await waitForGitHubToBeReady(); + expect(() => commitFilesFromBuffers({ octokit, @@ -337,6 +349,8 @@ describe("node", () => { }, }); + await waitForGitHubToBeReady(); + await commitFilesFromBuffers({ octokit, ...REPO, @@ -347,6 +361,8 @@ describe("node", () => { ...BASIC_FILE_CONTENTS, }); + await waitForGitHubToBeReady(); + await expectBranchHasTree({ branch, // TODO: re-enable @@ -371,6 +387,8 @@ describe("node", () => { }, }); + await waitForGitHubToBeReady(); + await commitFilesFromBuffers({ octokit, ...REPO, @@ -381,6 +399,8 @@ describe("node", () => { ...BASIC_FILE_CONTENTS, }); + await waitForGitHubToBeReady(); + await expectBranchHasTree({ branch, // TODO: re-enable @@ -414,6 +434,8 @@ describe("node", () => { message: input, }); + await waitForGitHubToBeReady(); + const ref = ( await getRefTreeQuery(octokit, { ...REPO, diff --git a/src/test/integration/util.ts b/src/test/integration/util.ts index 918a9c1..2023bc0 100644 --- a/src/test/integration/util.ts +++ b/src/test/integration/util.ts @@ -35,3 +35,16 @@ export const deleteBranches = async ( console.debug(`Deleted branch ${branch}`); }), ); + +/** + * GitHub sometimes has a delay between making changes to a git repo, + * and those changes being reflected in the API. + * + * This function is a workaround to wait for GitHub to be ready + * before running these assertions. + * + * It slows down testing a bit, + * but it's better than having flaky tests. + */ +export const waitForGitHubToBeReady = () => + new Promise((r) => setTimeout(r, 5000));