Support exporting python dependency metadata #308
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: Python CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: # Allows manual triggering from GitHub Actions UI | |
| env: | |
| VICEROY_TAG: v0.16.4 | |
| jobs: | |
| build: | |
| runs-on: forge-amd64-medium | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Rust toolchain | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| with: | |
| toolchain: 1.92.0 | |
| target: wasm32-unknown-unknown | |
| components: rustfmt, clippy | |
| # Disable the built-in cargo cache - we use our own below | |
| cache: false | |
| - name: Set up nightly Rust toolchain with rust-src | |
| run: | | |
| rustup toolchain install nightly --component rust-src | |
| rustup target add wasm32-wasip1 --toolchain nightly | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| run: pip install uv | |
| # Cache cargo binaries (viceroy, wasm-tools, etc.) | |
| - name: Cache cargo binaries | |
| id: cache-cargo-bins | |
| uses: actions/cache@v4 | |
| with: | |
| key: cargo-bins-${{ runner.os }}-${{ env.VICEROY_TAG }} | |
| path: | | |
| ~/.cargo/bin/viceroy* | |
| ~/.cargo/bin/wasm-tools* | |
| ~/.cargo/bin/wac* | |
| - name: Install wasm-tools and wac | |
| if: steps.cache-cargo-bins.outputs.cache-hit != 'true' | |
| run: cargo install wasm-tools wac-cli | |
| - name: Install viceroy | |
| if: steps.cache-cargo-bins.outputs.cache-hit != 'true' | |
| run: cargo install --git https://github.com/fastly/Viceroy.git --tag "$VICEROY_TAG" viceroy | |
| # Cache Rust registry and git sources separately from build artifacts. | |
| # | |
| # Sources are keyed only on Cargo.lock so they survive a clean target/ | |
| # and are shared across build profiles (release, clippy, etc.). | |
| # | |
| # Build artifacts (target/) are cached separately per Cargo.lock AND | |
| # Rust toolchain version, because different toolchain versions produce | |
| # incompatible artifacts. | |
| - name: Cache Rust sources | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| ~/.cargo/git/checkouts/ | |
| key: cargo-sources-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-v1 | |
| restore-keys: | | |
| cargo-sources-${{ runner.os }}- | |
| # Build artifacts are cached per Cargo.lock + toolchain. We cache both | |
| # release and debug/clippy profiles together since they share most deps. | |
| - name: Cache Rust build artifacts | |
| uses: actions/cache@v4 | |
| with: | |
| path: target/ | |
| key: cargo-target-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-${{ env.RUSTUP_TOOLCHAIN }}-v1 | |
| restore-keys: | | |
| cargo-target-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}- | |
| cargo-target-${{ runner.os }}- | |
| # Build the native extension in release mode first so the release | |
| # artifacts are in target/. Clippy reuses these artifacts for deps | |
| # that don't change between profiles. | |
| - name: Build native extension | |
| run: uv run maturin develop --release | |
| # Install Python dependencies | |
| - name: Install Python dependencies | |
| run: uv sync --extra dev --extra test --extra examples | |
| # Run clippy using the same --release flag and features as the build | |
| # above so that Cargo can reuse the already-compiled dependency | |
| # artifacts and only checks our own crate. | |
| - name: Check formatting | |
| run: make format-check | |
| - name: Run linting | |
| run: make lint | |
| - name: Run tests | |
| # Use DEV_MODE=0 to use the installed fastly-compute-py binary instead of rebuilding with cargo | |
| run: DEV_MODE=0 make test |