From 5bf1a62e2eda591067295356d68abc148d8c8631 Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Thu, 27 Nov 2025 20:42:12 -0300 Subject: [PATCH 1/4] chore: update pull request template and add PR title validation workflow --- .github/pull_request_template.md | 38 +++++++++--------- .github/workflows/validate-pr-title.yml | 51 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/validate-pr-title.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a8a64e7b4..d8a20a3d5 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,23 +1,27 @@ -# Description 📣 +## Context - + -## Type ✨ +## Screenshots -- [ ] Bug fix -- [ ] New feature + + +## How to test + + + +## Type + +- [ ] Fix +- [ ] Feature - [ ] Improvement -- [ ] Breaking change -- [ ] Documentation +- [ ] Breaking +- [ ] Docs +- [ ] Chore -# Tests 🛠️ +## Checklist - - -```sh -# Here's some code block to paste some code snippets -``` - ---- - -- [ ] I have read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview), agreed and acknowledged the [code of conduct](https://infisical.com/docs/contributing/getting-started/code-of-conduct). 📝 \ No newline at end of file +- [ ] Title follows format: `Type: Short description` (e.g., `Fix: Prevent crash on sync`) +- [ ] Tested locally +- [ ] Updated docs (if needed) +- [ ] Read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview) \ No newline at end of file diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml new file mode 100644 index 000000000..bb251a547 --- /dev/null +++ b/.github/workflows/validate-pr-title.yml @@ -0,0 +1,51 @@ +name: Validate PR Title + +on: + pull_request: + types: [opened, edited, synchronize, reopened] + +jobs: + validate-pr-title: + name: Validate PR Title Format + runs-on: ubuntu-latest + steps: + - name: Check PR Title Format + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 + with: + script: | + const title = context.payload.pull_request.title; + + // Valid PR types based on pull_request_template.md + const validTypes = ['Fix', 'Feature', 'Improvement', 'Breaking', 'Docs', 'Chore']; + + // Regex pattern: Type: Short description + // Type must be one of the valid types, followed by colon, space, and description + const pattern = new RegExp(`^(${validTypes.join('|')}): .+$`); + + if (!pattern.test(title)) { + const errorMessage = ` + ❌ **Invalid PR Title Format** + + Your PR title: \`${title}\` + + **Expected format:** \`Type: Short description\` + + **Valid types:** + - \`Fix\` - Bug fixes + - \`Feature\` - New features + - \`Improvement\` - Enhancements to existing features + - \`Breaking\` - Breaking changes + - \`Docs\` - Documentation updates + - \`Chore\` - Maintenance tasks + + **Examples:** + - \`Fix: Prevent crash on sync\` + - \`Feature: Add SSO login support\` + - \`Docs: Update API reference\` + `; + + core.setFailed(errorMessage); + } else { + console.log(`✅ PR title is valid: "${title}"`); + } + From 60daa12d215e4598eaad3335590eb650f4ad34e0 Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Thu, 27 Nov 2025 21:27:29 -0300 Subject: [PATCH 2/4] chore: update PR title format and validation to include optional scope --- .github/pull_request_template.md | 2 +- .github/workflows/validate-pr-title.yml | 32 ++++++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d8a20a3d5..afd0f1b57 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -21,7 +21,7 @@ ## Checklist -- [ ] Title follows format: `Type: Short description` (e.g., `Fix: Prevent crash on sync`) +- [ ] Title follows format: `type[scope]: Short description` (scope is optional, e.g., `fix: Prevent crash on sync` or `fix[api]: Handle null response`) - [ ] Tested locally - [ ] Updated docs (if needed) - [ ] Read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview) \ No newline at end of file diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml index bb251a547..d7bfe6043 100644 --- a/.github/workflows/validate-pr-title.yml +++ b/.github/workflows/validate-pr-title.yml @@ -16,11 +16,13 @@ jobs: const title = context.payload.pull_request.title; // Valid PR types based on pull_request_template.md - const validTypes = ['Fix', 'Feature', 'Improvement', 'Breaking', 'Docs', 'Chore']; + const validTypes = ['fix', 'feature', 'improvement', 'breaking', 'docs', 'chore']; - // Regex pattern: Type: Short description - // Type must be one of the valid types, followed by colon, space, and description - const pattern = new RegExp(`^(${validTypes.join('|')}): .+$`); + // Regex pattern: type[optional-scope]: Short description + // - Type must be one of the valid types + // - Scope is optional, must be in brackets, lowercase alphanumeric with hyphens + // - Followed by colon, space, and description + const pattern = new RegExp(`^(${validTypes.join('|')})(\\[[a-z0-9-]+\\])?: .+$`); if (!pattern.test(title)) { const errorMessage = ` @@ -28,20 +30,22 @@ jobs: Your PR title: \`${title}\` - **Expected format:** \`Type: Short description\` + **Expected format:** \`type[scope]: Short description\` **Valid types:** - - \`Fix\` - Bug fixes - - \`Feature\` - New features - - \`Improvement\` - Enhancements to existing features - - \`Breaking\` - Breaking changes - - \`Docs\` - Documentation updates - - \`Chore\` - Maintenance tasks + - \`fix\` - Bug fixes + - \`feature\` - New features + - \`improvement\` - Enhancements to existing features + - \`breaking\` - Breaking changes + - \`docs\` - Documentation updates + - \`chore\` - Maintenance tasks + + **Scope:** Optional, short identifier in brackets (e.g., \`[api]\`, \`[auth]\`, \`[ui]\`) **Examples:** - - \`Fix: Prevent crash on sync\` - - \`Feature: Add SSO login support\` - - \`Docs: Update API reference\` + - \`fix: Prevent crash on sync\` + - \`fix[api]: Handle null response from auth endpoint\` + - \`docs[cli]: Update installation guide\` `; core.setFailed(errorMessage); From 793e995f57c51a8450a26ed69966cabb7d074b34 Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Fri, 28 Nov 2025 10:07:23 -0300 Subject: [PATCH 3/4] chore: refine PR title format and update validation regex for optional scope --- .github/pull_request_template.md | 6 ++---- .github/workflows/validate-pr-title.yml | 14 +++++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index afd0f1b57..bec62f0bc 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -6,9 +6,7 @@ -## How to test - - +## Steps to verify the change ## Type @@ -21,7 +19,7 @@ ## Checklist -- [ ] Title follows format: `type[scope]: Short description` (scope is optional, e.g., `fix: Prevent crash on sync` or `fix[api]: Handle null response`) +- [ ] Title follows format: `type(scope): Short description` (scope is optional, e.g., `fix: Prevent crash on sync` or `fix(api): Handle null response`) - [ ] Tested locally - [ ] Updated docs (if needed) - [ ] Read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview) \ No newline at end of file diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml index d7bfe6043..650690329 100644 --- a/.github/workflows/validate-pr-title.yml +++ b/.github/workflows/validate-pr-title.yml @@ -18,11 +18,11 @@ jobs: // Valid PR types based on pull_request_template.md const validTypes = ['fix', 'feature', 'improvement', 'breaking', 'docs', 'chore']; - // Regex pattern: type[optional-scope]: Short description + // Regex pattern: type(optional-scope): Short description // - Type must be one of the valid types - // - Scope is optional, must be in brackets, lowercase alphanumeric with hyphens + // - Scope is optional, must be in parentheses, lowercase alphanumeric with hyphens // - Followed by colon, space, and description - const pattern = new RegExp(`^(${validTypes.join('|')})(\\[[a-z0-9-]+\\])?: .+$`); + const pattern = new RegExp(`^(${validTypes.join('|')})(\\([a-z0-9-]+\\))?: .+$`); if (!pattern.test(title)) { const errorMessage = ` @@ -30,7 +30,7 @@ jobs: Your PR title: \`${title}\` - **Expected format:** \`type[scope]: Short description\` + **Expected format:** \`type(scope): Short description\` **Valid types:** - \`fix\` - Bug fixes @@ -40,12 +40,12 @@ jobs: - \`docs\` - Documentation updates - \`chore\` - Maintenance tasks - **Scope:** Optional, short identifier in brackets (e.g., \`[api]\`, \`[auth]\`, \`[ui]\`) + **Scope:** Optional, short identifier in parentheses (e.g., \`(api)\`, \`(auth)\`, \`(ui)\`) **Examples:** - \`fix: Prevent crash on sync\` - - \`fix[api]: Handle null response from auth endpoint\` - - \`docs[cli]: Update installation guide\` + - \`fix(api): Handle null response from auth endpoint\` + - \`docs(cli): Update installation guide\` `; core.setFailed(errorMessage); From 59679006679944c672ab2ca17187117510be5925 Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Fri, 28 Nov 2025 17:16:53 -0300 Subject: [PATCH 4/4] chore: standardize PR title format and ensure description starts with lowercase --- .github/pull_request_template.md | 2 +- .github/workflows/validate-pr-title.yml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index bec62f0bc..2803cbbb5 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -19,7 +19,7 @@ ## Checklist -- [ ] Title follows format: `type(scope): Short description` (scope is optional, e.g., `fix: Prevent crash on sync` or `fix(api): Handle null response`) +- [ ] Title follows the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) format: `type(scope): short description` (scope is optional, e.g., `fix: prevent crash on sync` or `fix(api): handle null response`). - [ ] Tested locally - [ ] Updated docs (if needed) - [ ] Read the [contributing guide](https://infisical.com/docs/contributing/getting-started/overview) \ No newline at end of file diff --git a/.github/workflows/validate-pr-title.yml b/.github/workflows/validate-pr-title.yml index 650690329..1e590139c 100644 --- a/.github/workflows/validate-pr-title.yml +++ b/.github/workflows/validate-pr-title.yml @@ -18,11 +18,11 @@ jobs: // Valid PR types based on pull_request_template.md const validTypes = ['fix', 'feature', 'improvement', 'breaking', 'docs', 'chore']; - // Regex pattern: type(optional-scope): Short description + // Regex pattern: type(optional-scope): short description // - Type must be one of the valid types // - Scope is optional, must be in parentheses, lowercase alphanumeric with hyphens - // - Followed by colon, space, and description - const pattern = new RegExp(`^(${validTypes.join('|')})(\\([a-z0-9-]+\\))?: .+$`); + // - Followed by colon, space, and description (must start with lowercase letter) + const pattern = new RegExp(`^(${validTypes.join('|')})(\\([a-z0-9-]+\\))?: [a-z].+$`); if (!pattern.test(title)) { const errorMessage = ` @@ -30,7 +30,7 @@ jobs: Your PR title: \`${title}\` - **Expected format:** \`type(scope): Short description\` + **Expected format:** \`type(scope): short description\` (description must start with lowercase) **Valid types:** - \`fix\` - Bug fixes @@ -43,9 +43,9 @@ jobs: **Scope:** Optional, short identifier in parentheses (e.g., \`(api)\`, \`(auth)\`, \`(ui)\`) **Examples:** - - \`fix: Prevent crash on sync\` - - \`fix(api): Handle null response from auth endpoint\` - - \`docs(cli): Update installation guide\` + - \`fix: prevent crash on sync\` + - \`fix(api): handle null response from auth endpoint\` + - \`docs(cli): update installation guide\` `; core.setFailed(errorMessage);