-
Notifications
You must be signed in to change notification settings - Fork 18
141 lines (138 loc) · 5.6 KB
/
Copy pathpython.yml
File metadata and controls
141 lines (138 loc) · 5.6 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
name: Python
on:
push:
branches: [main]
pull_request:
workflow_call:
jobs:
test-python:
name: Python tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- name: Install Python SDK
working-directory: python
# Framework extras bring fastapi/flask/django so the pay_kit shim tests
# import and pyright can resolve them; dev brings ruff, pyright, pytest.
run: |
python -m pip install --upgrade pip
pip install -e ".[dev,fastapi,flask,django]"
- name: Lint with ruff
working-directory: python
run: ruff check src tests
- name: Type check with pyright
working-directory: python
# Point pyright at the interpreter the extras were installed into; it
# does not reliably auto-detect the active env on the runner.
run: pyright --pythonpath "$(python -c 'import sys; print(sys.executable)')"
- name: Run tests with coverage
working-directory: python
# Coverage gate: line coverage at 90% over pay_kit (the MPP wire layer
# now lives under pay_kit/protocols/mpp). preflight.py is omitted in
# pyproject (live-RPC paths). Branch coverage gate is follow-up work,
# tracked in #108.
run: |
pytest \
--cov=pay_kit \
--cov-report=term-missing \
--cov-report=json:coverage.json \
--cov-fail-under=90 \
--ignore=tests/test_server_html.py
- name: Upload Python coverage
if: always()
uses: actions/upload-artifact@v7
with:
name: python-coverage
path: python/coverage.json
harness-python:
name: Python harness matrix
runs-on: ubuntu-latest
needs: test-python
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: pip
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
rust/target
key: ${{ runner.os }}-cargo-python-harness-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: ${{ runner.os }}-cargo-python-harness-
- uses: pnpm/action-setup@v5
with:
package_json_file: package.json
- uses: actions/setup-node@v5
with:
node-version: 22
cache: pnpm
cache-dependency-path: typescript/pnpm-lock.yaml
- name: Install Python SDK
working-directory: python
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
# Critical order: install + build the TypeScript workspace BEFORE
# installing the harness. harness has
# ``"@solana/mpp": "file:../typescript/packages/mpp"`` which
# pnpm copies into node_modules at install time. If the typescript
# package has no dist/ at that moment, the TS harness client crashes
# with ``Cannot find module '@solana/mpp/dist/client/index.js''`` on
# boot and the harness reports "Adapter exited before signaling
# readiness/result (code 1)". html-assets.gen.ts is committed in
# the repo so no separate build-html step is needed.
- name: Install TypeScript workspace
working-directory: typescript
run: pnpm install --frozen-lockfile
- name: Build TypeScript package
working-directory: typescript
run: pnpm --filter @solana/mpp build
- name: Build Rust harness adapters
working-directory: rust
run: |
cargo build -p solana-mpp --bin harness_client --bin harness_server
cargo build -p solana-x402 --bin harness_client --bin harness_server
- name: Install harness
working-directory: harness
run: pnpm install --frozen-lockfile
- name: Focused TS-to-Python harness
working-directory: harness
env:
MPP_HARNESS_CLIENTS: typescript
MPP_HARNESS_SERVERS: python
run: pnpm exec vitest run test/e2e.test.ts
- name: Focused Rust-to-Python harness
working-directory: harness
env:
MPP_HARNESS_CLIENTS: rust
MPP_HARNESS_SERVERS: python
run: pnpm exec vitest run test/e2e.test.ts
# x402 exact: drive the Python pay_kit x402 client (a real signed v0
# VersionedTransaction) against the full-settling rust and python x402
# servers. test/e2e.test.ts self-hosts surfnet and threads the funded
# client keypair into X402_HARNESS_CLIENT_SECRET_KEY. The matrix pairs
# every active client x active server, so the MPP_HARNESS_* selectors are
# also set to keep the default charge-enabled adapters (typescript, php,
# go) out of this x402 run. ts-x402 is excluded: its stub server expects a
# payload.challengeId and never broadcasts a real transaction, so it
# cannot settle a genuine signed tx (same reason rust-x402 skips it). The
# x402 client adapter imports pay_kit from python/src on sys.path (no
# extra install beyond the editable SDK above).
- name: Focused python-x402 -> rust/python x402 servers
working-directory: harness
env:
MPP_HARNESS_INTENTS: x402-exact
MPP_HARNESS_SCENARIOS: x402-exact-basic
MPP_HARNESS_CLIENTS: python-x402
MPP_HARNESS_SERVERS: rust-x402,python
X402_HARNESS_CLIENTS: python-x402
X402_HARNESS_SERVERS: rust-x402,python
run: pnpm exec vitest run test/e2e.test.ts --testTimeout 180000