Repository navigation
212 lines (184 loc) · 7.19 KB
/
Copy pathtest-python-sdk.yml
File metadata and controls
212 lines (184 loc) · 7.19 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
name: Test Python SDK
on:
pull_request:
paths:
- 'packages/python-sdk-memwal/**'
- '.github/workflows/test-python-sdk.yml'
- '.github/actions/wait-for-relayer/**'
- '.github/actions/setup-python/**'
- 'scripts/bootstrap-python-security.py'
- 'scripts/tests/test_bootstrap_python_security.py'
- '.python-version'
- 'services/server/benchmarks/**'
push:
branches:
- main
- staging
- dev
paths:
- 'packages/python-sdk-memwal/**'
- '.github/workflows/test-python-sdk.yml'
- '.github/actions/wait-for-relayer/**'
- '.github/actions/setup-python/**'
- 'scripts/bootstrap-python-security.py'
- 'scripts/tests/test_bootstrap_python_security.py'
- '.python-version'
- 'services/server/benchmarks/**'
workflow_dispatch:
schedule:
# Catches relayer drift with no code change to trigger it.
- cron: '17 9 * * 1'
concurrency:
group: test-python-sdk-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
defaults:
run:
working-directory: packages/python-sdk-memwal
jobs:
unit:
name: Unit / Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
# Tracks requires-python and the pyproject classifiers.
python-version: ['3.11.17', '3.12.15', '3.13.17', '3.14.9']
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: ./.github/actions/setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Build and install from source
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Lint
run: python -m ruff check memwal/ tests/
- name: Unit tests
run: python -m pytest tests/ -m "not integration" -q
- name: Verify bootstrap integrity failure
run: python -m unittest discover -s ../../scripts/tests -p test_bootstrap_python_security.py
- name: Audit Python dependencies
run: |
python -m pip install pip-audit
python -m pip_audit --local --skip-editable
benchmark-unit:
name: Benchmark / Python unit tests
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: services/server/benchmarks
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-python
- name: Install locked benchmark dependencies
run: python -m pip install --require-hashes -r requirements.lock
- name: Unit tests
run: python -m pytest tests/ -q
- name: Audit Python dependencies
run: |
python -m pip install pip-audit
python -m pip_audit --local
e2e:
name: E2E / dev relayer
runs-on: ubuntu-latest
needs: unit
timeout-minutes: 30
# Dev only for now; staging and production follow once their credentials
# exist. Pull requests are excluded because environment secrets are
# withheld from fork PRs, and every authenticated run writes real memories.
if: >-
github.event_name == 'workflow_dispatch' ||
github.event_name == 'schedule' ||
(github.event_name == 'push' && github.ref_name == 'dev')
# Reuses the credentials benchmark-live.yml already relies on, so this
# needs no new secrets. Namespaces keep the *data* separate — the
# benchmark writes to `benchmark` while these tests use `sdk-test`,
# `default` and a per-run `sdk-e2e-<uuid>` — but they do not keep the
# *rate limit* separate: the relayer meters per delegate key and per
# account, so the concurrency group below is what stops the three suites
# 429ing each other. Group name must stay identical in this file,
# test-sdk.yml, and benchmark-live.yml — byte-identical on purpose,
# including branches this dev-only job never runs on, so the three land
# in one group whatever the expression resolves to.
concurrency:
group: bench-account-${{ github.event_name == 'workflow_dispatch' && inputs.target_environment || (github.ref_name == 'main' && 'production' || github.ref_name == 'staging' && 'staging' || 'dev') }}
cancel-in-progress: false
environment: benchmark-dev
env:
# BENCH_DELEGATE_KEY is the delegate private key the SDK signs with,
# which test_integration.py reads as MEMWAL_PRIVATE_KEY.
MEMWAL_PRIVATE_KEY: ${{ secrets.BENCH_DELEGATE_KEY }}
MEMWAL_ACCOUNT_ID: ${{ secrets.BENCH_ACCOUNT_ID }}
# Public URL (internal/relayer/benchmark-ci-setup.md), defaulted so a missing
# variable cannot silently point the run at the wrong relayer.
MEMWAL_SERVER_URL: ${{ vars.BENCH_SERVER_URL || 'https://relayer.dev.memwal.ai' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: ./.github/actions/setup-python
with:
python-version: '3.11.17'
- name: Build and install from source
run: |
python -m pip install --upgrade pip
pip install -e '.[dev]'
- name: Check credentials
id: config
shell: bash
run: |
set -euo pipefail
# Without these the `requires_key` marker skips every authenticated
# test, and the job would report success having never called the
# relayer. Fail instead of reporting a green run that proved nothing.
missing=0
for name in MEMWAL_PRIVATE_KEY MEMWAL_ACCOUNT_ID; do
if [ -z "${!name:-}" ]; then
echo "::error::${name} is empty — set BENCH_DELEGATE_KEY / BENCH_ACCOUNT_ID on the benchmark-dev environment."
missing=1
fi
done
if [ "$missing" -ne 0 ]; then
exit 1
fi
echo "authenticated=true" >> "$GITHUB_OUTPUT"
# Push that touched services/server/**: wait for this SHA. SDK-only
# pushes and dispatch/schedule: health + write_ready only.
- name: Wait for Railway deploy
uses: ./.github/actions/wait-for-relayer
with:
server-url: ${{ env.MEMWAL_SERVER_URL }}
expected-commit: ${{ github.event_name == 'push' && github.sha || '' }}
since-commit: ${{ github.event_name == 'push' && github.event.before || '' }}
- name: E2E tests
id: e2e
run: |
python -m pytest tests/test_integration.py -m integration \
-v --junit-xml=e2e-results.xml
- name: Write run summary
if: always()
run: |
{
echo "## Python SDK e2e"
echo
echo "| Field | Value |"
echo "| --- | --- |"
echo "| Relayer | \`${MEMWAL_SERVER_URL}\` |"
echo "| Authenticated | ${{ steps.config.outputs.authenticated }} |"
echo "| Result | ${{ steps.e2e.outcome }} |"
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload e2e results
if: always()
uses: actions/upload-artifact@v4
with:
name: python-sdk-e2e-${{ github.run_id }}
path: packages/python-sdk-memwal/e2e-results.xml
if-no-files-found: warn
retention-days: 14