Repository navigation
101 lines (87 loc) · 2.95 KB
/
Copy pathcodeql.yml
File metadata and controls
101 lines (87 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
name: CodeQL
on:
# develop is covered by its pull request into master; a push trigger there would run everything twice.
push:
branches: [ master ]
pull_request:
branches: [ master, develop ]
types: [ opened, synchronize, reopened, ready_for_review ]
schedule:
- cron: '0 6 * * 1'
concurrency:
group: codeql-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
security-events: write
jobs:
changes:
name: Detect changed languages
if: github.event.pull_request.draft != true
runs-on: ubuntu-latest
outputs:
csharp: ${{ github.event_name != 'pull_request' || steps.filter.outputs.csharp == 'true' }}
python: ${{ github.event_name != 'pull_request' || steps.filter.outputs.python == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Filter
id: filter
if: github.event_name == 'pull_request'
uses: dorny/paths-filter@v4
with:
filters: |
csharp:
- 'src/**'
- 'tests/**'
- 'Directory.Build.props'
- 'global.json'
- '.github/workflows/codeql.yml'
python:
- 'python/**'
- '.github/workflows/codeql.yml'
# Both languages always get a job: "Analyze (csharp)" and "Analyze (python)" are required checks, and
# a check whose job never starts stays pending. An unchanged language's job skips its steps instead.
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
needs: changes
strategy:
fail-fast: false
matrix:
language: [csharp, python]
env:
RUN: ${{ needs.changes.outputs[matrix.language] }}
steps:
- name: Skip (language unchanged)
if: env.RUN != 'true'
run: echo "No ${{ matrix.language }} changes; skipping the analysis."
- name: Checkout
if: env.RUN == 'true'
uses: actions/checkout@v7
- name: Setup .NET
if: env.RUN == 'true' && matrix.language == 'csharp'
uses: actions/setup-dotnet@v6
with:
global-json-file: global.json
cache: true
cache-dependency-path: '**/*.csproj'
- name: Initialize CodeQL
if: env.RUN == 'true'
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
queries: security-extended
# Only the shipped projects: tests, benchmarks and the fuzz harness double the build for code
# no one runs against untrusted input.
- name: Build (Release)
if: env.RUN == 'true' && matrix.language == 'csharp'
run: |
for project in src/*/*.csproj; do
dotnet build "$project" --configuration Release -p:RunAnalyzers=false
done
- name: Perform CodeQL Analysis
if: env.RUN == 'true'
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"