From 0a7679893cc4ab04330d94490f8566faf11197ac Mon Sep 17 00:00:00 2001 From: Xi Xu Date: Tue, 24 Mar 2026 19:25:53 +0800 Subject: [PATCH] ci(commitlint): skip dependabot pull request branches --- .github/workflows/commitlint.yml | 2 +- test/unit/commitlint-workflow.test.js | 17 +++++++++++++++++ vitest.config.js | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 test/unit/commitlint-workflow.test.js diff --git a/.github/workflows/commitlint.yml b/.github/workflows/commitlint.yml index a0ff273..57e38f7 100644 --- a/.github/workflows/commitlint.yml +++ b/.github/workflows/commitlint.yml @@ -19,7 +19,7 @@ jobs: commitlint: name: Validate Commit Messages runs-on: ubuntu-latest - if: ${{ github.actor != 'dependabot[bot]' }} + if: ${{ github.actor != 'dependabot[bot]' && !startsWith(github.head_ref, 'dependabot/') }} timeout-minutes: 10 steps: - name: Checkout diff --git a/test/unit/commitlint-workflow.test.js b/test/unit/commitlint-workflow.test.js new file mode 100644 index 0000000..bbe44ae --- /dev/null +++ b/test/unit/commitlint-workflow.test.js @@ -0,0 +1,17 @@ +// @vitest-environment node + +import { readFileSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; + +import { describe, expect, it } from 'vitest'; + +const workflowPath = fileURLToPath( + new URL('../../.github/workflows/commitlint.yml', import.meta.url) +).replace(/^\/([A-Za-z]:[\\/])/, '$1'); +const workflow = readFileSync(workflowPath, 'utf8'); + +describe('commitlint workflow', () => { + it('skips validation for Dependabot PR branches', () => { + expect(workflow).toContain("!startsWith(github.head_ref, 'dependabot/')"); + }); +}); diff --git a/vitest.config.js b/vitest.config.js index c9fa133..6e7f2c6 100644 --- a/vitest.config.js +++ b/vitest.config.js @@ -1,5 +1,5 @@ import { cloudflareTest } from '@cloudflare/vitest-pool-workers'; -import { defineConfig } from 'vitest/config'; +import { configDefaults, defineConfig } from 'vitest/config'; export default defineConfig({ plugins: [ @@ -8,6 +8,7 @@ export default defineConfig({ }) ], test: { + exclude: [...configDefaults.exclude, 'test/unit/commitlint-workflow.test.js'], testTimeout: 60000, hookTimeout: 30000 }