Skip to content

Commit 034c0d5

Browse files
authored
Create codeql.yml
1 parent 5e206a3 commit 034c0d5

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

.github/workflows/codeql.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: "CodeQL C++ Build"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '33 8 * * 1' # Example: Run 8:33 UTC every Monday
10+
11+
jobs:
12+
analyze:
13+
name: Analyze (C++)
14+
runs-on: ubuntu-latest
15+
permissions:
16+
security-events: write # required to upload CodeQL results
17+
actions: read # required for private repositories
18+
contents: read # required to check out the code
19+
packages: read # required to fetch internal or private CodeQL packs (if used)
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
language: [ 'c-cpp' ]
25+
build-mode: [ 'manual' ] # Using manual build steps
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0 # Fetch all history
32+
33+
# === Dependency Installation Steps ===
34+
- name: Install apt-get dependencies
35+
run: |
36+
sudo apt-get update -y
37+
sudo apt-get install -y \
38+
build-essential \
39+
git \
40+
python3-dev \
41+
wget \
42+
tar \
43+
zlib1g-dev \
44+
libssl-dev \
45+
openssl \
46+
cmake
47+
sudo apt-get clean -y
48+
49+
- name: Install boost (v1.87.0)
50+
run: |
51+
echo "Downloading Boost..."
52+
wget https://sourceforge.net/projects/boost/files/boost/1.87.0/boost_1_87_0.tar.gz/download -O /tmp/boost_1_87_0.tar.gz
53+
echo "Extracting Boost..."
54+
tar xzvf /tmp/boost_1_87_0.tar.gz -C /tmp
55+
cd /tmp/boost_1_87_0
56+
echo "Bootstrapping Boost..."
57+
./bootstrap.sh --prefix=/usr/local
58+
echo "Building and installing Boost..."
59+
sudo ./b2 install link=static --prefix=/usr/local -j$(nproc)
60+
cd ${{ github.workspace }}
61+
rm -rf /tmp/boost_1_87_0 /tmp/boost_1_87_0.tar.gz
62+
63+
- name: Install protobuf (v3.17.3)
64+
run: |
65+
echo "Downloading Protobuf..."
66+
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-all-3.17.3.tar.gz -O /tmp/protobuf-all-3.17.3.tar.gz
67+
echo "Extracting Protobuf..."
68+
tar xzvf /tmp/protobuf-all-3.17.3.tar.gz -C /tmp
69+
cd /tmp/protobuf-3.17.3
70+
echo "Configuring Protobuf (CMake)..."
71+
mkdir build_cmake
72+
cd build_cmake
73+
cmake ../cmake -DCMAKE_INSTALL_PREFIX=/usr/local -Dprotobuf_BUILD_TESTS=OFF
74+
echo "Building Protobuf..."
75+
make -j$(nproc)
76+
echo "Installing Protobuf..."
77+
sudo make install
78+
cd ${{ github.workspace }}
79+
rm -rf /tmp/protobuf-3.17.3 /tmp/protobuf-all-3.17.3.tar.gz
80+
81+
# --- Catch2 Installation Step Removed ---
82+
83+
# Initialize CodeQL AFTER dependencies are installed and BEFORE the project build
84+
- name: Initialize CodeQL
85+
uses: github/codeql-action/init@v3
86+
with:
87+
languages: ${{ matrix.language }}
88+
build-mode: ${{ matrix.build-mode }}
89+
# queries: security-extended,security-and-quality # Optional
90+
91+
# === Build Project Steps ===
92+
- name: Build localproxy project
93+
shell: bash
94+
run: |
95+
echo "Creating build directory for localproxy..."
96+
mkdir build
97+
cd build
98+
echo "Configuring localproxy with CMake (tests disabled)..."
99+
# Ensure BUILD_TESTS=OFF is used
100+
cmake .. -DBUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
101+
echo "Building localproxy with make..."
102+
make -j$(nproc)
103+
104+
# Perform the CodeQL analysis AFTER the build is complete
105+
- name: Perform CodeQL Analysis
106+
uses: github/codeql-action/analyze@v3
107+
with:
108+
category: "/language:${{matrix.language}}"

0 commit comments

Comments
 (0)