-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
chore(ci): add PR Sentinel compliance checks and grace-period auto-close #11254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rafaeltonholo
wants to merge
30
commits into
thunderbird:main
Choose a base branch
from
rafaeltonholo:chore/11158/ci-pr-sentinel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
51a300d
feat(ci): add optional resolved message parameter to manage-pr-commen…
rafaeltonholo b4a3176
docs: update commit message guide with CI enforcement and new types
rafaeltonholo 03dd4c1
docs: update contribution workflow with PR sentinel requirements
rafaeltonholo 3e43903
chore: update PR template with sentinel requirements and improved str…
rafaeltonholo 27d125a
feat(ci): add PR Sentinel check functions for PR and commit validation
rafaeltonholo bb819a2
test(ci): add test suite for PR Sentinel check functions
rafaeltonholo 3425a63
feat(ci): add shared PR Sentinel library for comment and label orches…
rafaeltonholo 120d873
feat(ci): add PR evaluation script with mandatory checks validation
rafaeltonholo c5d7fd8
feat(ci): add PR Sentinel report script with automated enforcement
rafaeltonholo 5c8daf0
feat(ci): add PR Sentinel escalation script with auto-close logic
rafaeltonholo a613450
test(ci): add tests for dry-run mode in PR Sentinel gh wrapper
rafaeltonholo 78ddb14
test(ci): add test runner for PR Sentinel test suites
rafaeltonholo f864215
feat(ci): add PR Sentinel workflow with automated validation and enfo…
rafaeltonholo a712e7b
feat(ci): add PR Sentinel workflow with automated validation and enfo…
rafaeltonholo 78f64e0
chore: add markdown code formatting to PR template example
rafaeltonholo 4c23b10
fix(ci): strip markdown code blocks from linked issue check
rafaeltonholo c8019be
chore(ci): remove backticks from PR Sentinel check error messages
rafaeltonholo 960c41a
feat(ci): add ready-for-review label and mutual exclusivity to Sentin…
rafaeltonholo 9d43b3a
feat(ci): support "Part of #N" as valid issue link in PR
rafaeltonholo 2574908
fix(ci): rename require_label to require_label_needs_updates in autoc…
rafaeltonholo 257f319
feat(ci): use GitHub App token for PR Sentinel workflows
rafaeltonholo 7f4912f
chore(ci): add safety flags to pr-sentinel lib.sh
rafaeltonholo c70fc03
chore(ci): remove perf type from commit message validation
rafaeltonholo 317b1c9
chore(ci): remove build and ci types from allowed commit message types
rafaeltonholo cc9f177
chore(ci): remove shellcheck directive comments from pr-sentinel scripts
rafaeltonholo d86f3f4
chore(ci): add safety flags to pr-sentinel checks.sh
rafaeltonholo 848e89f
chore(ci): skip pr-sentinel-autoclose for forks
rafaeltonholo a37ab42
chore(ci): update actions/checkout to v7.0.0 in pr-sentinel workflows
rafaeltonholo 0ec573d
chore(ci): checkout default branch explicitly in pr-sentinel-autoclose
rafaeltonholo de13f93
chore(ci): update pr-sentinel to require GitHub App token
rafaeltonholo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| name: PR - Sentinel Auto-Close | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 0 * * *" # 00:00 GMT/UTC daily | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: "Log escalate/close actions without making changes." | ||
| type: boolean | ||
| default: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
| jobs: | ||
| autoclose: | ||
| name: Escalate and close stale non-compliant PRs | ||
| if: github.repository == 'thunderbird/thunderbird-android' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| environment: botmobile | ||
| env: | ||
| GH_REPO: ${{ github.repository }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.event.repository.default_branch }} | ||
| persist-credentials: false | ||
|
|
||
| - name: App token generate | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| id: app-token | ||
| with: | ||
| client-id: ${{ vars.BOT_CLIENT_ID }} | ||
| private-key: ${{ secrets.BOT_PRIVATE_KEY }} | ||
|
|
||
| - name: Assert Sentinel label exists (fail loud) | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| run: | | ||
| set -euo pipefail | ||
| # shellcheck source=scripts/ci/pr-sentinel/lib.sh disable=SC1091 | ||
|
rafaeltonholo marked this conversation as resolved.
|
||
| source ./scripts/ci/pr-sentinel/lib.sh | ||
| require_label_needs_updates | ||
|
|
||
| - name: Escalate / close labeled PRs | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| DRY_RUN_INPUT: ${{ github.event.inputs.dry_run }} | ||
| run: | | ||
| set -euo pipefail | ||
| args=() | ||
| if [[ "${DRY_RUN_INPUT:-false}" == "true" ]]; then | ||
| args+=(--dry-run) | ||
| fi | ||
| numbers="$(gh pr list --state open --label "pr-sentinel: needs updates" \ | ||
| --json number --jq 'map(.number) | join(" ")')" | ||
| if [[ -z "$numbers" ]]; then | ||
| echo "No labeled PRs; nothing to do." | ||
| exit 0 | ||
| fi | ||
| for pr in $numbers; do | ||
| ./scripts/ci/pr-sentinel/escalate-pr.sh "$pr" "${args[@]}" | ||
| done | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| --- | ||
| name: PR - Sentinel Bot | ||
|
|
||
| # Warning, this job runs on pull_request_target and therefore has access to issue content. | ||
| # Don't add any steps that act on external (PR-head) code. | ||
| on: | ||
| pull_request_target: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
| - edited | ||
| - ready_for_review | ||
| - converted_to_draft | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
| inputs: | ||
| pr_number: | ||
| description: "Single PR to evaluate; leave blank to evaluate all open PRs." | ||
| required: false | ||
| default: "" | ||
| dry_run: | ||
| description: "Log actions without posting comments, changing labels, or closing PRs." | ||
| type: boolean | ||
| default: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| issues: write | ||
|
|
||
| concurrency: | ||
| group: pr-sentinel-${{ github.event.pull_request.number || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| sentinel: | ||
| name: PR Sentinel | ||
| if: github.repository == 'thunderbird/thunderbird-android' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| environment: botmobile | ||
| env: | ||
| GH_REPO: ${{ github.repository }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.event.repository.default_branch }} | ||
| persist-credentials: false | ||
|
|
||
| - name: App token generate | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| id: app-token | ||
| with: | ||
| client-id: ${{ vars.BOT_CLIENT_ID }} | ||
| private-key: ${{ secrets.BOT_PRIVATE_KEY }} | ||
|
|
||
| - name: Determine target PRs | ||
| id: prs | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| EVENT_NAME: ${{ github.event_name }} | ||
| EVENT_PR: ${{ github.event.pull_request.number }} | ||
| INPUT_PR: ${{ github.event.inputs.pr_number }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [[ "$EVENT_NAME" == "pull_request_target" ]]; then | ||
| numbers="$EVENT_PR" | ||
| elif [[ -n "$INPUT_PR" ]]; then | ||
| numbers="$INPUT_PR" | ||
| else | ||
| numbers="$(gh pr list --state open --json number --jq 'map(.number) | join(" ")')" | ||
| fi | ||
| echo "numbers=${numbers}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Evaluate and report | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| NUMBERS: ${{ steps.prs.outputs.numbers }} | ||
| DRY_RUN_INPUT: ${{ github.event.inputs.dry_run }} | ||
| run: | | ||
| set -euo pipefail | ||
| args=() | ||
| if [[ "${DRY_RUN_INPUT:-false}" == "true" ]]; then args+=(--dry-run); fi | ||
| overall=0 | ||
| for pr in $NUMBERS; do | ||
| ./scripts/ci/pr-sentinel/report-pr.sh "$pr" "${args[@]}" || overall=1 | ||
| done | ||
| exit "$overall" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.