Skip to content
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

feat: include release url in pr body #78

Merged
merged 1 commit into from
Nov 6, 2023
Merged
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: 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: "[email protected]",
};

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