fix: coverage badge #80
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: | |
| - "*" | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| format: | |
| runs-on: ubuntu-latest | |
| container: | |
| image: milss/tradercppbuild:v1.5 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # - name: Set up clang-format | |
| # run: sudo apt update && sudo apt install -y clang-format | |
| - name: Check code formatting | |
| run: | | |
| set -e | |
| CHANGED_FILES=$(find src tests -name '*.cpp' -o -name '*.h') | |
| FORMAT_ERRORS=0 | |
| for file in $CHANGED_FILES; do | |
| clang-format --dry-run --Werror "$file" || FORMAT_ERRORS=1 | |
| done | |
| if [ "$FORMAT_ERRORS" -ne 0 ]; then | |
| echo "Code is not properly formatted. Please run clang-format." | |
| exit 1 | |
| fi | |
| build_and_test: | |
| needs: format | |
| runs-on: ubuntu-latest | |
| container: | |
| image: milss/tradercppbuild:v1.5 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Restore Conan cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.conan2 | |
| key: ${{ runner.os }}-conan-${{ hashFiles('conanfile.*') }} | |
| restore-keys: | | |
| ${{ runner.os }}-conan- | |
| # - name: Install system dependencies | |
| # run: | | |
| # set -e | |
| # sudo apt update && sudo apt install -y g++ lcov | |
| # pip install conan | |
| - name: Install conan dependencies | |
| run: | | |
| set -e | |
| rm -rf build | |
| conan profile detect --force | |
| conan install . --build=missing -s build_type=Debug | |
| - name: Build and Test | |
| run: | | |
| set -e | |
| cmake --preset=debug | |
| cmake --build --preset=debug | |
| ctest --preset=debug | |
| lcov --gcov-tool gcov \ | |
| --capture \ | |
| --directory . \ | |
| --output-file lcov.info \ | |
| --rc geninfo_unexecuted_blocks=1 \ | |
| --ignore-errors mismatch | |
| # lcov --remove lcov.info '/home/*' '/usr/*' 'tests/*' --output-file lcov_filtered.info | |
| # TODO: need to solve mismatch before proceeding, custom docker image | |
| # TODO: should coverage be published in the case that SonarQube fails? | |
| # - name: Upload coverage to Coveralls | |
| # uses: coverallsapp/github-action@v2 | |
| # with: | |
| # path-to-lcov: lcov.info | |
| # continue-on-error: true | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: lcov.info | |
| - name: SonarQube Scan | |
| uses: SonarSource/sonarqube-scan-action@v6.0.0 | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| continue-on-error: true |