-
Notifications
You must be signed in to change notification settings - Fork 51
191 lines (185 loc) · 7.62 KB
/
Copy pathsdk.yml
File metadata and controls
191 lines (185 loc) · 7.62 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: SDK
on:
workflow_call:
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint (fmt, clippy, pyright)
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./sdk
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
workspaces: sdk
- name: fmt
run: cargo fmt --check
- name: clippy (mainnet)
run: cargo clippy --no-default-features --features mainnet -- -D warnings
# Guard the testnet cfg seam — it only exists at compile time.
- name: check (testnet)
run: cargo check --no-default-features --features testnet
# pyright needs the package's third-party imports resolvable
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install import-resolution deps for pyright
run: pip install requests httpx pynacl
- uses: jordemort/action-pyright@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workdir: ./sdk
fail_on_error: true
test:
name: Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
defaults:
run:
working-directory: ./sdk
shell: bash
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: sdk
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# Build BOTH network extension modules so aleo.mainnet AND aleo.testnet
# resolve. maturin emits one cdylib per invocation (named by pyproject
# module-name), so we build mainnet, then build testnet with the
# module-name overridden and merge its .so into the aleo package.
- name: Build both-network wheel
run: |
pip install maturin
maturin build --release --features mainnet --out dist
sed -i.bak 's/module-name = "aleo._aleolib_mainnet"/module-name = "aleo._aleolib_testnet"/' pyproject.toml
maturin build --release --no-default-features --features testnet --out dist-testnet
mv pyproject.toml.bak pyproject.toml
python ../.github/scripts/merge_testnet_so.py dist dist-testnet
# Install the built wheel by path: --find-links also consults PyPI, and
# once the branch's version is published there pip may prefer the PyPI
# wheel over the one just built (tag-order tie on macOS/Windows).
- name: Install wheel + test deps
run: |
pip install dist/aleo_sdk-*.whl
pip install pytest pytest-xdist httpx pynacl responses pytest-asyncio
# Fast, offline tests; -n auto parallelizes across cores.
- name: pytest (fast suite)
run: python -m pytest python/tests -v -n auto -m "not slow and not live and not devnode"
test-proving:
name: Test (proving, network)
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./sdk
shell: bash
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: sdk
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# SRS/proving parameters are fetched on first prove; cache them so the
# job costs ~30s warm instead of minutes of downloads.
- name: Cache Aleo parameters
uses: actions/cache@v4
with:
path: ~/.aleo
key: aleo-parameters-${{ runner.os }}-v1
# Build BOTH network extensions so the testnet surface is exercised here
# too (not just in the OS-matrix lane). Deps are cached, so the second
# feature build is a warm recompile, not a cold one.
- name: Build both-network wheel
run: |
pip install maturin
maturin build --release --features mainnet --out dist
sed -i.bak 's/module-name = "aleo._aleolib_mainnet"/module-name = "aleo._aleolib_testnet"/' pyproject.toml
maturin build --release --no-default-features --features testnet --out dist-testnet
mv pyproject.toml.bak pyproject.toml
python ../.github/scripts/merge_testnet_so.py dist dist-testnet
- name: Install wheel + test deps
run: |
pip install dist/aleo_sdk-*.whl
pip install pytest httpx pynacl responses pytest-asyncio
# The two slow tests share one module-scoped proven execution; xdist
# would prove twice, so they run in a single worker on purpose.
- name: pytest (proving suite)
run: python -m pytest python/tests -v -m slow
# test_testnet.py is not marked slow, so `-m slow` deselects it; run the
# testnet surface/ID/derivation tests explicitly against the two-network
# wheel built above.
- name: pytest (testnet surface + KATs)
run: python -m pytest python/tests/test_testnet.py -v
test-abi:
name: Test (aleo-contract-abi-generator package)
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
workspaces: |
sdk
sdk-abi
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# The canary for build-graph isolation: leo's snarkvm feature flags
# (dev_skip_checks etc.) must never leak into the main SDK's lockfile.
- name: Assert main-crate isolation from leo features
run: |
count=$(grep -c "dev_skip_checks" sdk/Cargo.lock || true)
if [ "$count" != "0" ]; then
echo "::error::sdk/Cargo.lock references dev_skip_checks — leo build graph leaked into the main crate"
exit 1
fi
# Build the aleo two-network wheel (mainnet + testnet merged) plus the
# aleo-contract-abi-generator wheel. The testnet .so must be spliced into the aleo wheel
# BEFORE the aleo-contract-abi-generator wheel lands in dist, so the merge sees only the
# aleo wheel.
- name: Build wheels (aleo two-network + aleo-contract-abi-generator)
run: |
pip install maturin pytest requests
maturin build --release --features mainnet --manifest-path sdk/Cargo.toml --out dist
sed -i.bak 's/module-name = "aleo._aleolib_mainnet"/module-name = "aleo._aleolib_testnet"/' sdk/pyproject.toml
maturin build --release --no-default-features --features testnet --manifest-path sdk/Cargo.toml --out dist-testnet
mv sdk/pyproject.toml.bak sdk/pyproject.toml
python .github/scripts/merge_testnet_so.py dist dist-testnet
maturin build --release --manifest-path sdk-abi/Cargo.toml --out dist
- name: Install wheels
run: |
pip install dist/*.whl
# Run each suite from inside its package dir so pytest uses that
# package's own pytest.ini (sdk-abi/pytest.ini, sdk/pytest.ini) rather
# than walking up to the stale legacy root setup.cfg.
- name: pytest (aleo-contract-abi-generator package suite)
run: |
cd sdk-abi
python -m pytest python/tests -v
- name: pytest (main-package abi hook)
run: |
cd sdk
python -m pytest python/tests/test_abi_hook.py -v
# Exercise the testnet extension in this lane too (it's now built above).
- name: pytest (testnet surface + KATs)
run: |
cd sdk
python -m pytest python/tests/test_testnet.py -v