Skip to content

CodeQL

CodeQL #686

# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [main]
paths-ignore:
- "**/*.md"
- "**/*.rst"
- "**/*.py"
- ".readthedocs.yaml"
pull_request:
branches: [main]
paths-ignore:
- "**/*.md"
- "**/*.rst"
- "**/*.py"
- ".readthedocs.yaml"
schedule:
- cron: "21 9 * * 3"
jobs:
analyze:
env:
buildDir: "${{ github.workspace }}/build/"
vcpkg-tag: "2023.06.20"
VCPKG_ROOT: "${{ github.workspace }}/vcpkg/"
VCPKG_DEFAULT_BINARY_CACHE: "${{ github.workspace }}/vcpkg/.cache"
CCACHE_DIR: "${{ github.workspace }}/ccache/"
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ["cpp"]
steps:
- name: Get current date
run: |
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Install gcc-11
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt install gcc-11 g++-11 ccache
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
- name: Set up ccache
run: |
ccache --set-config=cache_dir=${{ github.workspace }}/ccache
ccache --set-config=max_size=500M
ccache --set-config=compression=true
- name: Checkout repository
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Install latest CMake.
uses: lukka/get-cmake@latest
- name: download vcpkg
run: |
git clone https://github.com/microsoft/vcpkg ${{ github.workspace }}/vcpkg || true
pushd vcpkg
./bootstrap-vcpkg.sh
popd
- name: cache vcpkg
id: cache-vcpkg
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/vcpkg/.cache
${{ github.workspace }}/ccache
key: ${{ runner.os }}-analyze-${{ env.vcpkg-tag }}-${{ env.DATE }}-${{ hashFiles('vcpkg.json') }}
restore-keys: |
${{ runner.os }}-analyze-
- name: Make cache dir
if: steps.cache-vcpkg.outputs.cache-hit != 'true'
run: mkdir -p "${{ github.workspace }}/vcpkg/.cache"
- name: Configure
run: |
cmake --preset ci-codeql
- name: Build
run: |
cmake --build --preset default
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2