Skip to content

Commit 185699a

Browse files
init
1 parent 539eba6 commit 185699a

File tree

11 files changed

+539
-5
lines changed

11 files changed

+539
-5
lines changed

.env

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CONFIG_URL=https://raw.githubusercontent.com/MariaDB/failman/refs/heads/main/config.yaml
2+
SENDER=buildbot@mariadb.org
3+
RECIPIENT_EMAIL=bb-report@lists.mariadb.org
4+
SMTP_RELAY_SERVER=smtp-relay.gmail.com
5+
SMTP_RELAY_PORT=465
6+
BASE_BUILDBOT_URL=https://buildbot.mariadb.org/
7+
SUBJECT="buildbot.mariadb.org FAILED builds report"

.github/workflows/ci.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
# Step 1: Checkout your repository
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
# Step 2: Set up Python
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.11' # or 3.12 if you prefer
23+
24+
# Step 3: Install dependencies
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -r requirements.txt
29+
pip install pytest pytest-cov
30+
31+
# Step 4: Run tests
32+
- name: Run tests with pytest
33+
run: |
34+
pytest tests/ --maxfail=1 --disable-warnings -v --cov=failman --cov-report=term-missing

.github/workflows/publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
jobs:
14+
build-and-push:
15+
permissions:
16+
packages: write
17+
contents: read
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
- name: Docker meta
23+
id: meta
24+
uses: docker/metadata-action@v5
25+
with:
26+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
27+
- name: Login to GitHub Container Registry
28+
if: github.event_name != 'pull_request'
29+
uses: docker/login-action@v3
30+
with:
31+
registry: ${{ env.REGISTRY }}
32+
username: ${{ github.actor }}
33+
password: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Build and push
35+
uses: docker/build-push-action@v6
36+
with:
37+
context: .
38+
push: ${{ github.event_name != 'pull_request' }}
39+
tags: ${{ steps.meta.outputs.tags }}
40+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ celerybeat.pid
135135
*.sage.py
136136

137137
# Environments
138-
.env
139138
.envrc
140139
.venv
141140
env/
@@ -182,9 +181,9 @@ cython_debug/
182181
.abstra/
183182

184183
# Visual Studio Code
185-
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
184+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186185
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187-
# and can be added to the global gitignore or merged into this file. However, if you prefer,
186+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
188187
# you could uncomment the following to ignore the entire vscode folder
189188
# .vscode/
190189

Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM alpine:latest
2+
3+
RUN apk add --no-cache \
4+
python3 \
5+
py3-pip \
6+
py3-virtualenv \
7+
bash \
8+
rm -rf /etc/periodic
9+
10+
WORKDIR /app
11+
12+
COPY failman.py .
13+
COPY requirements.txt .
14+
COPY config.yaml .
15+
COPY crontab /etc/crontabs/root
16+
COPY .env .
17+
18+
RUN python3 -m venv /app/venv && \
19+
/app/venv/bin/pip install --upgrade pip && \
20+
/app/venv/bin/pip install -r requirements.txt
21+
22+
ENV PATH="/app/venv/bin:$PATH"
23+
24+
CMD ["crond", "-f", "-l", "8"]

README.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,53 @@
1-
# failman
2-
Buildbot failed builds reporter
1+
# Buildbot Failed Builds Reporter
2+
3+
This script collects the latest failed builds from a [Buildbot](https://buildbot.net/) instance, generates both an **HTML report** and a **CSV file**, and sends them via email using an SMTP relay (IP-based authentication).
4+
5+
## Features
6+
7+
- ✅ Fetches builders and latest builds per branch from the Buildbot API
8+
- ✅ Filters builds by branch and builder names. See Config.
9+
- ✅ Identifies **failed builds**
10+
- ✅ Generates:
11+
- HTML tables grouped by branch
12+
- A CSV report with details for each failed build
13+
- ✅ Sends an email with both the HTML report (inline) and the CSV as an attachment
14+
- ✅ SMTP relay connection with **IP-based authentication** (no login required)
15+
16+
## Requirements
17+
18+
- Buildbot REST API (v2) accessible
19+
- SMTP relay server accessible from the host machine
20+
- [Google Workspace SMTP relay](https://support.google.com/a/answer/176600?hl=en) or similar
21+
22+
## Config
23+
24+
- the configuration file can be either a local file or a URL. To use an URL set `CONFIG_URL` in the `.env` file
25+
- `branches` list for making calls to buildbot `/changes` api and retrieve the latest builds per branch
26+
- `builder_filter` empty to get results for all builders from the `/builders` API
27+
28+
29+
## How to run
30+
31+
Set according to your setup:
32+
```
33+
SENDER=#SENDER_EMAIL#
34+
RECIPIENT_EMAIL=#RECEIVER_EMAIL#
35+
SMTP_RELAY_SERVER=smtp-relay.gmail.com
36+
SMTP_RELAY_PORT=465
37+
BASE_BUILDBOT_URL=#BUILDBOT BASE URL#
38+
```
39+
40+
```bash
41+
pip install -r requirements.txt
42+
python3 failman.py
43+
```
44+
45+
Or in `Docker` as a scheduled event. Set the desired schedule in `crontab`
46+
```
47+
docker build -t failman .
48+
docker run -d --name failman failman
49+
```
50+
51+
The repository default `config.yaml` is present in the image and used when no
52+
`CONFIG_URL` is set in the `.env` file.
53+

config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
configuration:
2+
builder_filter:
3+
branches:
4+
- 10.6
5+
- 10.11
6+
- 11.4
7+
- 11.8
8+
- 12.1
9+
- 12.2
10+
- 12.3
11+
- main

crontab

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0 0 * * * /app/venv/bin/python /app/failman.py >> /proc/1/fd/1 2>> /proc/1/fd/2

0 commit comments

Comments
 (0)