Skip to content

Commit 8a44767

Browse files
perf(ci): optimize CodeQL analysis performance with query filtering and path exclusions
1 parent 8944671 commit 8a44767

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

.github/codeql/codeql-config.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "CodeQL Config"
22

3-
# Exclude paths to reduce disk space usage during CodeQL analysis
4-
# This prevents analyzing unnecessary files that consume disk space
3+
# Exclude paths to reduce disk space usage and improve analysis performance
4+
# This prevents analyzing unnecessary files that consume disk space and time
55
paths-ignore:
66
# Dependencies - don't analyze third-party code
77
- "**/node_modules"
@@ -16,6 +16,23 @@ paths-ignore:
1616
- "**/www"
1717
- "**/release"
1818

19+
# Test files - exclude test code to improve performance
20+
# Test files rarely contain security vulnerabilities that matter for production
21+
- "**/*.test.ts"
22+
- "**/*.test.tsx"
23+
- "**/*.spec.ts"
24+
- "**/*.spec.tsx"
25+
- "**/*.test.js"
26+
- "**/*.test.jsx"
27+
- "**/*.spec.js"
28+
- "**/*.spec.jsx"
29+
30+
# Storybook files
31+
- "**/*.stories.tsx"
32+
- "**/*.stories.ts"
33+
- "**/*.stories.jsx"
34+
- "**/*.stories.js"
35+
1936
# Test fixtures and snapshots
2037
- "**/__mocks__"
2138
- "**/__image_snapshots__"
@@ -26,6 +43,16 @@ paths-ignore:
2643
- "**/test/**/*.svg"
2744
- "**/integration-tests/**/*.png"
2845

46+
# Test utilities and configs
47+
- "**/test-utils/**"
48+
- "**/testing/**"
49+
- "**/jest.config.*"
50+
- "**/jest.setup.*"
51+
- "**/coverage/**"
52+
53+
# Generated type definition files
54+
- "**/*.d.ts"
55+
2956
# Example and playground files - not production code
3057
- "**/example"
3158
- "**/examples"

.github/workflows/codeql.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
analyze:
1313
name: Analyze (${{ matrix.language }})
1414
runs-on: ubuntu-latest
15+
timeout-minutes: 60
1516
permissions:
1617
# required for all workflows
1718
security-events: write
@@ -68,13 +69,28 @@ jobs:
6869
uses: actions/checkout@v4
6970

7071
# Initializes the CodeQL tools for scanning.
71-
- name: Initialize CodeQL
72+
# Use security-extended query pack for PRs (faster), security-and-quality for main/scheduled (comprehensive)
73+
- name: Initialize CodeQL (PR - security-extended)
74+
if: github.event_name == 'pull_request'
7275
uses: github/codeql-action/init@v4
7376
with:
7477
languages: ${{ matrix.language }}
7578
build-mode: ${{ matrix.build-mode }}
7679
# Use our custom config file to exclude unnecessary files
7780
config-file: ./.github/codeql/codeql-config.yml
81+
# Use security-extended for faster PR analysis
82+
queries: +security-extended
83+
84+
- name: Initialize CodeQL (main/scheduled - security-and-quality)
85+
if: github.event_name != 'pull_request'
86+
uses: github/codeql-action/init@v4
87+
with:
88+
languages: ${{ matrix.language }}
89+
build-mode: ${{ matrix.build-mode }}
90+
# Use our custom config file to exclude unnecessary files
91+
config-file: ./.github/codeql/codeql-config.yml
92+
# Use security-and-quality for comprehensive analysis on main branch and scheduled runs
93+
queries: +security-and-quality
7894

7995
- name: Perform CodeQL Analysis
8096
uses: github/codeql-action/analyze@v4

0 commit comments

Comments
 (0)