Add llm #583
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| branches: ["main"] | |
| paths: | |
| - "**/*.h" | |
| - "**/*.hpp" | |
| - "**/*.cpp" | |
| - "**/*.cmake" | |
| - .github/workflows/*.yml | |
| pull_request: | |
| branches: ["main"] | |
| paths: | |
| - "**/*.h" | |
| - "**/*.hpp" | |
| - "**/*.cpp" | |
| - "**/*.cmake" | |
| - .github/workflows/*.yml | |
| jobs: | |
| clang-format: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history to ensure base SHA is available | |
| - name: Install clang-format | |
| run: | | |
| sudo apt-get install clang-format-18 -y | |
| - name: Run clang-format style check for modified .cpp|.h|.hpp files | |
| run: | | |
| CHANGED_FILES=$(git diff --name-only --diff-filter=M ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -E '\.(cpp|h|hpp)$' || true) | |
| echo | |
| if [ -n "$CHANGED_FILES" ]; then | |
| clang-format --dry-run --Werror $CHANGED_FILES | |
| else | |
| echo "No C++ files to check with clang-format." | |
| fi | |
| cmake-format: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Format CMake files | |
| id: cmake-format | |
| uses: PuneetMatharu/cmake-format-lint-action@v1.0.4 | |
| with: | |
| args: --config-files .cmake-format.yaml --check | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - { | |
| name: "Windows Latest MSVC", | |
| os: windows-latest, | |
| tag: msvc, | |
| cc: "cl", | |
| cxx: "cl", | |
| environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
| "with_cxx": "", | |
| } | |
| - { | |
| name: "Windows Latest MSVC with cxx_build", | |
| os: windows-latest, | |
| tag: msvc, | |
| cc: "cl", | |
| cxx: "cl", | |
| environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", | |
| "with_cxx": "_build_cxx", | |
| } | |
| - { | |
| name: "Ubuntu Latest GCC", | |
| os: ubuntu-24.04, | |
| tag: gnu, | |
| cc: "gcc", | |
| cxx: "g++", | |
| "with_cxx": "", | |
| } | |
| - { | |
| name: "Ubuntu Latest GCC with cxx_build", | |
| os: ubuntu-24.04, | |
| tag: gnu, | |
| cc: "gcc", | |
| cxx: "g++", | |
| "with_cxx": "_build_cxx", | |
| } | |
| - { | |
| name: "Ubuntu Latest CLang", | |
| os: ubuntu-24.04, | |
| tag: "clang", | |
| cc: "clang", | |
| cxx: "clang++", | |
| "with_cxx": "", | |
| } | |
| - { | |
| name: "Ubuntu Latest CLang cxx_build", | |
| os: ubuntu-24.04, | |
| tag: "clang", | |
| cc: "clang", | |
| cxx: "clang++", | |
| "with_cxx": "_build_cxx", | |
| } | |
| name: ${{ matrix.config.name }} | |
| needs: [clang-format, cmake-format] | |
| runs-on: ${{ matrix.config.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: "true" | |
| - name: Get tags | |
| run: git fetch --tags origin | |
| - name: Install dependencies (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: sudo apt install -y gcc g++ clang ninja-build python3-pip grep | |
| - name: Install Qt (Ubuntu) | |
| if: runner.os == 'Linux' | |
| uses: jurplel/install-qt-action@v3 | |
| with: | |
| aqtversion: "==3.2.*" | |
| dir: "${{github.workspace}}/Qt/" | |
| install-deps: "true" | |
| version: "6.8.2" | |
| host: "linux" | |
| target: "desktop" | |
| arch: "linux_gcc_64" | |
| modules: "qt5compat" | |
| archives: "icu qtbase qtdeclarative qtsvg" | |
| cache: "true" | |
| cache-key-prefix: "install-qt-action-linux" | |
| - name: Install Qt (Windows) | |
| if: runner.os == 'Windows' | |
| uses: jurplel/install-qt-action@v3 | |
| with: | |
| aqtversion: "==3.2.*" | |
| dir: "${{github.workspace}}/Qt/" | |
| install-deps: "true" | |
| version: "6.8.2" | |
| host: "windows" | |
| target: "desktop" | |
| arch: "win64_msvc2022_64" | |
| modules: "qt5compat" | |
| archives: "qtbase qtdeclarative qtsvg" | |
| cache: "true" | |
| cache-key-prefix: "install-qt-action-windows" | |
| - name: Install conan & gcovr (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| python3 -m venv venv | |
| source venv/bin/activate | |
| pip install conan gcovr | |
| - name: Install conan (Windows) | |
| if: runner.os == 'Windows' | |
| run: python -m pip install conan && conan profile detect | |
| shell: bash | |
| - name: Cache Conan packages (Ubuntu) | |
| if: runner.os == 'Linux' | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.conan2 | |
| key: conan-${{ runner.os }}-${{ matrix.config.tag }}-${{ hashFiles('**/conanfile.txt') }} | |
| - name: Cache Conan packages (Windows) | |
| if: runner.os == 'Windows' | |
| uses: actions/cache@v4 | |
| with: | |
| path: "C:\\Users\\runneradmin\\.conan2\\" | |
| key: conan-${{ runner.os }}-${{ matrix.config.tag }}-${{ hashFiles('**/conanfile.txt') }} | |
| - name: Install conan dependencies (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| source venv/bin/activate | |
| conan install . -s build_type=Release -of .conan/${{ matrix.config.cc }} --build=missing -pr:a .conan/${{ matrix.config.cc }}/profile | |
| - name: Install conan dependencies (Windows) | |
| if: runner.os == 'Windows' | |
| run: conan install . --build missing -s build_type=Release -s compiler.cppstd=20 -c tools.cmake.cmaketoolchain:generator=Ninja -of .conan/msvc/ | |
| shell: bash | |
| - name: Download llvm build cache (Ubuntu) | |
| if: runner.os == 'Linux' && matrix.config.with_cxx == '_build_cxx' | |
| uses: robinraju/release-downloader@v1.12 | |
| with: | |
| tag: "2.0.0" | |
| fileName: "clang-19.1.7-linux.zip" | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| out-file-path: ${{github.workspace}}/external | |
| extract: true | |
| - name: Download llvm build cache (Windows) | |
| if: runner.os == 'Windows' && matrix.config.with_cxx == '_build_cxx' | |
| uses: robinraju/release-downloader@v1.12 | |
| with: | |
| tag: "2.0.0" | |
| fileName: "clang-19.1.7-windows.zip" | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| out-file-path: ${{github.workspace}}/external | |
| extract: true | |
| - name: Install llvm (Ubuntu) | |
| if: runner.os == 'Linux' && matrix.config.with_cxx == '_build_cxx' | |
| run: tar -xvf ${{github.workspace}}/external/clang-19.1.7-linux.tar.gz -C ${{github.workspace}}/external | |
| - name: Configure CMake (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: cmake --preset="ci_${{ matrix.config.tag }}_release${{ matrix.config.with_cxx }}" | |
| - name: Configure CMake (Windows) | |
| if: runner.os == 'Windows' | |
| env: | |
| CMAKE_PREFIX_PATH: ${{env.Qt5_DIR}} | |
| run: | | |
| call "${{ matrix.config.environment_script }}" | |
| cmake --preset="ci_${{ matrix.config.tag }}_release${{ matrix.config.with_cxx }}" | |
| shell: cmd | |
| - name: Build (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| set -eo pipefail # Stop on first error | |
| cmake --build ${{github.workspace}}/build | tee ${{github.workspace}}/build/build.log | |
| exit ${PIPESTATUS[0]} | |
| - name: Build (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| call "${{ matrix.config.environment_script }}" | |
| cmake --build ${{github.workspace}}/build > ${{github.workspace}}/build/build.log 2>&1 || (type ${{github.workspace}}/build/build.log && exit /b %errorlevel%) | |
| shell: cmd | |
| - name: Upload build logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-logs-${{ matrix.config.tag }}-${{ matrix.build_type }} | |
| path: ${{github.workspace}}/build/build.log | |
| retention-days: 7 | |
| - name: Count warnings (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: grep -c "warning:" ${{github.workspace}}/build/build.log | |
| - name: Test (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: ctest -Q --test-dir ${{github.workspace}}/build --output-junit ${{github.workspace}}/build/report.xml | |
| - name: Test (Windows) | |
| if: runner.os == 'Windows' | |
| run: ctest --test-dir ${{github.workspace}}/build --exclude-regex "unittests\.core\.GenerateRandomString\.goodCase|unittests\.core\.CommandlineCommandIndexFix\.projectIsAbsent|unittests\.core\.CommandlineCommandIndexFix\.projectIsInvalidProj|unittests\.core\.CommandLineParserConfig\.projectFileMissingExtention|unittests\.core\.CommandLineParserConfig\.emptyProjectFile|unittests\.lib\.BookmarkControllerFix\.displayBookmarksFor2|unittests\.lib\.FileHandler\.goodCaseEmptyFile|unittests\.lib\.FileHandler\.emptyFileCanNotCreated|unittests\.lib\.FileHandler\.goodCaseFromBuffer|unittests\.lib\.FileHandler\.PassZeroToFromBuffer|unittests\.lib\.FileHandler\.goodCaseRandomData|unittests\.lib\.FileHandler\.PassZeroToRandomData|unittests\.lib_gui\.utilityAppTestSuite\.searchPath|QtSelfRefreshIconButtonTestSuite" --output-junit ${{github.workspace}}/build/report.xml | |
| shell: cmd | |
| - name: Upload ctest logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ctest-logs-${{ matrix.config.tag }}-${{ matrix.build_type }} | |
| path: ${{github.workspace}}/build/report.xml | |
| retention-days: 7 | |
| - name: Publish Test Report for ${{ matrix.config.name }} | |
| uses: mikepenz/action-junit-report@v4 | |
| if: runner.os == 'Linux' | |
| with: | |
| report_paths: ${{github.workspace}}/build/report.xml | |
| include_passed: true | |
| detailed_summary: true | |
| - name: Upload build directory as artifact | |
| if: runner.os == 'Linux' && matrix.config.tag == 'gnu' && matrix.config.with_cxx == '_build_cxx' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifact-${{ github.event.number }} | |
| path: | | |
| ${{ github.workspace }}/build/compile_commands.json | |
| ${{ github.workspace }}/build/Sourcetrail_lib_gui_autogen | |
| ${{ github.workspace }}/build/src | |
| clang_tidy: | |
| needs: build | |
| if: github.event_name == 'pull_request' | |
| uses: ./.github/workflows/clang_tidy.yml | |
| secrets: inherit | |
| cppcheck: | |
| needs: build | |
| if: github.event_name == 'pull_request' | |
| uses: ./.github/workflows/cppcheck.yaml | |
| secrets: inherit |