Skip to content

Commit ed4d20d

Browse files
committed
Add a automatic PR-revert utility for failing buildbots
Signed-off-by: Pablo Galindo <[email protected]>
1 parent a22bbf3 commit ed4d20d

File tree

4 files changed

+466
-0
lines changed

4 files changed

+466
-0
lines changed

buildbothammer/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# BuildbotHammer
2+
3+
This app automatically creates revert Pull Requests for failing builds in the
4+
CPython project. It monitors Buildbot for failing builds, identifies the
5+
commit that caused the failure, and creates a revert PR on GitHub. It also sends
6+
notifications to Discord.
7+
8+
## Prerequisites
9+
10+
- Python 3.11+
11+
- Git
12+
- A GitHub account with fork of the CPython repository
13+
- A Discord server with webhook set up (for notifications)
14+
15+
## Installation
16+
17+
1. Clone this repository:
18+
```
19+
git clone https://github.com/python/buildmasterconf.git
20+
cd buildmasterconf/buildbot-hammer
21+
```
22+
23+
2. Install the required Python packages:
24+
```
25+
pip install -e .
26+
```
27+
28+
3. Set up environment variables:
29+
```
30+
export GITHUB_TOKEN="your-github-personal-access-token"
31+
export DISCORD_WEBHOOK_URL="your-discord-webhook-url"
32+
```
33+
34+
4. Update the script with your GitHub username:
35+
Open the script and replace `FORK_OWNER` variable with your GitHub username.
36+
37+
5. (Optional) Update the `REPO_CLONE_DIR` path if you want to use a different location for the local CPython clone.
38+
39+
## Usage
40+
41+
Run the script with:
42+
43+
```
44+
python -m buildbothammer
45+
```
46+
47+
The script will:
48+
1. Check Buildbot for failing builds
49+
2. For each failing build, it will:
50+
- Identify the commit that caused the failure
51+
- Create a new branch in your fork
52+
- Revert the problematic commit
53+
- Create a Pull Request to the main CPython repository
54+
- Send a notification to the configured Discord channel
55+
56+
## Configuration
57+
58+
- `BUILDBOT_API`: The Buildbot API endpoint (default: "http://buildbot.python.org/api/v2")
59+
- `BUILDBOT_URL`: The Buildbot URL for generating links (default: "http://buildbot.python.org/#/")
60+
- `REPO_OWNER`: The owner of the main repository (default: "python")
61+
- `REPO_NAME`: The name of the repository (default: "cpython")
62+
- `FORK_OWNER`: Your GitHub username (default: "$REPO_OWNER")
63+
- `REPO_CLONE_DIR`: The directory for the local clone of the repository

buildbothammer/pyproject.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[project]
2+
name = "buildbothammer"
3+
version = "0.1.0"
4+
description = "Automatic revert failing CPython PRs"
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = [
8+
"requests>=2.32.3",
9+
"pygithub>=2.4.0",
10+
"filelock>=3.16.1",
11+
"aiohttp",
12+
]
13+
14+
[build-system]
15+
requires = ["hatchling"]
16+
build-backend = "hatchling.build"

0 commit comments

Comments
 (0)