ci: use CODECOV_TOKEN on protected branch #9
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"] | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| build_type: [Debug, Release] | |
| include: | |
| - os: ubuntu-latest | |
| cxx: g++ | |
| - os: macos-latest | |
| cxx: clang++ | |
| - os: windows-latest | |
| cxx: cl | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Ninja | |
| uses: seanmiddleditch/gha-setup-ninja@v6 | |
| - name: Setup MSVC dev cmd | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Configure | |
| shell: bash | |
| run: | | |
| cmake -S . -B build -G Ninja \ | |
| -DCMAKE_BUILD_TYPE='${{ matrix.build_type }}' \ | |
| -DCMAKE_CXX_COMPILER='${{ matrix.cxx }}' | |
| - name: Build | |
| shell: bash | |
| run: cmake --build build --parallel | |
| - name: Test | |
| shell: bash | |
| run: ctest --test-dir build --output-on-failure | |
| coverage: | |
| name: Coverage (Codecov) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Ninja | |
| uses: seanmiddleditch/gha-setup-ninja@v6 | |
| - name: Install lcov | |
| shell: bash | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y lcov | |
| - name: Configure (coverage) | |
| shell: bash | |
| run: | | |
| cmake -S . -B build -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=Debug \ | |
| -DCMAKE_CXX_COMPILER=g++ \ | |
| -DCLASP_BUILD_EXAMPLES=ON \ | |
| -DCLASP_ENABLE_COVERAGE=ON | |
| - name: Build | |
| shell: bash | |
| run: cmake --build build --parallel | |
| - name: Test | |
| shell: bash | |
| run: ctest --test-dir build --output-on-failure | |
| - name: Generate coverage (lcov) | |
| shell: bash | |
| run: | | |
| lcov --capture --directory build --output-file coverage.info \ | |
| --rc branch_coverage=1 \ | |
| --rc geninfo_unexecuted_blocks=1 \ | |
| --ignore-errors mismatch | |
| lcov --remove coverage.info '/usr/*' '*/examples/*' --output-file coverage.info \ | |
| --rc branch_coverage=1 \ | |
| --ignore-errors unused | |
| lcov --list coverage.info --rc branch_coverage=1 | |
| - name: Upload to Codecov | |
| if: github.event_name == 'push' | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.info | |
| fail_ci_if_error: true | |
| verbose: true |