ci: fix smoke test — run import from /tmp to avoid source dir shadowing #87
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: Build & Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - "*" # Trigger on tag push for release | |
| paths: | |
| - "src/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| - "pyproject.toml" | |
| - "polars_iptools/**" | |
| - "tests/**" | |
| - ".github/workflows/publish_to_pypi.yml" | |
| pull_request: | |
| paths: | |
| - "src/**" | |
| - "Cargo.toml" | |
| - "Cargo.lock" | |
| - "pyproject.toml" | |
| - "polars_iptools/**" | |
| - "tests/**" | |
| - ".github/workflows/publish_to_pypi.yml" | |
| workflow_dispatch: # Trigger for manual release run | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read # Default read-only permissions | |
| env: | |
| RUSTFLAGS: "-Dwarnings -C debuginfo=0" | |
| CARGO_INCREMENTAL: 0 | |
| PYTHONUTF8: 1 | |
| jobs: | |
| # ------------------------------------------------------------------ | |
| # Run tests | |
| # ------------------------------------------------------------------ | |
| test-python: | |
| name: Test (Ubuntu, Python ${{ matrix.python-version }}) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: | |
| - "3.10" | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Rust stable toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Rust Cache | |
| uses: swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref_name == 'main' }} | |
| - name: Install uv and Python | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| enable-cache: true | |
| - name: install deps | |
| run: uv sync --group dev | |
| - run: uv pip install -e . | |
| env: | |
| RUST_BACKTRACE: 1 | |
| - run: uv pip freeze | |
| - name: Run tests | |
| run: uv run pytest tests -v | |
| # ------------------------------------------------------------------ | |
| # Test different operating systems | |
| # ------------------------------------------------------------------ | |
| test-os: | |
| name: Test on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }}-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu, macos, windows] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: install rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: cache rust | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| save-if: ${{ github.ref_name == 'main' }} | |
| - name: install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: "3.12" | |
| enable-cache: true | |
| - name: install deps | |
| run: uv sync --group dev | |
| - run: uv pip install -e . | |
| env: | |
| RUST_BACKTRACE: 1 | |
| - run: uv pip freeze | |
| - run: uv run pytest tests -v | |
| # ------------------------------------------------------------------ | |
| # Build Wheels | |
| # ------------------------------------------------------------------ | |
| build-linux: | |
| name: Build Wheels (linux, ${{ matrix.platform.target }}) | |
| if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' | |
| needs: [test-python, test-os] | |
| runs-on: ${{ matrix.platform.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - runner: ubuntu-latest | |
| target: x86_64 | |
| - runner: ubuntu-latest | |
| target: aarch64 | |
| - runner: ubuntu-latest | |
| target: armv7 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.platform.target }} | |
| args: --release --out dist | |
| sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| manylinux: auto | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-linux-${{ matrix.platform.target }} | |
| path: dist | |
| build-musllinux: | |
| name: Build Wheels (musllinux, ${{ matrix.platform.target }}) | |
| if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' | |
| needs: [test-python, test-os] | |
| runs-on: ${{ matrix.platform.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - runner: ubuntu-latest | |
| target: x86_64 | |
| - runner: ubuntu-latest | |
| target: aarch64 | |
| - runner: ubuntu-latest | |
| target: armv7 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.platform.target }} | |
| args: --release --out dist | |
| sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| manylinux: musllinux_1_2 | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-musllinux-${{ matrix.platform.target }} | |
| path: dist | |
| build-windows: | |
| name: Build Wheels (windows, ${{ matrix.platform.target }}) | |
| if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' | |
| needs: [test-python, test-os] | |
| runs-on: ${{ matrix.platform.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - runner: windows-latest | |
| target: x64 | |
| - runner: windows-latest | |
| target: x86 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| architecture: ${{ matrix.platform.target }} | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.platform.target }} | |
| args: --release --out dist | |
| sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| - name: Smoke test wheel | |
| if: matrix.platform.target == 'x64' | |
| run: | | |
| pip install --force-reinstall dist/*.whl | |
| cd /tmp && python -c 'import polars_iptools; print(polars_iptools.__version__)' | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-windows-${{ matrix.platform.target }} | |
| path: dist | |
| build-macos: | |
| name: Build Wheels (macos, ${{ matrix.platform.target }}) | |
| if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' | |
| needs: [test-python, test-os] | |
| runs-on: ${{ matrix.platform.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| platform: | |
| - runner: macos-15-intel | |
| target: x86_64 | |
| - runner: macos-15 | |
| target: aarch64 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| - name: Build wheels | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| target: ${{ matrix.platform.target }} | |
| args: --release --out dist | |
| sccache: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
| - name: Smoke test wheel | |
| run: | | |
| pip install --force-reinstall dist/*.whl | |
| cd /tmp && python -c 'import polars_iptools; print(polars_iptools.__version__)' | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-macos-${{ matrix.platform.target }} | |
| path: dist | |
| # ------------------------------------------------------------------ | |
| # sdist | |
| # ------------------------------------------------------------------ | |
| sdist: | |
| name: Build sdist | |
| if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Build sdist | |
| uses: PyO3/maturin-action@v1 | |
| with: | |
| command: sdist | |
| args: --out dist | |
| - name: Upload sdist | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-sdist | |
| path: dist | |
| # ------------------------------------------------------------------ | |
| # Release job | |
| # ------------------------------------------------------------------ | |
| release: | |
| name: Release to PyPI | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/polars-iptools/ | |
| if: | | |
| always() && | |
| (startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch') && | |
| !contains(needs.*.result, 'failure') | |
| needs: [build-linux, build-musllinux, build-windows, build-macos, sdist] | |
| permissions: | |
| # Use to sign the release artifacts | |
| id-token: write | |
| # Used to upload release artifacts | |
| contents: write | |
| # Used to generate artifact attestation | |
| attestations: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: Generate artifact attestation | |
| uses: actions/attest-build-provenance@v2 | |
| with: | |
| subject-path: "dist/*" | |
| - name: Publish to PyPI | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| skip-existing: true |