chore: Updated Makefile #784
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
| # This workflow will install Python dependencies, | |
| # run tests with a variety of Python versions, | |
| # and upload a new build to TestPyPI. | |
| # | |
| # For more information see: | |
| # https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
| name: Unit tests | |
| on: | |
| push: | |
| branches-ignore: | |
| - 'dependabot/**' # Avoid duplicates; only run the PR, not the push | |
| - 'gh-pages' # GitHub Pages do not trigger all tests | |
| tags-ignore: | |
| - 'v*' # Avoid re-running existing commit on release | |
| permissions: | |
| contents: read | |
| env: | |
| FORCE_COLOR: 1 | |
| jobs: | |
| generate-matrix: | |
| name: Derive Python version matrix from pyproject.toml | |
| runs-on: ubuntu-latest | |
| outputs: | |
| python-versions: ${{ steps.python-versions.outputs.python-versions }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| - name: Read supported versions from classifiers | |
| id: python-versions | |
| run: | | |
| python - <<'EOF' >> "$GITHUB_OUTPUT" | |
| import json | |
| import tomllib | |
| with open("pyproject.toml", "rb") as f: | |
| classifiers = tomllib.load(f)["project"]["classifiers"] | |
| prefix = "Programming Language :: Python :: 3." | |
| versions = [ | |
| classifier.rsplit("::", 1)[-1].strip() | |
| for classifier in classifiers | |
| if classifier.startswith(prefix) | |
| ] | |
| print(f"python-versions={json.dumps(versions)}") | |
| EOF | |
| test: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [macos-latest, ubuntu-latest, windows-latest] | |
| python-version: ${{ fromJson(needs.generate-matrix.outputs.python-versions) }} | |
| env: | |
| PYTHON_VERSION: ${{ matrix.python-version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| cache-dependency-glob: "uv.lock" | |
| enable-cache: false | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install library and dependencies | |
| run: | | |
| uv sync --frozen | |
| uv run maturin develop | |
| - name: Run tests (Pytest + Coverage) | |
| run: | | |
| uv run --frozen pytest | |
| uv run --frozen coverage report | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PLATFORM: ${{ matrix.os }} | |
| - name: Upload Results to CodeCov | |
| if: success() | |
| uses: codecov/codecov-action@v7 | |
| with: | |
| env_vars: PYTHON_VERSION | |
| fail_ci_if_error: false | |
| files: ./tests/reports/coverage-html/index.html,./tests/reports/coverage.xml | |
| flags: unittests | |
| name: "${{ matrix.os }} - Python ${{ matrix.python-version }}" | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| testpypi-deploy: | |
| name: Build and publish Python 🐍 distributions 📦 to TestPyPI | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v7 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| cache-dependency-glob: "uv.lock" | |
| enable-cache: true | |
| - name: Install Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version-file: "pyproject.toml" | |
| - name: Build test release 📦 | |
| uses: messense/maturin-action@v1 | |
| with: | |
| manylinux: auto | |
| command: build | |
| args: --release --sdist -o dist --find-interpreter | |
| - name: Publish test release 📦 to Test PyPI | |
| uses: messense/maturin-action@v1 | |
| continue-on-error: true | |
| env: | |
| MATURIN_PYPI_TOKEN: ${{ secrets.TEST_PYPI_PASSWORD }} | |
| MATURIN_REPOSITORY_URL: "https://test.pypi.org/legacy" | |
| with: | |
| command: upload | |
| args: --skip-existing * |