From 04af5dfdef93817930b3ddd239c762543198044e Mon Sep 17 00:00:00 2001 From: Lucas Colley Date: Tue, 17 Jun 2025 00:43:54 +0100 Subject: [PATCH 1/2] DEV: parallel workers task args --- pixi.toml | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/pixi.toml b/pixi.toml index 3782888..e3f14f1 100644 --- a/pixi.toml +++ b/pixi.toml @@ -28,12 +28,14 @@ cwd = "." [feature.build.tasks.build-only] # Just build without configure -cmd = ["cmake", "--build", "build", "--config", "Release"] +cmd = ["cmake", "--build", "build", "--config", "Release", "-j{{ parallel }}"] cwd = "." +args = [{ arg = "parallel", default = "2" }] [feature.build.tasks.build] # Build with default configuration -depends-on = ["configure", "build-only"] +depends-on = ["configure", { "task" = "build-only", "args" = ["{{ parallel }}"] }] +args = [{ arg = "parallel", default = "2" }] ## Tests @@ -60,11 +62,22 @@ configure-tests.cmd = [ ] configure-tests.cwd = "." # build for tests -build-tests.depends-on = ["configure-tests", "build-only"] -# run tests -tests.cmd = ["ctest", "--output-on-failure", "--test-dir", "build/tests"] -tests.depends-on = ["clone-xsref", "build-tests"] -tests.cwd = "." +build-tests.depends-on = [ + "configure-tests", + { "task" = "build-only", "args" = ["{{ parallel }}"] }, +] +build-tests.args = [{ arg = "parallel", default = "2" }] +# just run tests +tests-only.cmd = ["ctest", "--output-on-failure", "--test-dir", "build/tests", "-j{{ parallel }}"] +tests-only.cwd = "." +tests-only.args = [{ arg = "parallel", default = "2" }] +# build and run tests +tests.depends-on = [ + "clone-xsref", + { "task" = "build-tests", "args" = ["{{ parallel }}"] }, + { "task" = "tests-only", args = ["{{ parallel }}"] }, +] +tests.args = [{ arg = "parallel", default = "2" }] ## clang-format @@ -109,13 +122,15 @@ ccache = ">=4.11.2,<5" [feature.tests-ci.tasks] # Build and generate coverage report # TODO: use a task arg for parallelism https://github.com/prefix-dev/pixi/pull/3433 -build-tests-ci.cmd = ["cmake", "--build", "build", "-j3", "--config", "Release"] +build-tests-ci.cmd = ["cmake", "--build", "build", "-j{{ parallel }}", "--config", "Release"] build-tests-ci.depends-on = ["clone-xsref", "configure-coverage"] build-tests-ci.cwd = "." +build-tests-ci.args = [{ arg = "parallel", default = "2" }] # Run tests -tests-ci.cmd = ["ctest", "--output-on-failure", "--test-dir", "build/tests", "-j3"] -tests-ci.depends-on = ["build-tests-ci"] +tests-ci.cmd = ["ctest", "--output-on-failure", "--test-dir", "build/tests", "-j{{ parallel }}"] +tests-ci.depends-on = [{ "task" = "build-tests-ci", "args" = ["{{ parallel }}"] }] tests-ci.cwd = "." +tests-ci.args = [{ arg = "parallel", default = "2" }] # Coverage coverage.cmd = [ "cmake", @@ -123,12 +138,13 @@ coverage.cmd = [ "build", "--target", "coverage_html", - "-j3", + "-j{{ parallel }}", "--config", "Release", ] -coverage.depends-on = ["tests-ci"] +coverage.depends-on = [{ "task" = "tests-ci", "args" = ["{{ parallel }}"] }] coverage.cwd = "." +coverage.args = [{ arg = "parallel", default = "2" }] # CuPy tests [feature.cupy-tests] From 9aa446f211a1cb0300834d319f8c71c7279abe5e Mon Sep 17 00:00:00 2001 From: Lucas Colley Date: Tue, 17 Jun 2025 00:53:01 +0100 Subject: [PATCH 2/2] CI: set NUM_WORKERS --- .github/workflows/tests.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 11e7b6c..2cfd0ca 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: prefix-dev/setup-pixi@92815284c57faa15cd896c4d5cfb2d59f32dc43d # v0.8.3 with: - pixi-version: v0.45.0 + pixi-version: v0.48.2 cache: true environments: ${{ matrix.environment }} - name: Prepare compiler cache @@ -44,12 +44,22 @@ jobs: path: ${{ steps.prep-ccache.outputs.dir }} key: ${{ github.workflow }}-ccache-${{ matrix.environment }}-${{ matrix.runs-on }}-${{ steps.prep-ccache.outputs.timestamp }} restore-keys: ${{ github.workflow }}-ccache-${{ matrix.environment }}-${{ matrix.runs-on }}- + - name: Determine number of workers + run: | + if [[ "$RUNNER_OS" == "Linux" ]]; then + echo "NUM_WORKERS=$(nproc)" >> $GITHUB_ENV + elif [[ "$RUNNER_OS" == "macOS" ]]; then + echo "NUM_WORKERS=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV + elif [[ "$RUNNER_OS" == "Windows" ]]; then + echo "NUM_WORKERS=$($Env:NUMBER_OF_PROCESSORS)" >> $env:GITHUB_ENV + fi + shell: bash - name: Build xsf - run: pixi run --environment=tests-ci build-tests-ci + run: pixi run --environment=tests-ci build-tests-ci $NUM_WORKERS - name: Run tests - run: pixi run --skip-deps --environment=tests-ci tests-ci + run: pixi run --skip-deps --environment=tests-ci tests-ci $NUM_WORKERS - name: Generate converage - run: pixi run --skip-deps --environment=tests-ci coverage + run: pixi run --skip-deps --environment=tests-ci coverage $NUM_WORKERS - name: Upload HTML coverage report uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: