Skip to content

DEV: parallel workers task args #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
40 changes: 28 additions & 12 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -109,26 +122,29 @@ 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",
"--build",
"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]
Expand Down
Loading