Skip to content

Commit

Permalink
ci: notify via Slack on cherry-pick conflict during release (#7211)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhu authored Jun 26, 2023
1 parent 4e8ae39 commit 33d43ed
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/track-prs-for-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
private_key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- name: Handle merged PR
env:
CASPER_TOKEN: ${{ secrets.CASPER_TOKEN }}
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
PR_ID: ${{ github.event.pull_request.node_id }}
run: tools/scripts/track-pr pr-merged "$PR_ID"
Expand All @@ -51,6 +52,7 @@ jobs:
private_key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- name: Handle labeled PR
env:
CASPER_TOKEN: ${{ secrets.CASPER_TOKEN }}
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
PR_ID: ${{ github.event.pull_request.node_id }}
PR_LABEL: ${{ github.event.label.name }}
Expand Down
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
profile = black
skip_glob = **/__init__.py
default_section = THIRDPARTY
known_first_party = determined,tests
known_first_party = determined,tests,gql
line_length = 100
3 changes: 2 additions & 1 deletion tools/scripts/gql.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,12 @@ def __call__(self, **args: Any) -> Any:
"""
)

get_pr_merge_commit = GraphQLQuery(
get_pr_merge_commit_and_url = GraphQLQuery(
"""
query($id: ID!) {
node(id: $id) {
... on PullRequest {
url
mergeCommit {
oid
}
Expand Down
12 changes: 10 additions & 2 deletions tools/scripts/track-pr
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import subprocess
import sys
from typing import Callable, Optional

import requests

import gql

TEST = os.environ.get("RELEASE_TEST") == "1"
Expand All @@ -46,6 +48,7 @@ FIX_OPEN_STATUS = "Fix (open)"
FIX_CONFLICT_STATUS = "Fix (conflict)"

GITHUB_TOKEN = os.environ["GITHUB_TOKEN"]
CASPER_TOKEN = os.environ["CASPER_TOKEN"]


def run(*args, check=True, quiet=False, **kwargs):
Expand Down Expand Up @@ -117,7 +120,8 @@ def cherry_pick_pr(pr_id: str) -> None:
add_item_to_project(current_project_id(), pr_id, FIX_CONFLICT_STATUS)
return

pr_commit = gql.get_pr_merge_commit(id=pr_id)["node"]["mergeCommit"]["oid"]
pr = gql.get_pr_merge_commit_and_url(id=pr_id)["node"]
pr_commit = pr["mergeCommit"]["oid"]
print(f"Cherry-picking {pr_commit}")

try:
Expand Down Expand Up @@ -173,8 +177,12 @@ def cherry_pick_pr(pr_id: str) -> None:

traceback.print_exc()
print("Cherry-pick failed, adding PR as conflicted")
# TODO Notify a human.
add_item_to_project(current_project_id(), pr_id, FIX_CONFLICT_STATUS)
requests.post(
"https://casper.internal.infra.determined.ai/hubot/conflict",
headers={"X-Casper-Token": CASPER_TOKEN},
json={"url": pr["url"]},
)


class Actions:
Expand Down

0 comments on commit 33d43ed

Please sign in to comment.