Add pyproject.toml urls #1020
Workflow file for this run
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: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - "*" | |
| release: | |
| branch: main | |
| types: [released] | |
| env: | |
| CLICOLOR: 1 | |
| jobs: | |
| check: | |
| name: Check | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| - name: Check with ruff | |
| uses: astral-sh/ruff-action@v3 | |
| with: | |
| args: check | |
| spelling: | |
| name: Spellcheck | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| - name: Spellcheck repo | |
| uses: crate-ci/typos@v1 | |
| fmt: | |
| name: Formatting | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| - name: Check with ruff | |
| uses: astral-sh/ruff-action@v3 | |
| with: | |
| args: "format --diff --check" | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Replace symlinks with file copies | |
| run: find ./ -type l -exec sh -c 'for i in "$@"; do cp --preserve --remove-destination "$(readlink -f "$i")" "$i"; done' sh {} + | |
| - name: Build all packages | |
| run: uv build --all-packages | |
| - name: List the built dist files | |
| run: ls -lh dist/ | |
| - name: Upload the package sdist and wheels | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: dist | |
| path: dist | |
| retention-days: 1 | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ["3.11", "3.12", "3.13", "3.14"] | |
| resolution: ["highest", "lowest-direct"] | |
| markers: ["not slow and not veryslow", "slow", "veryslow"] | |
| exclude: | |
| - python: "3.11" | |
| markers: "veryslow" | |
| resolution: "highest" | |
| - python: "3.12" | |
| markers: "veryslow" | |
| - python: "3.13" | |
| markers: "veryslow" | |
| - python: "3.14" | |
| markers: "veryslow" | |
| resolution: "lowest-direct" | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: | | |
| pyproject.toml | |
| tests/ | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Download the dist artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Install the test dependencies | |
| run: | | |
| uv sync --no-install-workspace \ | |
| --group test \ | |
| --resolution ${{ matrix.resolution }} \ | |
| --no-build | |
| - name: Install the safeguards packages | |
| run: | | |
| uv pip install dist/*.whl \ | |
| --resolution ${{ matrix.resolution }} \ | |
| --no-build | |
| - name: Run tests | |
| run: uv run --no-sync pytest -v -W error -m "${{ matrix.markers }}" | |
| typing: | |
| name: Typecheck | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ["3.11", "3.12", "3.13", "3.14"] | |
| resolution: ["highest", "lowest-direct"] | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: | | |
| packages/numcodecs-safeguards/pyproject.toml | |
| packages/xarray-safeguards/pyproject.toml | |
| pyproject.toml | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Download the dist artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Install the typecheck dependencies | |
| run: | | |
| uv sync --no-install-workspace \ | |
| --group typecheck \ | |
| --resolution ${{ matrix.resolution }} \ | |
| --no-build | |
| - name: Install the safeguards packages | |
| run: | | |
| uv pip install dist/*.whl \ | |
| --resolution ${{ matrix.resolution }} \ | |
| --no-build | |
| - name: Typecheck compression-safeguards | |
| run: uv run --no-sync mypy -p compression_safeguards | |
| - name: Typecheck numcodecs-safeguards | |
| run: cd packages/numcodecs-safeguards && uv run --no-sync mypy -p numcodecs_safeguards | |
| - name: Typecheck xarray-safeguards | |
| run: cd packages/xarray-safeguards && uv run --no-sync mypy -p xarray_safeguards | |
| fuzz: | |
| name: Fuzz | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| actions: write | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 1 | |
| matrix: | |
| python: ["3.11", "3.12", "3.13", "3.14"] | |
| resolution: ["highest", "lowest-direct"] | |
| exclude: | |
| - python: "3.12" | |
| resolution: "lowest-direct" | |
| - python: "3.13" | |
| resolution: "lowest-direct" | |
| - python: "3.14" | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: | | |
| fuzz/ | |
| pyproject.toml | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Download the dist artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Install the fuzzing dependencies | |
| run: | | |
| uv sync --no-install-workspace \ | |
| --group fuzz \ | |
| --resolution ${{ matrix.resolution }} \ | |
| --no-build | |
| - name: Install the safeguards packages | |
| run: | | |
| uv pip install dist/*.whl \ | |
| --resolution ${{ matrix.resolution }} \ | |
| --no-build | |
| - name: Restore the fuzzer corpus | |
| id: fuzzer-corpus-restore | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: ./corpus | |
| key: fuzzer-corpus | |
| - name: Ensure the fuzzer corpus exists | |
| run: | | |
| mkdir -p ./corpus/safeguards | |
| mkdir -p ./corpus/intervals | |
| mkdir -p ./corpus/qois | |
| mkdir -p ./corpus/chunking | |
| - name: Run the fuzzers | |
| run: | | |
| uv run --no-sync fuzz/fuzz_safeguards.py ./corpus/safeguards -max_total_time=60 | |
| uv run --no-sync fuzz/fuzz_intervals.py ./corpus/intervals -max_total_time=30 | |
| uv run --no-sync fuzz/fuzz_qois.py ./corpus/qois -max_total_time=60 | |
| uv run --no-sync fuzz/fuzz_chunking.py ./corpus/chunking -max_total_time=30 | |
| - name: Delete the previous fuzzer corpus | |
| if: always() && steps.fuzzer-corpus-restore.outputs.cache-hit == 'true' | |
| run: gh cache delete fuzzer-corpus | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Save the fuzzer corpus | |
| if: always() | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: ./corpus | |
| key: fuzzer-corpus | |
| docs: | |
| name: Docs | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: build | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Download the dist artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Install the docs dependencies | |
| run: | | |
| uv sync --no-install-workspace \ | |
| --group docs \ | |
| --resolution highest \ | |
| --no-build | |
| - name: Install the safeguards packages | |
| run: | | |
| uv pip install dist/*.whl \ | |
| --resolution highest \ | |
| --no-build | |
| # https://github.com/mkdocstrings/python/issues/167 | |
| - name: Reduce docs duplication | |
| run: sed -i 's/__all__ = \["Safeguards", "SafeguardKind"\]/__all__ = \[\]/g' .venv/lib/python*/site-packages/compression_safeguards/__init__.py | |
| - name: Check docs build | |
| run: uv run --no-sync mkdocs build | |
| doctest: | |
| name: Doctest | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python: ["3.11", "3.12", "3.13", "3.14"] | |
| resolution: ["highest", "lowest-direct"] | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Download the dist artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Install the doctest dependencies | |
| run: | | |
| uv sync --no-install-workspace \ | |
| --group doctest \ | |
| --resolution highest \ | |
| --no-build | |
| - name: Install the safeguards packages | |
| run: | | |
| uv pip install dist/*.whl \ | |
| --resolution highest \ | |
| --no-build | |
| - name: Compile all docs | |
| run: | | |
| cp README.md docs/ | |
| uv run --no-sync griffe2md src/compression_safeguards/ -o docs/compression_safeguards.md | |
| uv run --no-sync griffe2md packages/numcodecs-safeguards/src/numcodecs_safeguards/ -o docs/numcodecs_safeguards.md | |
| uv run --no-sync griffe2md packages/xarray-safeguards/src/xarray_safeguards/ -o docs/xarray_safeguards.md | |
| find docs -type f -name "*.md" | xargs sed -i -e 's/```py/```python/g' | |
| - name: Run doctests | |
| run: uv run --no-sync pytest -v -W error --codeblocks docs/ | |
| pyodide-build: | |
| name: Build for Pyodide | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: | | |
| tools/ | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.13.2 | |
| - name: Setup Emscripten | |
| uses: mymindstorm/setup-emsdk@v14 | |
| with: | |
| version: 4.0.9 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Install pyodide-build | |
| run: python -m pip install pyodide-build | |
| - name: Install the Pyodide build env | |
| run: pyodide xbuildenv install 0.29.2 | |
| - name: Build compiled dependencies for Pyodide | |
| run: | | |
| pyodide build-recipes \ | |
| --recipe-dir tools/ci/pyodide-recipes/packages \ | |
| --install \ | |
| numcodecs numpy numpy-quaddtype | |
| - name: Clean the Pyodide dist | |
| run: find dist/ -type f ! -name '*.whl' -delete | |
| - name: Upload the Pyodide wheels | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: pyodide-dist | |
| path: dist | |
| retention-days: 1 | |
| pyodide-test: | |
| name: Test on Pyodide | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| needs: [build, pyodide-build] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| markers: ["not slow and not veryslow", "slow", "veryslow"] | |
| steps: | |
| - name: Checkout the Repository | |
| uses: actions/checkout@v6 | |
| with: | |
| sparse-checkout: | | |
| pyproject.toml | |
| tests/ | |
| - name: Setup Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.13.2 | |
| - name: Install pyodide-build | |
| run: python -m pip install pyodide-build | |
| - name: Install the Pyodide build env | |
| run: pyodide xbuildenv install 0.29.2 | |
| - name: Download the dist artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: Download the pyodide-dist artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: pyodide-dist | |
| path: dist | |
| - name: Create the Pyodide venv | |
| run: | | |
| # Set up Pyodide venv | |
| pyodide venv .venv-pyodide | |
| source .venv-pyodide/bin/activate | |
| # Install pre-built packages (for dependencies) | |
| python -m pip install $(ls dist/*.whl) | |
| # Install test dependencies | |
| python -m pip install --group test | |
| # Install pre-built packages (to override) | |
| python -m pip install $(ls dist/*.whl) | |
| - name: Run tests | |
| run: | | |
| source .venv-pyodide/bin/activate | |
| python -m pytest -v -W error -m "${{ matrix.markers }}" | |
| publish: | |
| name: Publish to PyPi | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| permissions: | |
| contents: read | |
| id-token: write | |
| if: ${{ github.event_name == 'release' }} | |
| needs: | |
| # require all jobs to succeed | |
| - check | |
| - spelling | |
| - fmt | |
| - build # includes the dist artifact | |
| - test | |
| - typing | |
| - fuzz | |
| - docs | |
| - doctest | |
| - pyodide-build | |
| - pyodide-test | |
| steps: | |
| - name: Download the dist artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist | |
| path: dist | |
| - name: List the built dist files | |
| run: ls -lh dist/ | |
| - name: Publish the packages | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true |