-
Notifications
You must be signed in to change notification settings - Fork 34
134 lines (114 loc) · 4.02 KB
/
analyzers.yml
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Analyzers
on:
push:
paths:
- '.github/workflows/analyzers.yml'
- 'CMakeLists.txt'
- 'src/**'
- 'test/**'
- 'modules/**'
- '3rdparty/**'
- '**.imp'
pull_request:
paths:
- '.github/workflows/analyzers.yml'
- 'CMakeLists.txt'
- 'src/**'
- 'test/**'
- 'modules/**'
- '3rdparty/**'
- '**.imp'
release:
types: published
jobs:
analyze-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
tool: [clang-analyzer, iwyu, CodeQL]
config: [Release, Debug]
permissions:
# required for all codeql to report detected outcomes
security-events: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update
sudo apt install -y libglfw3-dev libopenal-dev libglvnd-core-dev iwyu clang clang-tidy clang-tools ninja-build
# TODO: Really, this should only be fetching the build dependencies, so we can only use the in-tree version
sudo apt install -y libsdl2-dev
- name: Configure
run: |
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }}
# Compile deps before initializing codeql, to avoid unnecessary analysis.
- name: Compile Dependencies
if: ${{ matrix.tool == 'CodeQL' }}
run: |
cmake --build build --parallel --config ${{ matrix.config }} --target compile-osp-magnum-deps compile-test-deps
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
if: ${{ matrix.tool == 'CodeQL' }}
with:
languages: cpp
- name: Reconfigure for CodeQL
if: ${{ matrix.tool == 'CodeQL' }}
run: |
cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }}
- name: Compile for CodeQL
if: ${{ matrix.tool == 'CodeQL' }}
run: |
cmake --build build --parallel --target osp-magnum compile-tests
# Unlike clang-analyzer and include-what-you-use, CodeQL can't operate on just the config step. Need to actually build everything.
- name: Perform CodeQL Analysis
if: ${{ matrix.tool == 'CodeQL' }}
uses: github/codeql-action/analyze@v2
# Implicitly requires build/compile_commands.json to exist
- name: Run Clang Analyzer
if: ${{ matrix.tool == 'clang-analyzer' }}
run: |
wget https://raw.githubusercontent.com/llvm/llvm-project/llvmorg-11.0.1/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
chmod +x run-clang-tidy.py
./run-clang-tidy.py -j $(nproc) -p build
# Implicitly requires build/compile_commands.json to exist
- name: Run IWYU
if: ${{ matrix.tool == 'iwyu' }}
run: |
wget https://raw.githubusercontent.com/include-what-you-use/include-what-you-use/clang_11/iwyu_tool.py
chmod +x iwyu_tool.py
./iwyu_tool.py -j $(nproc) -p build -- -Xiwyu --mapping_file=${GITHUB_WORKSPACE}/iwyu-ubuntu.imp
analyze-windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
tool: [msvc-code-analysis]
config: [Release, Debug]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
submodules: recursive
- name: Configure (MSVC)
run: |
cmake -B build -DCMAKE_CONFIGURATION_TYPES=${{ matrix.config }}
- name: Initialize MSVC Code Analysis
uses: microsoft/[email protected]
# Provide a unique ID to access the sarif output path
id: run-analysis
with:
cmakeBuildDirectory: build
buildConfiguration: ${{ matrix.config }}
# Ruleset file that will determine what checks will be run
ruleset: NativeRecommendedRules.ruleset
ignoredPaths: 3rdparty
ignoredIncludePaths: 3rdparty
# Upload SARIF file to GitHub Code Scanning Alerts
- name: Upload SARIF to GitHub
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: ${{ steps.run-analysis.outputs.sarif }}