CI #41
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| schedule: | |
| - cron: "0 0 * * *" # Run daily at midnight UTC | |
| workflow_dispatch: | |
| jobs: | |
| format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang-format | |
| - name: Check C++ formatting | |
| run: | | |
| find src include tests -name "*.cpp" -o -name "*.h" | xargs clang-format --dry-run -Werror | |
| lint: | |
| runs-on: ubuntu-latest | |
| needs: format | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y clang-tidy cmake build-essential | |
| - name: Configure CMake | |
| run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | |
| - name: Run static analysis | |
| run: | | |
| find src tests -name "*.cpp" -exec clang-tidy -p build {} \; | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cmake build-essential | |
| - name: Configure | |
| run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug | |
| - name: Build | |
| run: cmake --build build | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential cmake strace | |
| - name: Configure | |
| run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug | |
| - name: Build | |
| run: cmake --build build | |
| - name: Run all tests | |
| run: ctest --test-dir build --output-on-failure -V | |
| ci-success: | |
| runs-on: ubuntu-latest | |
| needs: [format, lint, build, test] | |
| if: always() | |
| steps: | |
| - name: Check all jobs | |
| run: | | |
| if [[ "${{ needs.format.result }}" != "success" ]]; then | |
| echo "Format check failed" | |
| exit 1 | |
| fi | |
| if [[ "${{ needs.lint.result }}" != "success" ]]; then | |
| echo "Lint check failed" | |
| exit 1 | |
| fi | |
| if [[ "${{ needs.build.result }}" != "success" ]]; then | |
| echo "Build failed" | |
| exit 1 | |
| fi | |
| if [[ "${{ needs.test.result }}" != "success" ]]; then | |
| echo "Tests failed" | |
| exit 1 | |
| fi | |
| echo "All checks passed!" |