Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

ci(workflows): add PR title check to verify conformance to conventional commit standards (#1131)

Sanchith Hegdef5bb994b0993
diff --git a/.github/workflows/conventional-commit-check.yml b/.github/workflows/conventional-commit-check.yml
new file mode 100644
index 0000000000..779e079be7
--- /dev/null
+++ b/.github/workflows/conventional-commit-check.yml
@@ -0,0 +1,67 @@
+name: Conventional Commit Message Check
+
+on:
+ pull_request:
+ types:
+ - opened
+ - edited
+ - reopened
+ - ready_for_review
+
+permissions:
+ # Reference: https://github.com/cli/cli/issues/6274
+ repository-projects: read
+ pull-requests: write
+
+env:
+ # Allow more retries for network requests in cargo (downloading crates) and
+ # rustup (installing toolchains). This should help to reduce flaky CI failures
+ # from transient network timeouts or other issues.
+ CARGO_NET_RETRY: 10
+ RUSTUP_MAX_RETRIES: 10
+ # Use cargo's sparse index protocol
+ CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
+
+jobs:
+ pr_title_check:
+ name: Verify PR title follows conventional commit standards
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: stable
+
+ - uses: Swatinem/[email protected]
+ with:
+ cache-on-failure: "true"
+
+ - name: Install cocogitto
+ shell: bash
+ run: cargo install cocogitto
+
+ - name: Verify PR title follows conventional commit standards
+ id: pr_title_check
+ shell: bash
+ continue-on-error: true
+ run: cog verify "${{ github.event.pull_request.title }}"
+
+ # GitHub CLI returns a successful error code even if the PR has the label already attached
+ - name: Attach 'S-conventions-not-followed' label if PR title check failed
+ if: ${{ steps.pr_title_check.outcome == 'failure' }}
+ shell: bash
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ gh --repo ${{ github.event.repository.full_name }} pr edit --add-label 'S-conventions-not-followed' ${{ github.event.pull_request.number }}
+ echo "::error::PR title does not follow conventional commit standards"
+ exit 1
+
+ # GitHub CLI returns a successful error code even if the PR does not have the label attached
+ - name: Remove 'S-conventions-not-followed' label if PR title check succeeded
+ if: ${{ steps.pr_title_check.outcome == 'success' }}
+ shell: bash
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: gh --repo ${{ github.event.repository.full_name }} pr edit --remove-label 'S-conventions-not-followed' ${{ github.event.pull_request.number }}