build: Bump the testing group with 3 updates #253
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Validation | |
| on: | |
| pull_request: | |
| types: [opened, edited, synchronize, reopened] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| validate: | |
| name: Validate PR Title | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Validate PR title | |
| # Skip subject case validation for dependabot PRs (they use "Bump" with uppercase) | |
| if: ${{ github.actor != 'dependabot[bot]' }} | |
| uses: amannn/action-semantic-pull-request@v5 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| types: | | |
| feat | |
| fix | |
| docs | |
| style | |
| refactor | |
| perf | |
| test | |
| build | |
| ci | |
| chore | |
| revert | |
| requireScope: false | |
| disallowScopes: | | |
| wip | |
| subjectPattern: ^[a-z]([^A-Z]*[^.A-Z])?$ | |
| subjectPatternError: | | |
| The subject "{subject}" must be entirely lowercase and not end with a period. | |
| This matches commitlint's subject-case rule for squash merge commits. | |
| Example: "feat: add user authentication" | |
| - name: Validate dependabot PR title (relaxed) | |
| # For dependabot PRs, only validate the type prefix, not subject case | |
| if: ${{ github.actor == 'dependabot[bot]' }} | |
| uses: amannn/action-semantic-pull-request@v5 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| types: | | |
| feat | |
| fix | |
| docs | |
| style | |
| refactor | |
| perf | |
| test | |
| build | |
| ci | |
| chore | |
| revert | |
| requireScope: false | |
| - name: Validate branch name | |
| env: | |
| BRANCH_NAME: ${{ github.head_ref }} | |
| run: | | |
| echo "Validating branch name: $BRANCH_NAME" | |
| # Allow main branch (shouldn't happen in PRs, but just in case) | |
| if [ "$BRANCH_NAME" = "main" ]; then | |
| echo "Main branch - allowed" | |
| exit 0 | |
| fi | |
| # Allow dependabot branches | |
| if echo "$BRANCH_NAME" | grep -qE "^dependabot/"; then | |
| echo "Dependabot branch - allowed" | |
| exit 0 | |
| fi | |
| # Validate branch naming convention | |
| # Valid patterns: feature/N-*, fix/N-*, docs/N-*, chore/N-*, refactor/N-*, test/N-* | |
| if ! echo "$BRANCH_NAME" | grep -qE "^(feature|fix|docs|chore|refactor|test)/[0-9]+-"; then | |
| echo "::error::Invalid branch name: $BRANCH_NAME" | |
| echo "" | |
| echo "Branch name must follow pattern: {type}/{issue#}-description" | |
| echo "Valid types: feature, fix, docs, chore, refactor, test" | |
| echo "Example: feature/123-add-login-page" | |
| exit 1 | |
| fi | |
| echo "Branch name validation passed" | |
| - name: Check issue reference | |
| env: | |
| PR_BODY: ${{ github.event.pull_request.body }} | |
| run: | | |
| if ! echo "$PR_BODY" | grep -qiE "(close[sd]?|fix(e[sd])?|resolve[sd]?)\s*#[0-9]+|#[0-9]+|refs?\s*#[0-9]+"; then | |
| echo "::warning::PR body does not reference an issue. Consider adding 'refs #123' or 'closes #123'." | |
| fi |