-
Notifications
You must be signed in to change notification settings - Fork 370
97 lines (81 loc) · 2.79 KB
/
code-analysis.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
# This workflow performs code analysis using both CodeQL and Microsoft C++ Code Analysis.
# It is triggered on pushes to the 'master' branch and publishes warnings into the security GitHub tab.
# The workflow includes two jobs: one for CodeQL analysis on Ubuntu and another for MSVC Code Analysis on Windows.
name: Code Analysis
on:
push:
branches:
- 'master'
permissions:
contents: read
security-events: write
packages: read
env:
# Path to the CMake build directory.
build: '${{ github.workspace }}/build'
config: 'Debug'
jobs:
codeql-analyze:
name: CodeQL Analyze (C/C++)
runs-on: ubuntu-latest
steps:
# Step: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4.1.7
# Step: Install necessary dependencies for building the project
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y tcl-dev tk-dev cmake gcc g++ make libbtbb-dev libx11-dev libglu1-mesa-dev
# Step: Initialize CodeQL for scanning
- name: Initialize CodeQL
uses: github/codeql-action/init@v3.26.5
with:
languages: c-cpp
build-mode: manual
# Step: Build the project using CMake and Make
- name: Build project
shell: bash
run: |
mkdir -p build
cd build
cmake -G "Unix Makefiles" \
-D CMAKE_C_COMPILER=gcc \
-D CMAKE_CXX_COMPILER=g++ \
-D USE_FREETYPE=OFF \
-D CMAKE_BUILD_TYPE=Release ..
make -j$(nproc)
# Step: Perform CodeQL Analysis
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3.26.5
with:
category: "/language:c-cpp"
msvc-analyze:
name: Microsoft C++ Code Analysis
runs-on: windows-latest
steps:
# Step: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v4.1.7
# Step: Install necessary dependencies using Chocolatey
- name: Install dependencies
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' -y
choco install magicsplat-tcl-tk -y
# Step: Configure the project using CMake
- name: Configure CMake
run: |
mkdir build
cd build
cmake -D USE_FREETYPE=OFF -DCMAKE_BUILD_TYPE=${{ env.config }} ..
# Step: Run MSVC Code Analysis
- name: Run MSVC Code Analysis
uses: microsoft/msvc-code-analysis-action@v0.1.1
id: run-analysis
with:
cmakeBuildDirectory: ${{ env.build }}
buildConfiguration: ${{ env.config }}
ruleset: NativeRecommendedRules.ruleset
# Step: Upload SARIF file to GitHub Code Scanning Alerts
- name: Upload SARIF to GitHub
uses: github/codeql-action/upload-sarif@v3.26.5
with:
sarif_file: ${{ steps.run-analysis.outputs.sarif }}