test: verify ScopeTimer logs and label fallbacks #22
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 & SonarQube | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| types: [ opened, synchronize, reopened ] | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| jobs: | |
| build: | |
| name: GCC 15 • Build • Test • Coverage • Sonar | |
| runs-on: ubuntu-latest | |
| # Use a container that already has GCC 15 | |
| container: | |
| image: gcc:15 | |
| env: | |
| # Must match your sonar-project.properties: | |
| # sonar.cfamily.compile-commands=build/bw-output/compile_commands.json | |
| BUILD_WRAPPER_OUT_DIR: build/bw-output | |
| CTEST_OUTPUT_ON_FAILURE: "1" | |
| steps: | |
| - name: Install prerequisites (cmake, ninja, coverage tools, git, ca-certs, unzip) | |
| run: | | |
| apt-get update | |
| DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
| cmake ninja-build gcovr lcov git ca-certificates unzip jq | |
| update-ca-certificates | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Toolchain sanity check | |
| run: | | |
| gcc --version | |
| g++ --version | |
| gcov --version || true | |
| ninja --version | |
| cmake --version | |
| - name: Install Sonar Build Wrapper | |
| uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v6 | |
| # Equivalent to: rm -rf build && cmake -S . -B build | |
| - name: Configure (CMake • Debug • Ninja • GCC 15) | |
| env: | |
| CC: gcc | |
| CXX: g++ | |
| run: | | |
| rm -rf build "${BUILD_WRAPPER_OUT_DIR}" | |
| cmake -S . -B build -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=Debug \ | |
| -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ | |
| -DCMAKE_C_COMPILER="${CC}" \ | |
| -DCMAKE_CXX_COMPILER="${CXX}" | |
| # Equivalent to: cmake --build build -j | |
| - name: Build (unwrapped compile) | |
| run: | | |
| cmake --build build -j"$(nproc)" | |
| # Equivalent to: cmake --build build --target sonar_bw -j | |
| - name: Build (CMake target sonar_bw wrapped by build-wrapper) | |
| run: | | |
| cmake --build build --target sonar_bw -j"$(nproc)" | |
| env: | |
| # Ensure the install step put it on PATH; the CMake target will also auto-detect. | |
| BUILD_WRAPPER_OUT_DIR: ${{ env.BUILD_WRAPPER_OUT_DIR }} | |
| # Equivalent to: ctest --test-dir build --output-on-failure | |
| - name: Test | |
| run: | | |
| ctest --test-dir build --output-on-failure | |
| # Equivalent to: cmake --build build --target coverage | |
| - name: Coverage | |
| run: | | |
| cmake --build build --target coverage | |
| # Equivalent to: sonar-scanner | |
| - name: SonarQube Scan | |
| uses: SonarSource/sonarqube-scan-action@v6 | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| SONAR_HOST_URL: https://sonarcloud.io | |
| with: | |
| # Keep properties-file defaults | |
| args: > | |
| --define sonar.organization=stephenlclarke | |
| --define sonar.projectKey=stephenlclarke_ScopeTimer |