use non-throwing string parsing when detecting CPU quota #203
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: coverage-docker | |
| on: | |
| push: | |
| branches: [ main, 'v1.*' ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
| jobs: | |
| build-and-test: | |
| timeout-minutes: 15 | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| PRESET: [clang-linux-debug] | |
| WORK_ITEM: [CORO] | |
| HWLOC: [ON,OFF] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: tzcnt/tmc-examples | |
| ref: main | |
| - name: branch-examples | |
| continue-on-error: true | |
| run: git fetch --tags && git checkout ${{env.BRANCH_NAME}} | |
| - name: submodule-clone | |
| run: > | |
| cd submodules | |
| && git clone https://github.com/tzcnt/TooManyCooks.git | |
| - name: submodule-branch-TMC | |
| run: cd submodules/TooManyCooks && git fetch && git checkout ${{env.BRANCH_NAME}} | |
| - name: create coverage dir | |
| run: mkdir -p coverage | |
| - name: build docker image | |
| run: | | |
| cat > Dockerfile.coverage <<EOF | |
| FROM silkeh/clang:19-bookworm AS build | |
| RUN apt-get update && apt-get install -y cmake ninja-build git libhwloc-dev hwloc | |
| WORKDIR /src | |
| COPY . . | |
| RUN cmake -G "Unix Makefiles" -DTMC_AS_SUBMODULE=ON -DTMC_USE_HWLOC=${{matrix.HWLOC}} -DCMD_COMPILE_FLAGS='-Werror;-DTMC_WORK_ITEM=${{matrix.WORK_ITEM}}${{matrix.WORK_ITEM == 'FUNC' && ';-DTMC_TRIVIAL_TASK' || ''}};-fprofile-instr-generate;-fcoverage-mapping' -DCMD_LINK_FLAGS='-Wl,--build-id;-fprofile-instr-generate;-fcoverage-mapping' --preset ${{matrix.PRESET}} . | |
| RUN cmake --build ./build/${{matrix.PRESET}} --parallel 16 --target test_container | |
| WORKDIR /src/build/${{matrix.PRESET}}/tests | |
| EOF | |
| docker build -f Dockerfile.coverage -t tmc-container-tests . | |
| - name: extract binary for coverage | |
| run: | | |
| docker create --name extract tmc-container-tests | |
| mkdir -p ./build/${{matrix.PRESET}}/tests | |
| docker cp extract:/src/build/${{matrix.PRESET}}/tests/test_container ./build/${{matrix.PRESET}}/tests/test_container | |
| docker rm extract | |
| - name: install llvm tools | |
| run: | | |
| wget https://apt.llvm.org/llvm.sh | |
| chmod +x llvm.sh | |
| sudo ./llvm.sh 19 | |
| sudo apt-get install -y llvm-19 | |
| - name: test unlimited | |
| run: | | |
| docker run --rm \ | |
| -v $(pwd)/coverage:/coverage \ | |
| -e LLVM_PROFILE_FILE=/coverage/unlimited.profraw \ | |
| -e TMC_CONTAINER_TEST=unlimited \ | |
| tmc-container-tests \ | |
| ./test_container --gtest_filter='*unlimited*' | |
| - name: test cpu_quota | |
| run: | | |
| docker run --rm \ | |
| --cpus=1.5 \ | |
| -v $(pwd)/coverage:/coverage \ | |
| -e LLVM_PROFILE_FILE=/coverage/cpu_quota.profraw \ | |
| -e TMC_CONTAINER_TEST=cpu_quota \ | |
| -e TMC_EXPECTED_CPUS=1.5 \ | |
| tmc-container-tests \ | |
| ./test_container --gtest_filter='*cpu_quota*:*executor_respects_container_limits*' | |
| - name: test cpuset | |
| if: matrix.HWLOC == 'ON' | |
| run: | | |
| docker run --rm \ | |
| --cpuset-cpus="0,1" \ | |
| -v $(pwd)/coverage:/coverage \ | |
| -e LLVM_PROFILE_FILE=/coverage/cpuset.profraw \ | |
| -e TMC_CONTAINER_TEST=cpuset \ | |
| -e TMC_EXPECTED_CPUS=2 \ | |
| tmc-container-tests \ | |
| ./test_container --gtest_filter='*cpuset*:*executor_respects_container_limits*' | |
| - name: merge (with cpuset) | |
| if: matrix.HWLOC == 'ON' | |
| run: | | |
| llvm-profdata-19 merge -o coverage.profdata \ | |
| coverage/unlimited.profraw \ | |
| coverage/cpu_quota.profraw \ | |
| coverage/cpuset.profraw | |
| - name: merge (without cpuset) | |
| if: matrix.HWLOC == 'OFF' | |
| run: | | |
| llvm-profdata-19 merge -o coverage.profdata \ | |
| coverage/unlimited.profraw \ | |
| coverage/cpu_quota.profraw | |
| - name: export | |
| run: | | |
| llvm-cov-19 export -format=lcov -instr-profile coverage.profdata \ | |
| -object ./build/${{matrix.PRESET}}/tests/test_container \ | |
| -sources ./submodules/TooManyCooks/ \ | |
| > coverage_container_${{matrix.HWLOC}}_${{github.sha}}.txt | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage_container_${{matrix.HWLOC}}_${{github.sha}}.txt | |
| path: coverage_container_${{matrix.HWLOC}}_${{github.sha}}.txt | |
| retention-days: 1 | |
| overwrite: true | |
| # generate coverage files in parallel for different configs | |
| # but upload them together; codecov.io will merge them and show overall coverage | |
| upload: | |
| needs: [build-and-test] | |
| timeout-minutes: 10 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{secrets.CODECOV_TOKEN}} | |
| slug: tzcnt/TooManyCooks |