From 4d5a85c4fb523a7df4eec66e1ad5e8fc1089defa Mon Sep 17 00:00:00 2001 From: Guido Imperiale Date: Thu, 12 Dec 2024 19:37:50 +0000 Subject: [PATCH] Run vendor tests locally with pixi (#65) --- .github/workflows/test-vendor.yml | 55 ------------------------------- pixi.lock | 2 +- pyproject.toml | 31 ++++++++++------- 3 files changed, 20 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/test-vendor.yml diff --git a/.github/workflows/test-vendor.yml b/.github/workflows/test-vendor.yml deleted file mode 100644 index 20be389..0000000 --- a/.github/workflows/test-vendor.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Test vendoring support - -on: - workflow_dispatch: - pull_request: - push: - branches: - - main - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -env: - # Many color libraries just need this to be set to any value, but at least - # one distinguishes color depth, where "3" -> "256-bit color". - FORCE_COLOR: 3 - -jobs: - pre-commit-and-lint: - name: Format - runs-on: ubuntu-latest - steps: - - name: Checkout array-api-extra - uses: actions/checkout@v4 - with: - path: array-api-extra - - - name: Checkout array-api-compat - uses: actions/checkout@v4 - with: - repository: data-apis/array-api-compat - path: array-api-compat - - - name: Vendor array-api-extra into test package - run: | - cp -a array-api-compat/array_api_compat array-api-extra/vendor_tests/ - cp -a array-api-extra/src/array_api_extra array-api-extra/vendor_tests/ - - - name: Install Python - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - - name: Install Pixi - uses: prefix-dev/setup-pixi@v0.8.1 - with: - pixi-version: v0.39.0 - manifest-path: array-api-extra/pyproject.toml - cache: true - - - name: Test package - run: | - cd array-api-extra/ - pixi run --environment tests tests-vendor diff --git a/pixi.lock b/pixi.lock index 6241787..cf9de80 100644 --- a/pixi.lock +++ b/pixi.lock @@ -1301,7 +1301,7 @@ packages: - pypi: . name: array-api-extra version: 0.3.3.dev0 - sha256: 3a1c2a9249e421fa21e8456ee7e595b01f77fb61f333a18d9e1ec9421f1fbd16 + sha256: 687632f03a70a52b774868b286f4e7a9e65c394ffb4aac124e6b10b4eb597034 requires_dist: - array-api-compat>=1.1.1 - furo>=2023.8.17 ; extra == 'docs' diff --git a/pyproject.toml b/pyproject.toml index 98dd361..f59bb23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,11 +79,11 @@ numpy = "*" pytest = "*" [tool.pixi.feature.lint.tasks] -pre-commit-install = { cmd = "pre-commit install" } -pre-commit = { cmd = "pre-commit run --all-files" } -mypy = { cmd = "mypy", cwd = "." } -pylint = { cmd = ["pylint", "array_api_extra"], cwd = "src" } -pyright = { cmd = "basedpyright", cwd = "." } +pre-commit-install = "pre-commit install" +pre-commit = "pre-commit run --all-files" +mypy = "mypy" +pylint = { cmd = "pylint array_api_extra", cwd = "src" } +pyright = "basedpyright" lint = { depends-on = ["pre-commit", "pylint", "mypy", "pyright"] } [tool.pixi.feature.tests.dependencies] @@ -93,11 +93,18 @@ array-api-strict = "*" numpy = "*" [tool.pixi.feature.tests.tasks] -tests = { cmd = "pytest -v" } -tests-ci = { cmd = "pytest -v -ra --cov --cov-report=xml --cov-report=term --durations=20" } -tests-vendor = { cmd = "pytest vendor_tests" } -coverage = { cmd = ["coverage", "html"], depends-on = ["tests-ci"] } -open-coverage = { cmd = ["open", "htmlcov/index.html"], depends-on = ["coverage"] } +tests = "pytest -v" +tests-cov = "pytest -v -ra --cov --cov-report=xml --cov-report=term --durations=20" + +clean-vendor-compat = "rm -rf vendor_tests/array_api_compat" +clean-vendor-extra = "rm -rf vendor_tests/array_api_extra" +copy-vendor-compat = { cmd = "cp -r $(python -c 'import site; print(site.getsitepackages()[0])')/array_api_compat vendor_tests/", depends-on = ["clean-vendor-compat"] } +copy-vendor-extra = { cmd = "cp -r src/array_api_extra vendor_tests/", depends-on = ["clean-vendor-extra"] } +tests-vendor = { cmd = "pytest -v vendor_tests", depends-on = ["copy-vendor-compat", "copy-vendor-extra"] } + +tests-ci = { depends-on = ["tests-cov", "tests-vendor"] } +coverage = { cmd = "coverage html", depends-on = ["tests-cov"] } +open-coverage = { cmd = "open htmlcov/index.html", depends-on = ["coverage"] } [tool.pixi.feature.docs.dependencies] sphinx = ">=7.0" @@ -107,8 +114,8 @@ sphinx-copybutton = "*" sphinx-autodoc-typehints = "*" [tool.pixi.feature.docs.tasks] -docs = { cmd = ["sphinx-build", ".", "build/"], cwd = "docs" } -open-docs = { cmd = ["open", "build/index.html"], cwd = "docs", depends-on = ["docs"] } +docs = { cmd = "sphinx-build . build/", cwd = "docs" } +open-docs = { cmd = "open build/index.html", cwd = "docs", depends-on = ["docs"] } [tool.pixi.feature.dev.dependencies] ipython = "*"