Skip to content

Commit a4f0cf5

Browse files
authored
workflows: use dynamic core count (#566)
Improve parallelism in CI by dynamically determining the core count with `getconf`. This replaces hardcoded job limits and allows the builds to adapt to the runner size. Additionally, switch to calling ctest directly, which is simpler. - Add a "Set NUM_CORES" step in the CMake job using `getconf` and print the detected core count to the workflow output. - Use `${{ env.NUM_CORES }}` for CMake build parallelism. - Run tests using `ctest --parallel ${{ env.NUM_CORES }}` directly instead of `cmake --build . --target=test`. - Remove explicit job counts from Bazel, allowing it to use its native auto-detection.
1 parent d55a2d6 commit a4f0cf5

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

.github/workflows/build.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ jobs:
3434
timeout-minutes: 30
3535
steps:
3636
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
37+
- name: Set NUM_CORES
38+
run: |
39+
NUM_CORES=$(getconf _NPROCESSORS_ONLN)
40+
echo "NUM_CORES=$NUM_CORES" >> $GITHUB_ENV
41+
echo "Detected $NUM_CORES cores"
3742
- name: Setup ccache
3843
uses: hendrikmuhs/ccache-action@33522472633dbd32578e909b315f5ee43ba878ce # v1.2.22
3944
with:
@@ -48,13 +53,10 @@ jobs:
4853
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
4954
..
5055
working-directory: build/
51-
- run: cmake --build . --parallel 45
56+
- run: cmake --build . --parallel ${{ env.NUM_CORES }}
5257
working-directory: build/
5358
- if: always()
54-
run: cmake --build . --parallel 45 --target=test
55-
env:
56-
CTEST_OUTPUT_ON_FAILURE: ON
57-
CTEST_PARALLEL_LEVEL: 45
59+
run: ctest --parallel ${{ env.NUM_CORES }} --output-on-failure
5860
working-directory: build/
5961
bazel:
6062
runs-on: ubuntu-latest
@@ -82,7 +84,7 @@ jobs:
8284
- name: Build and Test
8385
run: |
8486
bazel test \
85-
--jobs=45 --keep_going \
87+
--keep_going \
8688
--test_verbose_timeout_warnings --test_output=errors \
8789
//...
8890
working-directory: src

0 commit comments

Comments
 (0)