-
Notifications
You must be signed in to change notification settings - Fork 17
fix: replace on-call reviewer assignment with Slack notification + last-reviewer #307
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
45e015b
fix: replace on-call reviewer assignment with Slack notification + la…
dannyneira 9096f52
fix: use #oncall-client (C06MT1NRBFV) for Slack PR notifications
dannyneira ec4de18
fix: also mention @oncall-client-secondary in Slack notification
dannyneira 3ac39df
fix: rename SLACK_BOT_TOKEN to DOCS_SLACK_BOT_TOKEN
dannyneira 2807b89
fix: remove resolve_oncall_reviewers.py (no longer used)
dannyneira cc0687b
fix: address review comments — sys import, pr_url, gh api GET, iterat…
dannyneira 7ea12e3
Merge branch 'main' into fix/release-docs-slack-reviewer-assignment
dannyneira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,11 +35,9 @@ They support the following: | |
| - **Auth**: `gh auth status` must be healthy in the run environment. | ||
| - **GitHub repo write access** for branch push + PR create/update. | ||
|
|
||
| ### Required for on-call reviewer assignment | ||
| ### Required for Slack PR notification | ||
|
|
||
| - Resolver script path (default): | ||
| `.agents/skills/release_updates/scripts/resolve_oncall_reviewers.py` | ||
| - `DOCS_AGENT_GRAFANA_TOKEN` environment variable. | ||
| - `DOCS_SLACK_BOT_TOKEN` environment variable (Oz team secret — add to the docs agent environment). | ||
|
|
||
| ### Recommended | ||
|
|
||
|
|
@@ -171,37 +169,48 @@ python3 .agents/skills/release_updates/scripts/run_release_updates.py \ | |
| --pr-body-file /tmp/release-pr-body.md | ||
| ``` | ||
|
|
||
| ### Assign primary and secondary client on-call as reviewers (Grafana schedules) | ||
|
|
||
| To resolve and assign both reviewers automatically, pass both schedules: | ||
|
|
||
| ```bash | ||
| python3 .agents/skills/release_updates/scripts/run_release_updates.py \ | ||
| --create-pr \ | ||
| --assign-oncall-reviewer \ | ||
| --oncall-schedule-id CLIENT_PRIMARY_SCHEDULE_ID \ | ||
| --oncall-schedule-id CLIENT_SECONDARY_SCHEDULE_ID | ||
| ### Post Slack notification after creating a PR | ||
|
|
||
| After the PR is created, post a notification to the `#oncall-client` Slack channel (`C06MT1NRBFV`): | ||
|
|
||
| ```python | ||
| import json, os, sys, urllib.request | ||
|
|
||
| # pr_url: obtain from the PR created in the previous step, e.g.: | ||
| # pr_url = subprocess.check_output(['gh', 'pr', 'view', '--json', 'url', '--jq', '.url'], text=True).strip() | ||
| token = os.environ.get('DOCS_SLACK_BOT_TOKEN') | ||
| channel = 'C06MT1NRBFV' # #oncall-client | ||
| if not token: | ||
| print('DOCS_SLACK_BOT_TOKEN not set — skipping Slack notification') | ||
| else: | ||
| # Resolve the oncall-client-primary and oncall-client-secondary user group IDs | ||
| req = urllib.request.Request( | ||
| 'https://slack.com/api/usergroups.list', | ||
| headers={'Authorization': f'Bearer {token}'} | ||
| ) | ||
| with urllib.request.urlopen(req) as resp: | ||
| groups = json.loads(resp.read()).get('usergroups', []) | ||
| primary_id = next((g['id'] for g in groups if g.get('handle') == 'oncall-client-primary'), None) | ||
| secondary_id = next((g['id'] for g in groups if g.get('handle') == 'oncall-client-secondary'), None) | ||
| primary = f'<!subteam^{primary_id}|oncall-client-primary>' if primary_id else '@oncall-client-primary' | ||
| secondary = f'<!subteam^{secondary_id}|oncall-client-secondary>' if secondary_id else '@oncall-client-secondary' | ||
|
|
||
| message = f':books: New release docs PR ready for review\n{pr_url}\n{primary} {secondary} please take a look when you get a chance.' | ||
| body = json.dumps({'channel': channel, 'text': message, 'mrkdwn': True}).encode() | ||
| req = urllib.request.Request( | ||
| 'https://slack.com/api/chat.postMessage', | ||
| data=body, | ||
| headers={'Authorization': f'Bearer {token}', 'Content-Type': 'application/json'} | ||
| ) | ||
| with urllib.request.urlopen(req) as resp: | ||
| result = json.loads(resp.read()) | ||
| if not result.get('ok'): | ||
| print(f'Slack error: {result.get("error")}', file=sys.stderr) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
dannyneira marked this conversation as resolved.
|
||
| else: | ||
| print(f'Slack notification sent to {channel}') | ||
| ``` | ||
|
|
||
| Notes: | ||
|
|
||
| - Requires `DOCS_AGENT_GRAFANA_TOKEN` in the environment. | ||
| - Uses resolver script (by default): | ||
| `.agents/skills/release_updates/scripts/resolve_oncall_reviewers.py` | ||
| - Repeat `--oncall-schedule-id` to resolve one reviewer per schedule, in order. | ||
| - Override with `--oncall-resolver-script` if needed. | ||
|
|
||
| To verify reviewer resolution without mutating PR assignments: | ||
|
|
||
| ```bash | ||
| python3 .agents/skills/release_updates/scripts/run_release_updates.py \ | ||
| --tasks changelog \ | ||
| --create-pr \ | ||
| --assign-oncall-reviewer \ | ||
| --oncall-schedule-id CLIENT_PRIMARY_SCHEDULE_ID \ | ||
| --oncall-schedule-id CLIENT_SECONDARY_SCHEDULE_ID \ | ||
| --dry-run | ||
| ``` | ||
| The GitHub Actions workflow handles assigning the last human reviewer from recent docs PRs — the agent does not need to assign reviewers. | ||
|
|
||
| ### Explicit repo paths | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.