-
-
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
26
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
26 commits
Select commit
Hold shift + click to select a range
40b3320
feat(ci): add optional resolved message parameter to manage-pr-commen…
rafaeltonholo 791c847
docs: update commit message guide with CI enforcement and new types
rafaeltonholo 0ab06da
docs: update contribution workflow with PR sentinel requirements
rafaeltonholo 6c9bc71
chore: update PR template with sentinel requirements and improved str…
rafaeltonholo a3156cb
feat(ci): add PR Sentinel check functions for PR and commit validation
rafaeltonholo 9cfdd94
test(ci): add test suite for PR Sentinel check functions
rafaeltonholo 04f308c
feat(ci): add shared PR Sentinel library for comment and label orches…
rafaeltonholo 35622f5
feat(ci): add PR evaluation script with mandatory checks validation
rafaeltonholo 5533cf8
feat(ci): add PR Sentinel report script with automated enforcement
rafaeltonholo 30f7a19
feat(ci): add PR Sentinel escalation script with auto-close logic
rafaeltonholo 9f53c46
test(ci): add tests for dry-run mode in PR Sentinel gh wrapper
rafaeltonholo 7678220
test(ci): add test runner for PR Sentinel test suites
rafaeltonholo 232264d
feat(ci): add PR Sentinel workflow with automated validation and enfo…
rafaeltonholo 10c5e97
feat(ci): add PR Sentinel workflow with automated validation and enfo…
rafaeltonholo 30268fd
chore: add markdown code formatting to PR template example
rafaeltonholo 65206fc
fix(ci): strip markdown code blocks from linked issue check
rafaeltonholo c9d7bcd
chore(ci): remove backticks from PR Sentinel check error messages
rafaeltonholo 9c54b08
feat(ci): add ready-for-review label and mutual exclusivity to Sentin…
rafaeltonholo f001245
feat(ci): support "Part of #N" as valid issue link in PR
rafaeltonholo eb43208
fix(ci): rename require_label to require_label_needs_updates in autoc…
rafaeltonholo b03df90
feat(ci): use GitHub App token for PR Sentinel workflows
rafaeltonholo acd0ed1
chore(ci): add safety flags to pr-sentinel lib.sh
rafaeltonholo 812774f
chore(ci): remove perf type from commit message validation
rafaeltonholo 7d2ada0
chore(ci): remove build and ci types from allowed commit message types
rafaeltonholo 411332a
chore(ci): remove shellcheck directive comments from pr-sentinel scripts
rafaeltonholo ff78851
chore(ci): add safety flags to pr-sentinel checks.sh
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,66 @@ | ||
| --- | ||
| 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 | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| environment: botmobile | ||
| env: | ||
| GH_REPO: ${{ github.repository }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
|
|
||
| - name: App token generate | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| if: ${{ vars.BOT_CLIENT_ID }} | ||
| 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 || github.token }} | ||
| run: | | ||
| set -euo pipefail | ||
| # shellcheck source=scripts/ci/pr-sentinel/lib.sh disable=SC1091 | ||
| source ./scripts/ci/pr-sentinel/lib.sh | ||
| require_label_needs_updates | ||
|
|
||
| - name: Escalate / close labeled PRs | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token || github.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,88 @@ | ||
| --- | ||
| 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 | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| environment: botmobile | ||
| env: | ||
| GH_REPO: ${{ github.repository }} | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
|
|
||
| - name: App token generate | ||
| uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0 | ||
| if: ${{ vars.BOT_CLIENT_ID }} | ||
| 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 || github.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 || github.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.