Skip to content

Commit

Permalink
feat: include release url in pr body
Browse files Browse the repository at this point in the history
  • Loading branch information
kormide committed Nov 6, 2023
1 parent c7b46e8 commit 3dffc30
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/application/release-event-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class ReleaseEventHandler {
event.payload.sender.login,
repository
);
const releaseUrl = event.payload.release.url;

const tag = event.payload.release.tag_name;

Expand Down Expand Up @@ -110,7 +111,8 @@ export class ReleaseEventHandler {
bcr,
branch,
releaser,
rulesetRepo.getModuleName(moduleRoot)
rulesetRepo.getModuleName(moduleRoot),
releaseUrl
);

console.log(`Created pull request against ${bcr.canonicalName}`);
Expand Down
45 changes: 41 additions & 4 deletions src/domain/publish-entry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ describe("sendRequest", () => {
bcr,
branch,
releaser,
"rules_foo"
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);

expect(mockGithubClient.createPullRequest).toHaveBeenCalledWith(
Expand Down Expand Up @@ -61,7 +62,8 @@ describe("sendRequest", () => {
bcr,
branch,
releaser,
"rules_foo"
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);

expect(mockGithubClient.createPullRequest).toHaveBeenCalledWith(
Expand Down Expand Up @@ -99,7 +101,8 @@ describe("sendRequest", () => {
bcr,
branch,
releaser,
"rules_foo"
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);

expect(mockGithubClient.createPullRequest).toHaveBeenCalledWith(
Expand All @@ -112,6 +115,39 @@ describe("sendRequest", () => {
);
});

test("incliudes 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}`
);

expect(mockGithubClient.createPullRequest).toHaveBeenCalledWith(
expect.any(Repository),
expect.any(String),
expect.any(Repository),
expect.any(String),
expect.any(String),
expect.stringContaining(
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
)
);
});

test("creates the created pull request number", async () => {
const bcrFork = new Repository("bazel-central-registry", "bar");
const bcr = new Repository("bazel-central-registry", "bazelbuild");
Expand All @@ -131,7 +167,8 @@ describe("sendRequest", () => {
bcr,
branch,
releaser,
"rules_foo"
"rules_foo",
`github.com/aspect-build/rules_foo/releases/tag/${tag}`
);

expect(pr).toEqual(4);
Expand Down
8 changes: 6 additions & 2 deletions src/domain/publish-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ export class PublishEntryService {
bcr: Repository,
branch: string,
releaser: User,
moduleName: string
moduleName: string,
releaseUrl: string
): Promise<number> {
const version = RulesetRepository.getVersionFromTag(tag);

const pr = await this.githubClient.createPullRequest(
bcrForkRepo,
branch,
bcr,
"main",
`${moduleName}@${version}`,
`\
Release author: @${releaser.username}.
Release: [${tag}](${releaseUrl})
Author: @${releaser.username}.
Automated by [Publish to BCR](https://github.com/apps/publish-to-bcr).`
);
Expand Down

0 comments on commit 3dffc30

Please sign in to comment.