Skip to content

Commit

Permalink
CI(CodeQL): Improve run times and add concurrency groups (OSGeo#3361)
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix authored Jan 15, 2024
1 parent ddf374e commit 4c6be3e
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,49 +16,72 @@ 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:
group: ${{ github.workflow }}-${{
github.event_name == 'pull_request' &&
github.head_ref || github.sha }}-${{ matrix.language }}
cancel-in-progress: true

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'
- 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: 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 4c6be3e

Please sign in to comment.