Quality Gates: PR Title standardization and LOC#122
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
PR Complexity Score: 2.0 - Simple
View Breakdown
- Lines Changed: 238
- Files Changed: 5
- Complexity Added: 0
- Raw Score: 19.76
⚠️ Sensitive Data (PII/ Secrets) Detected
| File | Types | Count | ||||||
|---|---|---|---|---|---|---|---|---|
|
| Line | Type | Preview |
|---|---|---|
| 13 | Secret: Secret Keyword | [Secret Keyword] |
Overview
Introduces standardized tooling and automation around pull requests, including a new PR template, changelog generation script, and GitHub Actions workflows.
The goal is to improve PR metadata quality, enable consistent changelog creation, and enforce PR size and lint checks for PRs targeting main/master.
Key Changes
- Adds a structured PR template capturing changelog entries, summary, automation/test details, impact areas, change type, and documentation links to standardize PR descriptions.
- Introduces a
generate-changelog.shscript plus documentation to fetch and format merged PRs from GitHub (excluding parent-branch syncs and bot PRs), enabling automated/assisted changelog creation with robust error handling and JSON validation. - Adds a reusable PR lint workflow that triggers on PR events for main/master branches and delegates checks to a shared
cb-cicd-pipelinesworkflow, centralizing lint rules. - Adds a PR size check workflow for PRs into
masterthat enforces warning/error thresholds, supports apr-size-exceptionbypass label, and records bypass approvals to S3 for auditability while excluding infrastructure paths from size calculations.
Risks & Considerations
generate-changelog.shdepends onGH_USERNAME,GH_PAT,jq, and the hard-codedchargebee/chargebee-androidrepo; running it in other repos will require updating theREPOvariable.- The date calculation for the default
DATE_FILTERuses BSD (-v-30d) and GNU (-d '30 days ago') variants ofdate, which may behave differently or fail on non-standard environments. - PR lint workflow runs only for base branches
mainandmasterdespite listing other branches inon.pull_request.branches; reviewers should confirm this is intentional. - PR size check applies only to
masteras base and excludes.github/**and.cursor/**from size calculation; large changes in other branches or paths may not be guarded. - The bypass flow depends on the
pr-size-exceptionlabel and an AWS role/region being correctly configured; misconfiguration could break recording of approvals while still marking the job successful. - New PR template is not enforced by automation; teams must adopt it in practice for consistent usage.
File-level change summary
| File | Change summary |
|---|---|
| .github/pull_request_template.md | Adds a standardized PR template capturing changelog, summary, automation details, impact areas, change types, and documentation links. |
| .github/scripts/README.md | Documents usage, prerequisites, arguments, and examples for the new changelog generation script. |
| .github/scripts/generate-changelog.sh | Adds a bash script that queries GitHub’s search API to list merged PRs into a branch, validates/cleans JSON, and prints a formatted changelog with a verification URL. |
| .github/workflows/pr-lint.yml | Introduces a PR lint workflow that runs shared lint checks for PRs into main/master using a centralized reusable workflow. |
| .github/workflows/pr-size-check.yml | Adds a PR size check workflow for master that enforces size thresholds, supports a bypass label, posts informational comments, and records bypass approvals to S3. |
| # Optional: Branch name (defaults to current branch if not provided) | ||
| SOURCE_BRANCH="${1:-$(git branch --show-current)}" | ||
| # Optional: Date filter (defaults to last 30 days if not provided) | ||
| DATE_FILTER="${2:-merged:>=$(date -u -v-30d +%Y-%m-%d 2>/dev/null || date -u -d '30 days ago' +%Y-%m-%d)}" | ||
|
|
||
| # Repo is set per-repo when this file is pushed (placeholder replaced by upload script) | ||
| REPO="chargebee/chargebee-android" |
There was a problem hiding this comment.
Priority: 🟠 HIGH
Problem: The default DATE_FILTER value already includes the merged: qualifier, but it is later interpolated into the search query as merged:$DATE_FILTER, resulting in a malformed query like merged:merged:>=YYYY-MM-DD.
Why: The malformed merged:merged:... qualifier can cause the GitHub Search API to return incorrect results (or none at all), breaking the core purpose of this script: reliably generating a changelog of merged PRs.
How to Fix: Change the default DATE_FILTER to contain only the date expression (e.g. >=YYYY-MM-DD) rather than the full merged: qualifier, so that merged:$DATE_FILTER becomes a valid merged:>=YYYY-MM-DD search qualifier in both the API call and the verification URL.
| # Optional: Branch name (defaults to current branch if not provided) | |
| SOURCE_BRANCH="${1:-$(git branch --show-current)}" | |
| # Optional: Date filter (defaults to last 30 days if not provided) | |
| DATE_FILTER="${2:-merged:>=$(date -u -v-30d +%Y-%m-%d 2>/dev/null || date -u -d '30 days ago' +%Y-%m-%d)}" | |
| # Repo is set per-repo when this file is pushed (placeholder replaced by upload script) | |
| REPO="chargebee/chargebee-android" | |
| # Optional: Branch name (defaults to current branch if not provided) | |
| SOURCE_BRANCH="${1:-$(git branch --show-current)}" | |
| # Optional: Date filter (defaults to last 30 days if not provided) | |
| DEFAULT_DATE="$(date -u -v-30d +%Y-%m-%d 2>/dev/null || date -u -d '30 days ago' +%Y-%m-%d)" | |
| DATE_FILTER="${2:-">=$DEFAULT_DATE"}" | |
| # Repo is set per-repo when this file is pushed (placeholder replaced by upload script) | |
| REPO="chargebee/chargebee-android" |
| script: | | ||
| const owner = context.repo.owner; | ||
| const repo = context.repo.repo; | ||
| const issue_number = context.payload.pull_request.number; | ||
|
|
||
| const marker = '<!-- pr-size-bypass-pending -->'; | ||
| const pending = `${marker} | ||
| 🛑 The \`pr-size-exception\` label is present. This workflow is **waiting for approvals** from the **[cb-Billing-CAB-reviewers](https://github.com/orgs/chargebee/teams/cb-billing-cab-approvers)**.`; | ||
|
|
||
| // create a new comment when the workflow runs | ||
| await github.rest.issues.createComment({ owner, repo, issue_number, body: pending }); | ||
| pr-size-check: |
There was a problem hiding this comment.
Priority: 🟡 MEDIUM
Problem: The pre-approval-comment job always creates a new comment whenever it runs, without checking for an existing marker, which will spam PRs with duplicate “pending bypass approval” comments on every sync/edit after the label is applied.
Why: Each synchronize, edited, reopened, or re-run of the workflow after the pr-size-exception label is present will add another identical comment, degrading PR readability and making it harder to see meaningful discussion.
How to Fix: Before creating the comment, list existing issue comments and only create a new one if no comment containing the marker is already present.
| script: | | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const issue_number = context.payload.pull_request.number; | |
| const marker = '<!-- pr-size-bypass-pending -->'; | |
| const pending = `${marker} | |
| 🛑 The \`pr-size-exception\` label is present. This workflow is **waiting for approvals** from the **[cb-Billing-CAB-reviewers](https://github.com/orgs/chargebee/teams/cb-billing-cab-approvers)**.`; | |
| // create a new comment when the workflow runs | |
| await github.rest.issues.createComment({ owner, repo, issue_number, body: pending }); | |
| pr-size-check: | |
| script: | | |
| const owner = context.repo.owner; | |
| const repo = context.repo.repo; | |
| const issue_number = context.payload.pull_request.number; | |
| const marker = '<!-- pr-size-bypass-pending -->'; | |
| const pending = `${marker} | |
| 🛑 The \`pr-size-exception\` label is present. This workflow is **waiting for approvals** from the **[cb-Billing-CAB-reviewers](https://github.com/orgs/chargebee/teams/cb-billing-cab-approvers)**.`; | |
| // create the comment only if it doesn't already exist | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner, | |
| repo, | |
| issue_number, | |
| per_page: 100, | |
| }); | |
| const existing = comments.find( | |
| (comment) => comment.body && comment.body.includes(marker) | |
| ); | |
| if (!existing) { | |
| await github.rest.issues.createComment({ owner, repo, issue_number, body: pending }); | |
| } | |
| pr-size-check: |
This PR adds standardized PR template, changelog script, PR lint workflow, and PR size check workflow.