-
Notifications
You must be signed in to change notification settings - Fork 15
275 lines (245 loc) · 8.69 KB
/
e2e.yml
File metadata and controls
275 lines (245 loc) · 8.69 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: E2E
on:
push:
branches: ["main"]
paths:
- "crates/**"
- "programs/**"
- "sdk/**"
- "console/**"
- "examples/**"
- "schemas/**"
- "docker-compose.yml"
- ".github/workflows/e2e.yml"
- "Cargo.lock"
- "pnpm-lock.yaml"
pull_request:
branches: ["main"]
paths:
- "crates/**"
- "programs/**"
- "sdk/**"
- "console/**"
- "examples/**"
- "schemas/**"
- "docker-compose.yml"
- ".github/workflows/e2e.yml"
- "Cargo.lock"
- "pnpm-lock.yaml"
workflow_dispatch:
concurrency:
group: e2e-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
NODE_VERSION: "20"
PNPM_VERSION: "9"
SOLANA_VERSION: "stable"
ANCHOR_VERSION: "latest"
SIGNIA_E2E_OUT: "/tmp/signia-e2e"
SIGNIA_API_URL: "http://127.0.0.1:8787"
jobs:
e2e:
name: End-to-end (compile → verify → publish → query)
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install system dependencies
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y \
build-essential \
pkg-config \
libssl-dev \
libudev-dev \
curl \
jq
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Install JS dependencies (root)
run: |
set -euo pipefail
if [ -f package.json ]; then
pnpm install --frozen-lockfile || pnpm install
else
echo "No root package.json; skipping JS install."
fi
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Build SIGNIA CLI + API (release)
run: |
set -euo pipefail
cargo build --release --locked --manifest-path crates/signia-cli/Cargo.toml
cargo build --release --locked --manifest-path crates/signia-api/Cargo.toml
mkdir -p "${SIGNIA_E2E_OUT}"
cp crates/signia-cli/target/release/signia "${SIGNIA_E2E_OUT}/signia"
echo "${SIGNIA_E2E_OUT}" >> "${GITHUB_PATH}"
- name: Print versions
run: |
set -euo pipefail
"${SIGNIA_E2E_OUT}/signia" --version || true
rustc -V
cargo -V
node -v
pnpm -v
# -----------------------------
# Optional: Local Solana + Anchor program
# -----------------------------
- name: Install Solana CLI (optional)
if: ${{ hashFiles('programs/signia-registry/Anchor.toml') != '' }}
run: |
set -euo pipefail
sh -c "$(curl -sSfL https://release.solana.com/${SOLANA_VERSION}/install)"
echo "$HOME/.local/share/solana/install/active_release/bin" >> "$GITHUB_PATH"
solana --version
- name: Cache Solana CLI
if: ${{ hashFiles('programs/signia-registry/Anchor.toml') != '' }}
uses: actions/cache@v4
with:
path: |
~/.local/share/solana
key: solana-${{ runner.os }}-${{ env.SOLANA_VERSION }}
- name: Install Anchor (optional)
if: ${{ hashFiles('programs/signia-registry/Anchor.toml') != '' }}
run: |
set -euo pipefail
cargo install --git https://github.com/coral-xyz/anchor avm --locked
avm install ${ANCHOR_VERSION}
avm use ${ANCHOR_VERSION}
anchor --version
- name: Start solana-test-validator (optional)
if: ${{ hashFiles('programs/signia-registry/Anchor.toml') != '' }}
run: |
set -euo pipefail
solana-test-validator --reset --quiet &
echo $! > /tmp/solana-validator.pid
# Wait for RPC
for i in $(seq 1 60); do
if solana cluster-version --url http://127.0.0.1:8899 >/dev/null 2>&1; then
echo "Solana RPC is ready."
break
fi
sleep 1
done
solana config set --url http://127.0.0.1:8899
solana airdrop 10 || true
- name: Build + deploy registry program (optional)
if: ${{ hashFiles('programs/signia-registry/Anchor.toml') != '' }}
working-directory: programs/signia-registry
run: |
set -euo pipefail
anchor build
# In localnet, anchor deploy typically uses Anchor.toml provider config.
anchor deploy
# -----------------------------
# Start API service (background)
# -----------------------------
- name: Start SIGNIA API (background)
run: |
set -euo pipefail
mkdir -p "${SIGNIA_E2E_OUT}/logs"
# Expect your API to support these env vars; adjust later to your actual config keys.
export SIGNIA_API_BIND="127.0.0.1:8787"
export SIGNIA_STORE_DIR="${SIGNIA_E2E_OUT}/store"
export RUST_LOG="info"
# If your API uses a config file, replace this with `--config`.
crates/signia-api/target/release/signia-api > "${SIGNIA_E2E_OUT}/logs/api.log" 2>&1 &
echo $! > /tmp/signia-api.pid
# Wait for health endpoint (assumes /health exists)
for i in $(seq 1 60); do
if curl -fsS "${SIGNIA_API_URL}/health" >/dev/null 2>&1; then
echo "SIGNIA API is ready."
break
fi
sleep 1
done
# -----------------------------
# E2E flow: compile → verify → publish → query
# -----------------------------
- name: Compile (example: OpenAPI)
run: |
set -euo pipefail
mkdir -p "${SIGNIA_E2E_OUT}/run"
# Use an example file in the repo. Adjust the path to match your final examples directory.
"${SIGNIA_E2E_OUT}/signia" compile \
--input "file:examples/openapi/petstore.yaml" \
--out "${SIGNIA_E2E_OUT}/run/openapi" \
--format bundle
test -f "${SIGNIA_E2E_OUT}/run/openapi/schema.json"
test -f "${SIGNIA_E2E_OUT}/run/openapi/manifest.json"
test -f "${SIGNIA_E2E_OUT}/run/openapi/proof.json"
- name: Verify bundle
run: |
set -euo pipefail
"${SIGNIA_E2E_OUT}/signia" verify \
--bundle "${SIGNIA_E2E_OUT}/run/openapi" \
--schemas "./schemas/v1"
- name: Publish to registry (optional)
if: ${{ hashFiles('programs/signia-registry/Anchor.toml') != '' }}
run: |
set -euo pipefail
# Assumes CLI has a publish command that can target a registry program on localnet.
"${SIGNIA_E2E_OUT}/signia" publish \
--cluster localnet \
--rpc http://127.0.0.1:8899 \
--bundle "${SIGNIA_E2E_OUT}/run/openapi" \
--program-id auto \
--commitment confirmed
- name: Query registry (optional)
if: ${{ hashFiles('programs/signia-registry/Anchor.toml') != '' }}
run: |
set -euo pipefail
# Example query by schema hash produced in schema.json.
SCHEMA_HASH="$(jq -r '.schema_hash' "${SIGNIA_E2E_OUT}/run/openapi/schema.json")"
test -n "${SCHEMA_HASH}"
"${SIGNIA_E2E_OUT}/signia" fetch \
--cluster localnet \
--rpc http://127.0.0.1:8899 \
--schema-hash "${SCHEMA_HASH}" \
--out "${SIGNIA_E2E_OUT}/run/fetched.json"
test -f "${SIGNIA_E2E_OUT}/run/fetched.json"
- name: API compile endpoint smoke test
run: |
set -euo pipefail
# Assumes API provides POST /v1/compile accepting JSON; adjust to your final OpenAPI.
# This is a smoke test placeholder; keep it simple.
curl -fsS "${SIGNIA_API_URL}/health" | cat
# -----------------------------
# Cleanup
# -----------------------------
- name: Stop services
if: always()
run: |
set +e
if [ -f /tmp/signia-api.pid ]; then
kill "$(cat /tmp/signia-api.pid)" || true
fi
if [ -f /tmp/solana-validator.pid ]; then
kill "$(cat /tmp/solana-validator.pid)" || true
fi
- name: Upload logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-logs
path: |
/tmp/signia-e2e/logs
/tmp/signia-e2e/run
if-no-files-found: warn