Refactoring to improve flow and readability #66
Workflow file for this run
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
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| name: Build | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| BUILD_TYPE: Release | |
| BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed | |
| jobs: | |
| build: | |
| name: Build & Test | |
| runs-on: macos-26 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Set up Homebrew | |
| id: set-up-homebrew | |
| uses: Homebrew/actions/setup-homebrew@main | |
| - name: Install dependencies | |
| run: bash ./.github/workflows/scripts/brew.sh | |
| - name: Build C++ Libraries | |
| run: bash ./scripts/build_dep.sh | |
| - name: Select Xcode version | |
| run: sudo xcode-select -switch /Applications/Xcode.app | |
| - name: Run tests | |
| run: > | |
| OTHER_CFLAGS="-fprofile-instr-generate -fcoverage-mapping" | |
| OTHER_CPLUSPLUSFLAGS="-fprofile-instr-generate -fcoverage-mapping" | |
| OTHER_SWIFT_FLAGS="-profile-generate -profile-coverage-mapping" | |
| LLVM_PROFILE_FILE="/tmp/coverage.profraw" | |
| CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | |
| xcodebuild | |
| -scheme tests | |
| -destination 'platform=macOS,arch=arm64' | |
| -resultBundlePath TestResult/ | |
| -enableCodeCoverage YES | |
| -derivedDataPath "${RUNNER_TEMP}/Build/DerivedData" | |
| -parallelizeTargets | |
| -jobs "$(sysctl -n hw.logicalcpu)" | |
| clean build test | |
| | xcpretty -r junit && exit ${PIPESTATUS[0]} | |
| - name: Convert coverage report to sonarqube format | |
| run: > | |
| bash ./.github/workflows/scripts/xccov-to-sonarqube-generic.sh *.xcresult/ > sonarqube-generic-coverage.xml | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: sonarqube-coverage | |
| path: sonarqube-generic-coverage.xml | |
| retention-days: 1 | |
| sonar-scan: | |
| name: SonarCloud Scan | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| # fetch-depth: 0 gives Sonar full git history for blame-based new-code analysis. | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install dependencies | |
| run: sudo apt install -y libssl-dev libpq-dev | |
| # Ubuntu's apt Boost (1.83 on 24.04) predates Boost.Redis, which was added | |
| # in Boost 1.84, so <boost/redis.hpp> is absent. Install a newer Boost. | |
| # Boost.Redis/Asio are header-only, so we only need the headers plus the | |
| # CMake package config — building just Boost.System generates both quickly. | |
| - name: Install Boost >= 1.84 (for Boost.Redis) | |
| run: | | |
| BOOST_VERSION=1.86.0 | |
| BOOST_DIR="boost_${BOOST_VERSION//./_}" | |
| wget -q "https://archives.boost.io/release/${BOOST_VERSION}/source/${BOOST_DIR}.tar.gz" | |
| tar xzf "${BOOST_DIR}.tar.gz" | |
| cd "${BOOST_DIR}" | |
| ./bootstrap.sh > /dev/null | |
| # -d0 silences per-action output (otherwise b2 prints one line per | |
| # copied header — ~15k lines just for the header install). | |
| sudo ./b2 install -d0 --prefix=/usr/local --with-system -j"$(nproc)" | |
| - name: Check compiler version, for debugging | |
| run: | | |
| g++ --version | |
| cmake --version | |
| - name: Build C++ Libraries | |
| run: bash ./scripts/build_dep.sh | |
| # SonarQube Server and Cloud (formerly SonarQube and SonarCloud) is a widely used static | |
| # analysis solution for continuous code quality and security inspection. | |
| # This action now supports and is the official entrypoint for scanning C++ projects via GitHub actions. | |
| # https://github.com/SonarSource/sonarqube-scan-action | |
| - name: Install Build Wrapper | |
| uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v4.2.1 | |
| # This step installs the SonarQube build wrapper, which is necessary for analyzing C/C++ projects. | |
| # Lands at ./artifact/sonarqube-generic-coverage.xml so the existing | |
| # sonar.coverageReportPaths argument keeps working unchanged. | |
| - name: Download coverage artifact from build job | |
| uses: actions/download-artifact@v5 | |
| with: | |
| name: sonarqube-coverage | |
| path: artifact | |
| # Configures the CMake build system, specifying the source directory and build directory, and setting the build type | |
| - name: Configure CMake | |
| run: cmake -S ${{github.workspace}} -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | |
| # Runs the build wrapper to capture build commands and outputs them to the specified directory. Then builds the project using CMake | |
| - name: Run build-wrapper | |
| run: | | |
| build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --clean-first | |
| # Performs the SonarQube scan using the scan action. Uses captured build commands for analysis and requires GitHub and SonarQube tokens for authentication | |
| - name: SonarQube Scan | |
| uses: SonarSource/sonarqube-scan-action@v4.2.1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| with: | |
| args: > | |
| --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" | |
| --define sonar.coverageReportPaths=artifact/sonarqube-generic-coverage.xml |