Scripts: mirror the testing feed into Discord from GitHub Actions #3485

Merged
Foniass merged 1 commit from upstream-pr/3485 into main 2026-11-30 20:58:06 +00:00
Foniass commented 2026-11-30 01:17:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-11-30T01:17:45Z.


Moves the Discord posts of the testing queue (#nvidia-prs, #amd-prs, #any-prs, #ready-to-merge) from a bot on my PC into this repo's Actions, so they keep working without it. Same posts as before.

What is in it

  • scripts/discord_mirror.py: one pass that keeps one Discord post per PR and channel in step with queue.json (post / edit / delete), through one webhook per channel. Standard library only, read-only on GitHub except for its own state branch.
  • .github/workflows/discord-mirror.yml: runs it after each successful Testing feed run, when a PR is closed (its posts go at once), and every 10 min as a fallback. Which Discord message is which post is kept on a discord-mirror-state branch (a webhook cannot list a channel). No PR code is checked out; no event text reaches a shell.
  • scripts/test_discord_mirror.py: unit tests against a fake Discord.
  • Safety: nothing runs until the webhook secrets exist; the first run creates the state branch before it posts anything, and a run that cannot push that branch posts nothing (so it can never post the same PRs run after run). At most 20 new posts per run.
  • 832 lines, all new files (159 of them tests), nothing existing changes. Not split: neither the script nor the workflow does anything on its own.

Setup (maintainer, once)

  1. Merge.
  2. Settings → Secrets and variables → Actions → New repository secret, one per channel, each holding that channel's webhook URL (sent privately): DISCORD_WEBHOOK_NVIDIA_PRS, DISCORD_WEBHOOK_AMD_PRS, DISCORD_WEBHOOK_ANY_PRS, DISCORD_WEBHOOK_READY_TO_MERGE. The names must be exactly these.

That's all: the next run starts posting (20 a run, the channels are full after about 20 min). My bot sees that, deletes its own posts and removes itself; until then some posts show twice. Please don't delete the discord-mirror-state branch: it keeps which message is which post.

Stop: disable the workflow (posts stay up), or first run it with action remove-all.

Tested

  • Linux, Python 3.14: python -m unittest scripts/test_discord_mirror.py: 11 passed; scripts/test_triage_pr.py still passes.
  • Replayed all 397 versions of queue.json on testing-feed through the script against a fake Discord: the 91,679 posts are identical to the old bot's and within Discord's size limits; with 5–15 % of Discord calls failing (5xx, 429, dropped connections) and runs killed partway, no duplicate and no lost post, and Discord ended up matching the last feed.
  • The workflow's shell steps against a local git remote: no secrets (nothing happens), first run, dry run, settled feed (no commit), closed PR, push refused (nothing posted), remove-all, state branch deleted, no feed yet. actionlint 1.7.12 with shellcheck 0.11.0: clean.
  • Discord's error codes the script tells apart (10008 unknown message: forget the post; 10015 unknown webhook: keep it) checked on the live API.

Regression run
Not needed: scripts and CI only.

Not tested

  • Not run on GitHub Actions itself yet (triggers, pushing discord-mirror-state with GITHUB_TOKEN). The workflow does nothing until the secrets exist, and its first push is made before anything is posted.
  • cargo test: not built; no Rust is changed. (Build and test (Windows, no GPU) fails on hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, as it does on main at this PR's base.)

AI use

  • Claude Code with Claude Opus 5.5: ported my bot into the script and workflow, wrote the tests, and ran the checks above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5557264624 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3485). Originally posted by [Foniass](https://github.com/Foniass) on 2026-11-30T01:17:45Z. --- Moves the Discord posts of the testing queue (#nvidia-prs, #amd-prs, #any-prs, #ready-to-merge) from a bot on my PC into this repo's Actions, so they keep working without it. Same posts as before. **What is in it** - `scripts/discord_mirror.py`: one pass that keeps one Discord post per PR and channel in step with `queue.json` (post / edit / delete), through one webhook per channel. Standard library only, read-only on GitHub except for its own state branch. - `.github/workflows/discord-mirror.yml`: runs it after each successful `Testing feed` run, when a PR is closed (its posts go at once), and every 10 min as a fallback. Which Discord message is which post is kept on a `discord-mirror-state` branch (a webhook cannot list a channel). No PR code is checked out; no event text reaches a shell. - `scripts/test_discord_mirror.py`: unit tests against a fake Discord. - Safety: nothing runs until the webhook secrets exist; the first run creates the state branch before it posts anything, and a run that cannot push that branch posts nothing (so it can never post the same PRs run after run). At most 20 new posts per run. - 832 lines, all new files (159 of them tests), nothing existing changes. Not split: neither the script nor the workflow does anything on its own. **Setup (maintainer, once)** 1. Merge. 2. Settings → Secrets and variables → Actions → New repository secret, one per channel, each holding that channel's webhook URL (sent privately): `DISCORD_WEBHOOK_NVIDIA_PRS`, `DISCORD_WEBHOOK_AMD_PRS`, `DISCORD_WEBHOOK_ANY_PRS`, `DISCORD_WEBHOOK_READY_TO_MERGE`. The names must be exactly these. That's all: the next run starts posting (20 a run, the channels are full after about 20 min). My bot sees that, deletes its own posts and removes itself; until then some posts show twice. Please don't delete the `discord-mirror-state` branch: it keeps which message is which post. Stop: disable the workflow (posts stay up), or first run it with action `remove-all`. **Tested** - Linux, Python 3.14: `python -m unittest scripts/test_discord_mirror.py`: 11 passed; `scripts/test_triage_pr.py` still passes. - Replayed all 397 versions of `queue.json` on `testing-feed` through the script against a fake Discord: the 91,679 posts are identical to the old bot's and within Discord's size limits; with 5–15 % of Discord calls failing (5xx, 429, dropped connections) and runs killed partway, no duplicate and no lost post, and Discord ended up matching the last feed. - The workflow's shell steps against a local git remote: no secrets (nothing happens), first run, dry run, settled feed (no commit), closed PR, push refused (nothing posted), remove-all, state branch deleted, no feed yet. `actionlint` 1.7.12 with `shellcheck` 0.11.0: clean. - Discord's error codes the script tells apart (10008 unknown message: forget the post; 10015 unknown webhook: keep it) checked on the live API. **Regression run** Not needed: scripts and CI only. **Not tested** - Not run on GitHub Actions itself yet (triggers, pushing `discord-mirror-state` with `GITHUB_TOKEN`). The workflow does nothing until the secrets exist, and its first push is made before anything is posted. - `cargo test`: not built; no Rust is changed. (`Build and test (Windows, no GPU)` fails on `hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline`, as it does on `main` at this PR's base.) **AI use** - Claude Code with Claude Opus 5.5: ported my bot into the script and workflow, wrote the tests, and ran the checks above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3485
No description provided.