name: "Test cppcheck"

on: [push, workflow_dispatch, pull_request] # Trigger for every push as well as for every pull request. Yes, this will run stuff twice in case we create a PR from inside this repo. I'm open for better solutions, where I do not have to specify each brach individually for the 'push' trigger.

jobs:
  cppcheck:
    runs-on: ubuntu-latest
    container: "fedora:latest" # Use fedora for an up to date version of cppcheck
    steps:
    - name: Checkout
      uses: actions/checkout@v3
    - name: Update package list
      run: dnf update -y
    - name: Install Dependencies
      run: dnf install -y gcc clang git gcc gdb make openssl-devel cmake libpsl-devel cppcheck meson
    - name: "[Release g++] Build"
      env:
        CPR_ENABLE_CPPCHECK: ON
        # Avoid parallel runs so only the resulting error file is not being written by multiple processes at the same time.
        CMAKE_BUILD_PARALLEL_LEVEL: 1
      uses: ashutoshvarma/action-cmake-build@master
      with:
        build-dir: ${{github.workspace}}/build
        source-dir: ${{github.workspace}}
        cc: gcc
        cxx: g++
        build-type: Release
        run-test: false