Skip to content

Fixed ci issue

Fixed ci issue #131

name: Static Analysis
on:
workflow_dispatch:
push:
branches: [ "master", "experimental" ]
pull_request:
branches: [ "master", "experimental" ]
env:
BUILD_TYPE: Release
jobs:
cppcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run Cppcheck
run: |
sudo apt-get install -y cppcheck
cppcheck --enable=all --inconclusive --force --language=c++ --file-list=<(find lwlog/include/ -name "*.cpp" -o -name "*.h") &> \
"${{ runner.workspace }}/cppcheck.txt"
continue-on-error: true
- name: Upload Cppcheck Results
uses: actions/upload-artifact@v4
with:
name: cppcheck_results
path: "${{ runner.workspace }}/cppcheck.txt"
clang-tidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: sudo apt-get install -y build-essential cmake
- name: Create Build Environment
run: cmake -E make_directory "${{runner.workspace}}/build"
- name: Generate compile_commands.json
run: |
mkdir -p build
cd build
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1
- name: Run Clang-Tidy
run: |
sudo apt-get install -y clang-tidy
find lwlog/include/ -name "*.cpp" -o -name "*.h" | xargs clang-tidy -p=build/compile_commands.json &> \
"${{ runner.workspace }}/clang-tidy.txt"
continue-on-error: true
- name: Upload Clang-Tidy Results
uses: actions/upload-artifact@v4
with:
name: clangtidy_results
path: "${{ runner.workspace }}/clang-tidy.txt"
sonar-scanner:
runs-on: ubuntu-latest
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install GCC
run: sudo apt-get install -y gcc g++
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v3
- name: Create Build Environment
run: cmake -E make_directory "${{ runner.workspace }}/build"
- name: Configure GCC Build
working-directory: "${{ runner.workspace }}/build"
run: |
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 "${{ github.workspace }}"
- name: Build with GCC (with build-wrapper)
working-directory: "${{ runner.workspace }}/build"
run: |
build-wrapper-linux-x86-64 --out-dir "${{ env.BUILD_WRAPPER_OUT_DIR }}" cmake --build . --config ${{ env.BUILD_TYPE }}
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
-Dsonar.cfamily.compile-commands="${{ runner.workspace }}/build/compile_commands.json" \
-Dsonar.projectKey=ChristianPanov_lwlog \
-Dsonar.organization=christianpanov \
-Dsonar.sources=lwlog/src