-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (95 loc) · 3.59 KB
/
python-ci.yml
File metadata and controls
104 lines (95 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
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: ubuntu-24.04
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