Some checks are pending
Go Benchmark / Performance Regression Check (push) Waiting to run
Cerberus Integration / Cerberus Security Stack Integration (push) Waiting to run
Upload Coverage to Codecov / Backend Codecov Upload (push) Waiting to run
Upload Coverage to Codecov / Frontend Codecov Upload (push) Waiting to run
CodeQL - Analyze / CodeQL analysis (go) (push) Waiting to run
CodeQL - Analyze / CodeQL analysis (javascript-typescript) (push) Waiting to run
CrowdSec Integration / CrowdSec Bouncer Integration (push) Waiting to run
Docker Build, Publish & Test / build-and-push (push) Waiting to run
Docker Build, Publish & Test / Security Scan PR Image (push) Blocked by required conditions
Quality Checks / Auth Route Protection Contract (push) Waiting to run
Quality Checks / Codecov Trigger/Comment Parity Guard (push) Waiting to run
Quality Checks / Backend (Go) (push) Waiting to run
Quality Checks / Frontend (React) (push) Waiting to run
Rate Limit integration / Rate Limiting Integration (push) Waiting to run
Security Scan (PR) / Trivy Binary Scan (push) Waiting to run
Supply Chain Verification (PR) / Verify Supply Chain (push) Waiting to run
WAF integration / Coraza WAF Integration (push) Waiting to run
73 lines
3.5 KiB
YAML
Executable File
73 lines
3.5 KiB
YAML
Executable File
name: PR Checklist Validation (History Rewrite)
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
pr_number:
|
|
description: 'PR number to validate'
|
|
required: true
|
|
type: string
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ inputs.pr_number || github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
validate:
|
|
name: Validate history-rewrite checklist (conditional)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
|
|
- name: Validate PR checklist (only for history-rewrite changes)
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
|
|
env:
|
|
PR_NUMBER: ${{ inputs.pr_number }}
|
|
with:
|
|
script: |
|
|
const owner = context.repo.owner;
|
|
const repo = context.repo.repo;
|
|
const prNumber = Number(process.env.PR_NUMBER || context.issue.number);
|
|
if (!prNumber) {
|
|
core.setFailed('Missing PR number input for workflow_dispatch.');
|
|
return;
|
|
}
|
|
const pr = await github.rest.pulls.get({owner, repo, pull_number: prNumber});
|
|
const body = (pr.data && pr.data.body) || '';
|
|
|
|
// Determine if this PR modifies history-rewrite related files
|
|
// Exclude the template file itself - it shouldn't trigger its own validation
|
|
const filesResp = await github.rest.pulls.listFiles({ owner, repo, pull_number: prNumber });
|
|
const files = filesResp.data.map(f => f.filename.toLowerCase());
|
|
const relevant = files.some(fn => {
|
|
// Skip the PR template itself
|
|
if (fn === '.github/pull_request_template/history-rewrite.md') return false;
|
|
// Check for actual history-rewrite implementation files
|
|
return fn.startsWith('scripts/history-rewrite/') || fn === 'docs/plans/history_rewrite.md';
|
|
});
|
|
if (!relevant) {
|
|
core.info('No history-rewrite related files changed; skipping checklist validation.');
|
|
return;
|
|
}
|
|
|
|
// Use a set of named checks with robust regex patterns for checkbox and phrase variants
|
|
const checks = [
|
|
{ name: 'preview_removals.sh mention', pattern: /preview_removals\.sh/i },
|
|
{ name: 'data/backups mention', pattern: /data\/?backups/i },
|
|
// Accept checked checkbox variants and inline code/backtick usage for the '--force' phrase
|
|
{ name: 'explicit non-run of --force', pattern: /(?:\[\s*[xX]\s*\]\s*)?(?:i will not run|will not run|do not run|don'?t run|won'?t run)\b[^\n]*--force/i },
|
|
];
|
|
|
|
const missing = checks.filter(c => !c.pattern.test(body)).map(c => c.name);
|
|
if (missing.length > 0) {
|
|
// Post a comment to the PR with instructions for filling the checklist
|
|
const commentBody = `Hi! This PR touches history-rewrite artifacts and requires the checklist in .github/PULL_REQUEST_TEMPLATE/history-rewrite.md. The following items are missing in your PR body: ${missing.join(', ')}\n\nPlease update the PR description using the history-rewrite template and re-run checks.`;
|
|
await github.rest.issues.createComment({ owner, repo, issue_number: prNumber, body: commentBody });
|
|
core.setFailed('Missing required checklist items: ' + missing.join(', '));
|
|
}
|