Skip to content

Commit 45dedc3

Browse files
CopilotedburnsCopilot
authored
Add path-filtered CodeQL workflow for content-specific analysis (#1444)
* Initial plan * Add path-filtered CodeQL workflow for content-specific analysis Create .github/workflows/codeql.yml that uses dorny/paths-filter to detect which language directories changed, then only runs CodeQL analysis for those languages. This replaces the default setup which analyzed all languages on every PR regardless of changed files. On push to main and scheduled runs, all languages are analyzed. On PRs, only languages with changed files are analyzed. Co-authored-by: edburns <75821+edburns@users.noreply.github.com> * Add clarifying comment for if: always() in CodeQL workflow Co-authored-by: edburns <75821+edburns@users.noreply.github.com> * Add rust. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Fix codeql.yml: add rust, fix path filters, skip changes job on non-PRs Co-authored-by: edburns <75821+edburns@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: edburns <75821+edburns@users.noreply.github.com> Co-authored-by: Ed Burns <edburns@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 4fba3a4 commit 45dedc3

1 file changed

Lines changed: 102 additions & 0 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
schedule:
9+
- cron: "0 6 * * 1" # Weekly on Monday at 06:00 UTC
10+
11+
permissions:
12+
contents: read
13+
security-events: write
14+
15+
jobs:
16+
changes:
17+
name: Detect changed paths
18+
if: github.event_name == 'pull_request'
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
22+
pull-requests: read
23+
outputs:
24+
java: ${{ steps.filter.outputs.java }}
25+
js: ${{ steps.filter.outputs.js }}
26+
python: ${{ steps.filter.outputs.python }}
27+
go: ${{ steps.filter.outputs.go }}
28+
rust: ${{ steps.filter.outputs.rust }}
29+
csharp: ${{ steps.filter.outputs.csharp }}
30+
actions: ${{ steps.filter.outputs.actions }}
31+
steps:
32+
- uses: actions/checkout@v4
33+
- uses: dorny/paths-filter@v3
34+
id: filter
35+
with:
36+
filters: |
37+
java:
38+
- 'java/**'
39+
js:
40+
- 'nodejs/**'
41+
- 'scripts/**'
42+
- 'test/harness/**'
43+
python:
44+
- 'python/**'
45+
go:
46+
- 'go/**'
47+
rust:
48+
- 'rust/**'
49+
csharp:
50+
- 'dotnet/**'
51+
actions:
52+
- '.github/workflows/**'
53+
- '.github/actions/**'
54+
55+
analyze:
56+
name: Analyze (${{ matrix.language }})
57+
needs: changes
58+
# Run even if 'changes' is skipped (e.g. on push/schedule where paths-filter
59+
# may not flag changes). Each step has its own gate condition.
60+
if: always()
61+
runs-on: ubuntu-latest
62+
permissions:
63+
security-events: write
64+
contents: read
65+
strategy:
66+
fail-fast: false
67+
matrix:
68+
include:
69+
- language: java-kotlin
70+
gate: java
71+
- language: javascript-typescript
72+
gate: js
73+
- language: python
74+
gate: python
75+
- language: go
76+
gate: go
77+
- language: rust
78+
gate: rust
79+
- language: csharp
80+
gate: csharp
81+
- language: actions
82+
gate: actions
83+
steps:
84+
- name: Checkout repository
85+
if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }}
86+
uses: actions/checkout@v4
87+
88+
- name: Initialize CodeQL
89+
if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }}
90+
uses: github/codeql-action/init@v3
91+
with:
92+
languages: ${{ matrix.language }}
93+
94+
- name: Autobuild
95+
if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }}
96+
uses: github/codeql-action/autobuild@v3
97+
98+
- name: Perform CodeQL Analysis
99+
if: ${{ needs.changes.outputs[matrix.gate] == 'true' || github.event_name == 'schedule' || github.event_name == 'push' }}
100+
uses: github/codeql-action/analyze@v3
101+
with:
102+
category: "/language:${{ matrix.language }}"

0 commit comments

Comments
 (0)