Skip to content

Quality Gates: PR Title standardization and LOC#122

Merged
cb-jeevitha merged 6 commits into
masterfrom
feat/EE-651
Jun 17, 2026
Merged

Quality Gates: PR Title standardization and LOC#122
cb-jeevitha merged 6 commits into
masterfrom
feat/EE-651

Conversation

@cb-anomitromunshi

Copy link
Copy Markdown
Contributor

This PR adds standardized PR template, changelog script, PR lint workflow, and PR size check workflow.

@snyk-io

snyk-io Bot commented Mar 13, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cb-jeevitha cb-jeevitha merged commit 35d2710 into master Jun 17, 2026
3 of 5 checks passed

@hivel-marco hivel-marco Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
FileTypesCount
.github/workflows/pr-lint.yml
LineTypePreview
13Secret: Secret Keyword[Secret Keyword]
Secret Keyword1
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.sh script 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-pipelines workflow, centralizing lint rules.
  • Adds a PR size check workflow for PRs into master that enforces warning/error thresholds, supports a pr-size-exception bypass label, and records bypass approvals to S3 for auditability while excluding infrastructure paths from size calculations.
Risks & Considerations
  • generate-changelog.sh depends on GH_USERNAME, GH_PAT, jq, and the hard-coded chargebee/chargebee-android repo; running it in other repos will require updating the REPO variable.
  • The date calculation for the default DATE_FILTER uses BSD (-v-30d) and GNU (-d '30 days ago') variants of date, which may behave differently or fail on non-standard environments.
  • PR lint workflow runs only for base branches main and master despite listing other branches in on.pull_request.branches; reviewers should confirm this is intentional.
  • PR size check applies only to master as 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-exception label 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.

Comment on lines +16 to +22
# 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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
# 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"

Comment on lines +24 to +35
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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants