Skip to content

Commit

Permalink
CI(CodeQL): Run all analysis concurrently, but don't build for python
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Jan 14, 2024
1 parent ea400bd commit dcd3644
Showing 1 changed file with 39 additions and 13 deletions.
52 changes: 39 additions & 13 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ on:
# Check every Saturday at 18:36
- cron: 36 18 * * 6

permissions: {}

jobs:
analyze:
name: ${{ matrix.language }}
name: Analyze
runs-on: ubuntu-22.04
permissions:
security-events: write
actions: read
contents: read

strategy:
fail-fast: false
matrix:
# C is included in cpp, no separate C language available on CodeQL
language:
- cpp
- c-cpp
- python

concurrency:
Expand All @@ -38,37 +43,58 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml

- name: Get dependencies
python-version: '3.x'
cache: pip
cache-dependency-path: |
.github/workflows/python_requirements.txt
.github/workflows/optional_requirements.txt
- name: Install non-Python dependencies
if: ${{ matrix.language == 'c-cpp' }}
run: |
sudo apt-get update -y
sudo apt-get install -y wget git gawk findutils
xargs -a <(awk '! /^ *(#|$)/' ".github/workflows/apt.txt") -r -- \
sudo apt-get install -y --no-install-recommends --no-install-suggests
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install \
-r .github/workflows/python_requirements.txt \
-r .github/workflows/optional_requirements.txt
# Set the `CODEQL-PYTHON` environment variable to the Python executable
# that includes the dependencies
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
setup-python-dependencies: false

- name: Create installation directory
run: |
mkdir $HOME/install
mkdir "${HOME}/install"
- name: Set LD_LIBRARY_PATH for compilation
run: |
echo "LD_LIBRARY_PATH=$HOME/install/lib" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=${HOME}/install/lib" >> $GITHUB_ENV
- name: Set number of cores for compilation
run: |
echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV
- name: Build
if: ${{ matrix.language == 'c-cpp' }}
env:
CFLAGS: -std=gnu11
CXXFLAGS: -std=c++11
run: .github/workflows/build_ubuntu-22.04.sh $HOME/install
run: .github/workflows/build_ubuntu-22.04.sh "${HOME}/install"

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"

0 comments on commit dcd3644

Please sign in to comment.