Skip to content

Commit 60eb2f0

Browse files
chore: progress reporter (#10717)
2 parents 4109be3 + 18deeed commit 60eb2f0

3 files changed

Lines changed: 465 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
name: PR - Request report labels
3+
4+
# Warning, this job is running on pull_request_target and therefore has access to issue content.
5+
# Don't add any steps that act on external code.
6+
on:
7+
pull_request_target:
8+
types: [ opened, reopened, synchronize, labeled, unlabeled ]
9+
branches:
10+
- main
11+
- beta
12+
- release
13+
14+
permissions:
15+
contents: none
16+
17+
jobs:
18+
require-report-label:
19+
permissions:
20+
pull-requests: write
21+
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Validate report label
25+
id: validate
26+
run: |
27+
set -euo pipefail
28+
29+
labels_json='${{ toJson(github.event.pull_request.labels) }}'
30+
31+
echo "Current labels:"
32+
echo "$labels_json" | jq -r '.[].name'
33+
34+
include_count="$(jq '[.[] | select(.name == "report: include")] | length' <<< "$labels_json")"
35+
exclude_count="$(jq '[.[] | select(.name == "report: exclude")] | length' <<< "$labels_json")"
36+
highlight_count="$(jq '[.[] | select(.name == "report: highlight")] | length' <<< "$labels_json")"
37+
38+
total_count=$((include_count + exclude_count + highlight_count))
39+
40+
if [ "$total_count" -eq 0 ]; then
41+
echo "valid=false" >> "$GITHUB_OUTPUT"
42+
echo "message=Missing report label. Set exactly one of: \`report: include\`, \`report: exclude\` OR \`report: highlight\`." >> "$GITHUB_OUTPUT"
43+
elif [ "$total_count" -gt 1 ]; then
44+
echo "valid=false" >> "$GITHUB_OUTPUT"
45+
echo "message=Only one report label is allowed: \`report: include\`, \`report: exclude\` OR \`report: highlight\`." >> "$GITHUB_OUTPUT"
46+
else
47+
echo "valid=true" >> "$GITHUB_OUTPUT"
48+
fi
49+
50+
- name: Comment on PR (only on error)
51+
if: steps.validate.outputs.valid == 'false'
52+
env:
53+
GH_TOKEN: ${{ github.token }}
54+
PR_NUMBER: ${{ github.event.pull_request.number }}
55+
MESSAGE: ${{ steps.validate.outputs.message }}
56+
run: |
57+
gh pr comment "$PR_NUMBER" \
58+
--repo "${{ github.repository }}" \
59+
--body "$MESSAGE"
60+
61+
- name: Fail if invalid
62+
if: steps.validate.outputs.valid == 'false'
63+
env:
64+
MESSAGE: ${{ steps.validate.outputs.message }}
65+
run: |
66+
echo "::error::$MESSAGE"
67+
exit 1

scripts/MERGED_PR_REPORT_README.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Merged PR Report
2+
3+
Generate a monthly report of pull requests merged into the `main`, `beta`, and `release` branches of `thunderbird/thunderbird-android`.
4+
5+
The script `scripts/merged-pr-report.sh` produces:
6+
7+
- A Markdown report for review
8+
- A CSV report for spreadsheet import or further processing
9+
10+
## What it reports
11+
12+
For each merged pull request, the report includes:
13+
14+
- Target branch (`main`, `beta`, `release`)
15+
- PR number
16+
- Merge date
17+
- PR title
18+
- Report status from GitHub labels
19+
- First beta tag containing the merge commit
20+
- First release tag containing the merge commit
21+
22+
The CSV report additionally includes:
23+
24+
- PR author
25+
- Merge commit SHA
26+
- PR URL
27+
- Empty `Comment` column for manual notes
28+
29+
## Report status labels
30+
31+
The script reads these labels from the PR:
32+
33+
| Label | Result |
34+
|------|--------|
35+
| `report: include` | Include |
36+
| `report: exclude` | Exclude |
37+
| `report: highlight` | Highlight |
38+
| *(none)* | Review |
39+
40+
## Beta and Release columns
41+
42+
For each PR merge commit, the script determines:
43+
44+
- **Beta**: first beta tag (containing `b`) that contains the merge commit (only if the commit reached the `beta` branch)
45+
- **Release**: first production release tag (excluding `b`, including dot releases) that contains the merge commit (only if the commit reached the `release` branch)
46+
47+
Possible values:
48+
49+
- A tag (e.g. `THUNDERBIRD_115_0b1`, `THUNDERBIRD_115_1_0`)
50+
- `Not released yet` (commit reached the branch but is not yet tagged)
51+
- `-` (commit not present in that branch history)
52+
53+
## How it works
54+
55+
The script:
56+
57+
1. Validates input (`YEAR`, `MONTH`)
58+
2. Computes the monthly date range
59+
3. Creates a temporary git repository
60+
4. Fetches:
61+
- `main`, `beta`, `release`
62+
- all tags
63+
5. Queries GitHub for merged PRs
64+
6. Maps report labels to status
65+
7. Resolves beta/release versions via git ancestry and tags
66+
8. Writes Markdown and CSV outputs
67+
68+
To improve performance, version lookups are cached per merge commit SHA.
69+
70+
## Usage
71+
72+
```bash
73+
./scripts/merged-pr-report.sh YEAR MONTH [TARGET_DIR] [--skip-excluded]
74+
```
75+
76+
Example:
77+
78+
```bash
79+
./scripts/merged-pr-report.sh 2026 02
80+
./scripts/merged-pr-report.sh 2026 02 ./reports
81+
./scripts/merged-pr-report.sh 2026 02 . --skip-excluded
82+
```
83+
84+
Arguments:
85+
86+
- `YEAR`: Four-digit year (e.g. 2026)
87+
- `MONTH`: Two-digit month (01-12)
88+
- `TARGET_DIR`: (Optional) Target directory for reports (default: current directory)
89+
- `--skip-excluded`: (Optional) If set, PRs with `report: exclude` label are omitted from the report
90+
91+
## Requirements
92+
93+
- `git`
94+
- `gh` (GitHub CLI)
95+
- `jq`
96+
- macOS / BSD `date` (uses `date -j`)
97+
98+
Authenticate GitHub CLI:
99+
100+
```bash
101+
gh auth login

0 commit comments

Comments
 (0)