Skip to content
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
9 changes: 9 additions & 0 deletions .github/workflows/release_create_release_branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ jobs:
create-release-branch --issue ${{ github.event.issue.number }} --remote origin
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# A no-op job that always runs to prevent "no jobs ran" failures
# when the main job is skipped.
suppress-no-jobs-ran-error:
runs-on: ubuntu-latest
steps:
- name: Echo Success
run: echo "Success"

52 changes: 44 additions & 8 deletions tests/tools/private/release/create_rc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,56 @@ def test_create_rc_success_first_rc(self):
"**New Release Candidate Tagged!** 🐍🌿",
comment_call_args[1],
)
self.assertIn(
"tagged on branch [`release/2.0`](https://github.com/bazel-contrib/rules_python/tree/release/2.0)",
comment_call_args[1],
)
self.assertIn(
"- [Github Release 2.0.0-rc0](https://github.com/bazel-contrib/rules_python/releases/tag/2.0.0-rc0)",
comment_call_args[1],
)
self.assertIn(
"- BCR Entry: [rules_python@2.0.0](https://registry.bazel.build/modules/rules_python/2.0.0)",
"- [BCR Entry 2.0.0-rc0](https://registry.bazel.build/modules/rules_python/2.0.0-rc0)",
comment_call_args[1],
)
self.assertIn(
"- [BCR PRs](https://github.com/bazelbuild/bazel-central-registry/pulls?q=is%3Apr+rules_python+2.0.0)",
"- [BCR PRs](https://github.com/bazelbuild/bazel-central-registry/pulls?q=is%3Apr+rules_python+2.0.0-rc0)",
comment_call_args[1],
)
self.assertIn(
"- [Release workflow status](https://github.com/bazel-contrib/rules_python/actions/workflows/release_publish.yaml)",
"- [Release workflow status](https://github.com/bazel-contrib/rules_python/actions/workflows/release_create_rc.yaml)",
comment_call_args[1],
)

def test_create_rc_success_with_run_id(self):
# Arrange
args = MagicMock(issue=123, remote="my-remote")
self.mock_gh.get_issue_title.return_value = "Release 2.0.0"
self.mock_gh.get_issue_body.return_value = """
## Checklist
- [x] Prepare Release | status=done pr=#122 commit=abcdef12
- [x] Create Release branch | status=done branch=release/2.0 commit=abcdef12
- [ ] Tag RC0 | status=pending
"""
self.mock_git.get_remote_tags.return_value = []
self.mock_git.get_commit_sha.return_value = "1234567890"

# Act
with patch.dict(os.environ, {"GITHUB_RUN_ID": "987654321"}):
Comment thread
rickeylev marked this conversation as resolved.
result = CreateRc(args, self.mock_git, self.mock_gh).run()

# Assert
self.assertEqual(result, 0)
self.mock_gh.post_issue_comment.assert_called_once()
comment_call_args = self.mock_gh.post_issue_comment.call_args[0]
self.assertIn(
"- [Release workflow status](https://github.com/bazel-contrib/rules_python/actions/runs/987654321)",
comment_call_args[1],
)
self.assertIn(
"tagged on branch [`release/2.0`](https://github.com/bazel-contrib/rules_python/tree/release/2.0)",
comment_call_args[1],
)
self.assertNotIn("🚀", comment_call_args[1])

def test_create_rc_success_next_rc(self):
# Arrange
Expand Down Expand Up @@ -113,23 +146,26 @@ def test_create_rc_success_next_rc(self):
"**New Release Candidate Tagged!** 🐍🌿",
comment_call_args[1],
)
self.assertIn(
"tagged on branch [`release/2.0`](https://github.com/bazel-contrib/rules_python/tree/release/2.0)",
comment_call_args[1],
)
self.assertIn(
"- [Github Release 2.0.0-rc1](https://github.com/bazel-contrib/rules_python/releases/tag/2.0.0-rc1)",
comment_call_args[1],
)
self.assertIn(
"- BCR Entry: [rules_python@2.0.0](https://registry.bazel.build/modules/rules_python/2.0.0)",
"- [BCR Entry 2.0.0-rc1](https://registry.bazel.build/modules/rules_python/2.0.0-rc1)",
comment_call_args[1],
)
self.assertIn(
"- [BCR PRs](https://github.com/bazelbuild/bazel-central-registry/pulls?q=is%3Apr+rules_python+2.0.0)",
"- [BCR PRs](https://github.com/bazelbuild/bazel-central-registry/pulls?q=is%3Apr+rules_python+2.0.0-rc1)",
comment_call_args[1],
)
self.assertIn(
"- [Release workflow status](https://github.com/bazel-contrib/rules_python/actions/workflows/release_publish.yaml)",
"- [Release workflow status](https://github.com/bazel-contrib/rules_python/actions/workflows/release_create_rc.yaml)",
comment_call_args[1],
)
self.assertNotIn("🚀", comment_call_args[1])

def test_create_rc_gating_on_backports(self):
# Arrange
Expand Down
16 changes: 11 additions & 5 deletions tools/private/release/create_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,21 @@ def run(self) -> int:
self.gh.update_issue_body(args.issue, updated_body)

tag_url = f"{REPO_URL}/releases/tag/{next_rc}"
bcr_entry_url = f"https://registry.bazel.build/modules/rules_python/{version}"
bcr_search_url = f"https://github.com/bazelbuild/bazel-central-registry/pulls?q=is%3Apr+rules_python+{version}"
release_workflow_url = f"{REPO_URL}/actions/workflows/release_publish.yaml"
bcr_entry_url = f"https://registry.bazel.build/modules/rules_python/{next_rc}"
bcr_search_url = f"https://github.com/bazelbuild/bazel-central-registry/pulls?q=is%3Apr+rules_python+{next_rc}"
if run_id := os.environ.get("GITHUB_RUN_ID"):
Comment thread
rickeylev marked this conversation as resolved.
release_workflow_url = f"{REPO_URL}/actions/runs/{run_id}"
else:
release_workflow_url = (
f"{REPO_URL}/actions/workflows/release_create_rc.yaml"
)
branch_url = f"{REPO_URL}/tree/{branch_name}"
comment_body = f"""**New Release Candidate Tagged!** 🐍🌿

Release Candidate **{next_rc}** has been successfully generated and tagged on branch `{branch_name}`.
Release Candidate **{next_rc}** has been successfully generated and tagged on branch [`{branch_name}`]({branch_url}).

- [Github Release {next_rc}]({tag_url})
- BCR Entry: [rules_python@{version}]({bcr_entry_url})
- [BCR Entry {next_rc}]({bcr_entry_url})
- [BCR PRs]({bcr_search_url})
- [Release workflow status]({release_workflow_url})"""
self.gh.post_issue_comment(args.issue, comment_body)
Expand Down