From 45191e6bcf341b16746c8ecd09d64f4bacb7be6c Mon Sep 17 00:00:00 2001 From: JerrettDavis Date: Fri, 22 May 2026 20:27:49 -0500 Subject: [PATCH] build(ci): configure dependabot grouping, conventional commits, and cooldown --- .github/dependabot.yml | 50 ++++-------------- .github/workflows/conventional-commits.yml | 59 ++++++++++++++++++++++ 2 files changed, 68 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/conventional-commits.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d5a0335..8d745b9 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,66 +1,34 @@ version: 2 - updates: - # NuGet package updates - package-ecosystem: "nuget" directory: "/" schedule: interval: "weekly" - day: "monday" - time: "09:00" open-pull-requests-limit: 10 - reviewers: - - "jerrettdavis" labels: - "dependencies" - - "nuget" commit-message: - prefix: "deps" - include: "scope" + prefix: "chore(deps)" + cooldown: + default-days: 2 groups: - all-nuget: + all-dependencies: patterns: - "*" - microsoft: - patterns: - - "Microsoft.*" - update-types: - - "minor" - - "patch" - testing: - patterns: - - "xunit*" - - "Moq" - - "FluentAssertions" - - "coverlet.*" - update-types: - - "minor" - - "patch" - analyzers: - patterns: - - "*.Analyzers" - - "*.CodeAnalysis" - update-types: - - "minor" - - "patch" - # GitHub Actions updates - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" - day: "monday" - time: "09:00" open-pull-requests-limit: 5 - reviewers: - - "jerrettdavis" labels: - "dependencies" - - "github-actions" + - "ci" commit-message: - prefix: "ci" - include: "scope" + prefix: "chore(deps)" + cooldown: + default-days: 2 groups: - all-actions: + all-dependencies: patterns: - "*" diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml new file mode 100644 index 0000000..ddc0f13 --- /dev/null +++ b/.github/workflows/conventional-commits.yml @@ -0,0 +1,59 @@ +name: Conventional Commits + +on: + pull_request: + branches: [ main ] + types: [ opened, edited, synchronize, reopened, ready_for_review ] + +permissions: + contents: read + pull-requests: read + +jobs: + validate: + name: Conventional Commits + runs-on: ubuntu-latest + steps: + - name: Validate PR title and commits + uses: actions/github-script@v9 + with: + script: | + const allowed = /^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([A-Za-z0-9._/-]+\))?!?: .+$/; + const allowedSpecial = /^(Merge .+|Revert ".+")$/; + + const failures = []; + const title = context.payload.pull_request.title; + + if (!allowed.test(title) && !allowedSpecial.test(title)) { + failures.push(`PR title: ${title}`); + } + + const commits = await github.paginate(github.rest.pulls.listCommits, { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + per_page: 100, + }); + + for (const commit of commits) { + const subject = commit.commit.message.split('\n')[0]; + if (!allowed.test(subject) && !allowedSpecial.test(subject)) { + failures.push(`${commit.sha.substring(0, 7)}: ${subject}`); + } + } + + if (failures.length > 0) { + core.setFailed([ + 'Conventional Commit validation failed.', + '', + 'Expected format:', + ' type(scope): description', + ' type: description', + '', + 'Allowed types:', + ' build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test', + '', + 'Failures:', + ...failures.map(f => ` - ${f}`), + ].join('\n')); + }