Skip to content

Commit

Permalink
feat: stop tagging author and maintainers in pr body (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide authored Mar 9, 2024
1 parent 836d047 commit ffd6f39
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 150 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Prepare your ruleset for bzlmod by following the [Bzlmod User Guide](https://baz
_Note: Authors of rulesets under the `bazelbuild` org should add the app to their personal fork of `bazelbuild/bazel-central-registry`._

1. Include these [template files](./templates) in your ruleset repository.
1. Cut a release. You will be tagged in a pull request against the BCR.
1. Cut a release. A pull request like [this](https://github.com/bazelbuild/bazel-central-registry/pull/1601) will be opened against the BCR.

## Publishing multiple modules in the same repo

Expand Down
4 changes: 0 additions & 4 deletions e2e/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,6 @@ describe("e2e tests", () => {
})
);

// PR body tags releaser and maintainer
expect(body.body).toEqual(expect.stringContaining(`@${releaser.login}`));
expect(body.body).toEqual(expect.stringContaining(`@foobar`));

// PR body has a link to the github release
expect(body.body).toEqual(
expect.stringContaining(
Expand Down
2 changes: 0 additions & 2 deletions src/application/release-event-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ export class ReleaseEventHandler {
bcrFork,
bcr,
branch,
releaser,
rulesetRepo.metadataTemplate(moduleRoot).maintainers,
rulesetRepo.getModuleName(moduleRoot),
releaseUrl
);
Expand Down
129 changes: 1 addition & 128 deletions src/domain/publish-entry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ describe("sendRequest", () => {
const bcr = new Repository("bazel-central-registry", "bazelbuild");
const branch = "branch_with_entry";
const tag = "v1.0.0";
const releaser = {
name: "Json Bearded",
username: "json",
email: "jason@foo.org",
};

await publishEntryService.sendRequest(
tag,
bcrFork,
bcr,
branch,
releaser,
[],
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);
Expand All @@ -51,19 +44,12 @@ describe("sendRequest", () => {
const bcr = new Repository("bazel-central-registry", "bazelbuild");
const branch = "branch_with_entry";
const tag = "v1.0.0";
const releaser = {
name: "Json Bearded",
username: "json",
email: "jason@foo.org",
};

await publishEntryService.sendRequest(
tag,
bcrFork,
bcr,
branch,
releaser,
[],
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);
Expand All @@ -86,56 +72,17 @@ describe("sendRequest", () => {
);
});

test("tags the releaser in the body", async () => {
const bcrFork = new Repository("bazel-central-registry", "bar");
const bcr = new Repository("bazel-central-registry", "bazelbuild");
const branch = "branch_with_entry";
const tag = "v1.0.0";
const releaser = {
name: "Json Bearded",
username: "json",
email: "jason@foo.org",
};

await publishEntryService.sendRequest(
tag,
bcrFork,
bcr,
branch,
releaser,
[],
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);

expect(mockGithubClient.createPullRequest).toHaveBeenCalledWith(
expect.any(Repository),
expect.any(String),
expect.any(Repository),
expect.any(String),
expect.any(String),
expect.stringContaining(`@${releaser.username}`)
);
});

test("includes the release url in the body", async () => {
const bcrFork = new Repository("bazel-central-registry", "bar");
const bcr = new Repository("bazel-central-registry", "bazelbuild");
const branch = "branch_with_entry";
const tag = "v1.0.0";
const releaser = {
name: "Json Bearded",
username: "json",
email: "jason@foo.org",
};

await publishEntryService.sendRequest(
tag,
bcrFork,
bcr,
branch,
releaser,
[],
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);
Expand All @@ -152,83 +99,11 @@ describe("sendRequest", () => {
);
});

test("tags all maintainers with github handles in the body", async () => {
const bcrFork = new Repository("bazel-central-registry", "bar");
const bcr = new Repository("bazel-central-registry", "bazelbuild");
const branch = "branch_with_entry";
const tag = "v1.0.0";
const releaser = {
name: "Json Bearded",
username: "json",
email: "jason@foo.org",
};
const maintainers = [
{ name: "M1", github: "m1" },
{ name: "M2", email: "m2@foo-maintainer.org" },
{ name: "M3", github: "m3", email: "m3@foo-maintainer.org" },
{ name: "M4" },
];

await publishEntryService.sendRequest(
tag,
bcrFork,
bcr,
branch,
releaser,
maintainers,
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);

const body = mockGithubClient.createPullRequest.mock.calls[0][5];
expect(body.includes("@m1")).toEqual(true);
expect(body.includes("@m2")).toEqual(false);
expect(body.includes("@m3")).toEqual(true);
expect(body.includes("@m4")).toEqual(false);
});

test("does not double tag the release author if they are also a maintainer", async () => {
const bcrFork = new Repository("bazel-central-registry", "bar");
const bcr = new Repository("bazel-central-registry", "bazelbuild");
const branch = "branch_with_entry";
const tag = "v1.0.0";
const releaser = {
name: "Json Bearded",
username: "json",
email: "jason@foo.org",
};
const maintainers = [
{ name: "M1", github: "m1" },
{ name: releaser.name, github: releaser.username },
];

await publishEntryService.sendRequest(
tag,
bcrFork,
bcr,
branch,
releaser,
maintainers,
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);

const body = mockGithubClient.createPullRequest.mock.calls[0][5];
expect(
(body.match(new RegExp(`@${releaser.username}`, "gm")) || []).length
).toEqual(1);
});

test("creates the created pull request number", async () => {
test("returns the created pull request number", async () => {
const bcrFork = new Repository("bazel-central-registry", "bar");
const bcr = new Repository("bazel-central-registry", "bazelbuild");
const branch = "branch_with_entry";
const tag = "v1.0.0";
const releaser = {
name: "Json Bearded",
username: "json",
email: "jason@foo.org",
};

mockGithubClient.createPullRequest.mockResolvedValueOnce(4);

Expand All @@ -237,8 +112,6 @@ describe("sendRequest", () => {
bcrFork,
bcr,
branch,
releaser,
[],
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);
Expand Down
14 changes: 0 additions & 14 deletions src/domain/publish-entry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { GitHubClient } from "../infrastructure/github.js";
import { Maintainer } from "./metadata-file.js";
import { Repository } from "./repository.js";
import { RulesetRepository } from "./ruleset-repository.js";
import { User } from "./user.js";

export class PublishEntryService {
constructor(private readonly githubClient: GitHubClient) {}
Expand All @@ -12,19 +10,11 @@ export class PublishEntryService {
bcrForkRepo: Repository,
bcr: Repository,
branch: string,
releaser: User,
maintainers: ReadonlyArray<Maintainer>,
moduleName: string,
releaseUrl: string
): Promise<number> {
const version = RulesetRepository.getVersionFromTag(tag);

// Only tag maintainers that have a github handle, which is optional:
// See: https://docs.google.com/document/d/1moQfNcEIttsk6vYanNKIy3ZuK53hQUFq1b1r0rmsYVg/edit#bookmark=id.1i90c6c14zvx
const maintainersToTag = maintainers
.filter((m) => !!m.github && m.github !== releaser.username)
.map((m) => `@${m.github}`);

const pr = await this.githubClient.createPullRequest(
bcrForkRepo,
branch,
Expand All @@ -34,10 +24,6 @@ export class PublishEntryService {
`\
Release: ${releaseUrl}
Author: @${releaser.username}
${maintainersToTag.length > 0 ? "fyi: " + maintainersToTag.join(", ") : ""}
_Automated by [Publish to BCR](https://github.com/apps/publish-to-bcr)_`
);

Expand Down
2 changes: 1 addition & 1 deletion templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For more information about the files that make up a BCR entry, see the [Bzlmod U
Insert your ruleset's homepage and fill out the list of maintainers. Replace `OWNER/REPO` with your repository's
canonical name. Leave `versions` alone as this will be filled automatically.

_Note_: Maintainers will be emailed if any releases fail and will be tagged on the BCR pull request.
_Note_: Maintainers will be emailed if a release fails.

```jsonc
{
Expand Down

0 comments on commit ffd6f39

Please sign in to comment.