Skip to content

Resolve issues on workflows #652

Resolve issues on workflows

Resolve issues on workflows #652

---
# SPDX-FileCopyrightText: © 2016-2024 Jürgen Mülbert
#
# SPDX-License-Identifier: MIT
#
# 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 Analysis"
on: # yamllint disable-line rule:truthy
push:
branches: [main, develop, release, improve_build-workflow]
paths:
- "**.{cpp,h,hpp,py,ts,qml}"
- cmake/**
- apps/**
- CMakeLists.txt
- conanfile.py
- ".github/workflows/codeql-analysis.yml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**.{cpp,h,hpp,py,ts,qml}"
- cmake/**
- apps/**
- CMakeLists.txt
- ".github/workflows/codeql-analysis.yml"
schedule:
- cron: "38 0 * * 5"
env:
TARGET_NAME: "jmbde"
QT_INSTALL_PREFIX: ${{ github.workspace }}/install
QT_VERSION: 6.5.3
permissions:
contents: read
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
analyze:
# Skip any PR created by dependabot to avoid permission issues:
if: (github.actor != 'dependabot[bot]')
name: "CodeQL Analyze"
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
language: ["cpp", "python"]
std: [20]
formatting: ["std::format"]
build_type: ["Debug"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
compiler-cc:
- clang-15
compiler-cxx:
- clang++-15
lib:
- "libc++"
cxx-modules:
- false
conan_config:
- ""
CMAKE_GENERATOR:
- "Ninja Multi-Config"
QT_ARCH:
- "gcc_64"
QT_HOST:
- "linux"
QT_ARCHIVES:
- ""
QT_MODULES:
- ""
QT_TOOLS:
- ""
env:
CC: ${{ matrix.compiler-cc }}
CXX: ${{ matrix.compiler-cxx }}
CMAKE_GENERATOR: ${{ matrix.CMAKE_GENERATOR }}
CMAKE_BUILD_TYPE: ${{ matrix.build_type }}
steps:
- name: "🧰 Checkout Source Code"
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "🧰 Setup Cache-ID with date for unix-like systems"
if: matrix.language == 'cpp'
run: echo "cache_id=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_ENV
- name: "⚙️️ Cache conan data"
if: matrix.language == 'cpp' && always()
uses: actions/cache@v4
env:
cache-name: cache-conan-data
with:
path: ~/.conan2/p
key: build-${{ matrix.os }}-${{ matrix.formatting }}-${{ matrix.lib }}-${{ matrix.build_type }}-${{ matrix.compiler.version }}-${{ matrix.std }}-${{ env.cache_id }}
restore-keys: |
build-${{ matrix.os }}-${{ matrix.formatting }}-${{ matrix.lib }}-${{ matrix.build_type }}-${{ matrix.compiler.version }}-${{ matrix.std }}-
build-${{ matrix.os }}-${{ matrix.formatting }}-${{ matrix.lib }}-${{ matrix.build_type }}-${{ matrix.compiler.version }}-
build-${{ matrix.os }}-${{ matrix.formatting }}-${{ matrix.lib }}-${{ matrix.build_type }}-
build-${{ matrix.os }}-${{ matrix.formatting }}-${{ matrix.lib }}-
build-${{ matrix.os }}-${{ matrix.formatting }}-
build-${{ matrix.os }}-${{ matrix.formatting }}-
build-${{ matrix.os }}-
- name: "Setup CCache for Linux"
if: matrix.language == 'cpp'
uses: hendrikmuhs/ccache-action@v1
with:
key: ${{ matrix.os }}-{{matrix.CMAKE_BUILD_TYPE}}
max-size: 50M
- name: "🟨 Setup Python"
uses: actions/setup-python@v5
with:
# Read python version from a file .python-version
python-version-file: ".python-version"
# check-latest: true
cache: pip
- name: "Update pip"
shell: bash
run: |
pip install --upgrade pip
- name: "🧰 Install Ninja"
if: matrix.language == 'cpp'
shell: bash
run: |
pip install --upgrade ninja
- name: "🧰 Setup Conan"
if: matrix.language == 'cpp'
run: |
pip install --upgrade conan
- name: "Configure Conan"
if: matrix.language == 'cpp'
shell: bash
run: |
conan profile detect --force
sed -i.backup '/^\[settings\]$/,/^\[/ s/^compiler.cppstd=.*/compiler.cppstd=${{ matrix.std }}/' ~/.conan2/profiles/default
sed -i.backup '/^\[settings\]$/,/^\[/ s/^build_type=.*/build_type=${{ matrix.build_type }}/' ~/.conan2/profiles/default
conan profile show -pr default
- name: "🧰 Install Qt Version ${{ env.QT_VERSION }}"
if: matrix.language == 'cpp'
uses: jurplel/install-qt-action@v3
with:
version: ${{ env.QT_VERSION }}
host: ${{ matrix.QT_HOST}}
target: "desktop"
arch: ${{ matrix.QT_ARCH }}
dir: "${{ env.QT_INSTALL_PREFIX}}"
install-deps: "true"
modules: ${{ matrix.QT_MODULES }}
archives: ${{ matrix.QT_ARCHIVES }}
cache: "true"
cache-key-prefix: "${{ runner.os }}-install-qt-action"
setup-python: "false"
tools: ${{ matrix.QT_TOOLS }}
set-env: "true"
tools-only: "false"
- name: restore ccache
if: matrix.language == 'cpp'
uses: pat-s/always-upload-cache@v3.0.11
with:
path: ${{ github.workspace }}/ccache
key: ccache-${{matrix.os}}-${{matrix.compiler}}-${{ env.QT_VERSION }}-${{ github.sha }}
restore-keys: ccache-${{matrix.os}}-${{matrix.compiler}}-${{ env.QT_VERSION }}
- name: check ccache stats prior to build
if: matrix.language == 'cpp'
run: ccache --zero-stats --show-stats
- name: "Add GCC problem matcher"
if: matrix.language == 'cpp'
# make sure coverage is only enabled for Debug builds, since it sets -O0 to make sure coverage
# has meaningful results
uses: ammaraskar/gcc-problem-matcher@master
- name: "🧰 Let Conan generate Deps"
if: matrix.language == 'cpp'
run: |
conan install . --build=missing --settings=build_type=${{matrix.build_type}}
env:
CMAKE_GENERATOR: ${{matrix.CMAKE_GENERATOR}}
CMAKE_PREFIX_PATH: "${{ env.Qt6_DIR }}/lib/cmake"
- name: "🍎 🚧 Configure CMake build for Linux}"
if: matrix.language == 'cpp'
shell: bash
run: |
APPIMAGE_DST_PATH=$GITHUB_WORKSPACE/${TARGET_NAME}.AppDir
mkdir -p ${APPIMAGE_DST_PATH}
cmake -S . -B build/${{matrix.build_type}} \
-DCMAKE_TOOLCHAIN_FILE=generators/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DCMAKE_INSTALL_PREFIX:PATH="${APPIMAGE_DST_PATH}/usr"
env:
CMAKE_GENERATOR: ${{matrix.CMAKE_GENERATOR}}
CMAKE_PREFIX_PATH: "${{ env.Qt6_DIR }}/lib/cmake"
# 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: "🍎 🐧 🚧 Build and Install"
if: matrix.language == 'cpp'
shell: bash
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cmake --build build/${{matrix.build_type}} \
--config ${{matrix.build_type}} \
--target install \
--parallel $(sysctl -n hw.logicalcpu)
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: "📦 Autobuild"
if: matrix.language != 'cpp'
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2