Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/pr-request-report-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
name: PR - Request report labels

Comment thread
wmontwe marked this conversation as resolved.
# Warning, this job is running on pull_request_target and therefore has access to issue content.
# Don't add any steps that act on external code.
on:
pull_request_target:
types: [ opened, reopened, synchronize, labeled, unlabeled ]
branches:
- main
- beta
- release

permissions:
contents: none

jobs:
require-report-label:
permissions:
pull-requests: write

runs-on: ubuntu-latest
steps:
- name: Validate report label
id: validate
run: |
set -euo pipefail

labels_json='${{ toJson(github.event.pull_request.labels) }}'

echo "Current labels:"
echo "$labels_json" | jq -r '.[].name'

include_count="$(jq '[.[] | select(.name == "report: include")] | length' <<< "$labels_json")"
exclude_count="$(jq '[.[] | select(.name == "report: exclude")] | length' <<< "$labels_json")"
highlight_count="$(jq '[.[] | select(.name == "report: highlight")] | length' <<< "$labels_json")"

total_count=$((include_count + exclude_count + highlight_count))

if [ "$total_count" -eq 0 ]; then
echo "valid=false" >> "$GITHUB_OUTPUT"
echo "message=Missing report label. Set exactly one of: \`report: include\`, \`report: exclude\` OR \`report: highlight\`." >> "$GITHUB_OUTPUT"
elif [ "$total_count" -gt 1 ]; then
echo "valid=false" >> "$GITHUB_OUTPUT"
echo "message=Only one report label is allowed: \`report: include\`, \`report: exclude\` OR \`report: highlight\`." >> "$GITHUB_OUTPUT"
else
echo "valid=true" >> "$GITHUB_OUTPUT"
fi

- name: Comment on PR (only on error)
if: steps.validate.outputs.valid == 'false'
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
MESSAGE: ${{ steps.validate.outputs.message }}
run: |
gh pr comment "$PR_NUMBER" \
--repo "${{ github.repository }}" \
--body "$MESSAGE"

- name: Fail if invalid
if: steps.validate.outputs.valid == 'false'
env:
MESSAGE: ${{ steps.validate.outputs.message }}
run: |
echo "::error::$MESSAGE"
exit 1
101 changes: 101 additions & 0 deletions scripts/MERGED_PR_REPORT_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Merged PR Report

Generate a monthly report of pull requests merged into the `main`, `beta`, and `release` branches of `thunderbird/thunderbird-android`.

The script `scripts/merged-pr-report.sh` produces:

- A Markdown report for review
- A CSV report for spreadsheet import or further processing

## What it reports

For each merged pull request, the report includes:

- Target branch (`main`, `beta`, `release`)
- PR number
- Merge date
- PR title
- Report status from GitHub labels
- First beta tag containing the merge commit
- First release tag containing the merge commit

The CSV report additionally includes:

- PR author
- Merge commit SHA
- PR URL
- Empty `Comment` column for manual notes

## Report status labels

The script reads these labels from the PR:

| Label | Result |
|------|--------|
| `report: include` | Include |
| `report: exclude` | Exclude |
| `report: highlight` | Highlight |
| *(none)* | Review |

## Beta and Release columns

For each PR merge commit, the script determines:

- **Beta**: first beta tag (containing `b`) that contains the merge commit (only if the commit reached the `beta` branch)
- **Release**: first production release tag (excluding `b`, including dot releases) that contains the merge commit (only if the commit reached the `release` branch)

Possible values:

- A tag (e.g. `THUNDERBIRD_115_0b1`, `THUNDERBIRD_115_1_0`)
- `Not released yet` (commit reached the branch but is not yet tagged)
- `-` (commit not present in that branch history)

## How it works

The script:

1. Validates input (`YEAR`, `MONTH`)
2. Computes the monthly date range
3. Creates a temporary git repository
4. Fetches:
- `main`, `beta`, `release`
- all tags
5. Queries GitHub for merged PRs
6. Maps report labels to status
7. Resolves beta/release versions via git ancestry and tags
8. Writes Markdown and CSV outputs

To improve performance, version lookups are cached per merge commit SHA.

## Usage

```bash
./scripts/merged-pr-report.sh YEAR MONTH [TARGET_DIR] [--skip-excluded]
```

Example:

```bash
./scripts/merged-pr-report.sh 2026 02
./scripts/merged-pr-report.sh 2026 02 ./reports
./scripts/merged-pr-report.sh 2026 02 . --skip-excluded
```

Arguments:

- `YEAR`: Four-digit year (e.g. 2026)
- `MONTH`: Two-digit month (01-12)
- `TARGET_DIR`: (Optional) Target directory for reports (default: current directory)
- `--skip-excluded`: (Optional) If set, PRs with `report: exclude` label are omitted from the report

## Requirements

- `git`
- `gh` (GitHub CLI)
- `jq`
- macOS / BSD `date` (uses `date -j`)

Authenticate GitHub CLI:

```bash
gh auth login
Loading
Loading