-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (94 loc) · 3.44 KB
/
Copy pathpython-ci.yml
File metadata and controls
103 lines (94 loc) · 3.44 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
name: Python CI
on:
push: # Runs on pushes to all branches
pull_request:
branches:
- main
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: Get wasiless submodule
# Org-internal submodules are very tricky to check out.
env:
SSHK: ${{ secrets.WASILESS_REPO_READ_KEY }}
run: |
mkdir -p $HOME/.ssh
echo "$SSHK" > $HOME/.ssh/ssh.key
chmod 600 $HOME/.ssh/ssh.key
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/ssh.key"
git submodule update --init --recursive
- 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'll use a more sophisticated setup 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 dependencies and build artifacts
# CRITICAL: ~/.cargo/git/checkouts/ contains componentize-py source + built CPython (5+ min build)
- name: Cache Rust dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/git/checkouts/
target/
key: cargo-deps-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-v3
restore-keys: |
cargo-deps-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}-
cargo-deps-${{ runner.os }}-
# Setup sccache for Rust compilation caching
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.8
- name: Configure sccache
run: |
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
# Build the Rust native extension (this is the slow part - builds componentize-py + CPython)
- 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
# Finally, do our final checks
- 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