-
Notifications
You must be signed in to change notification settings - Fork 55
326 lines (287 loc) · 11.5 KB
/
Copy pathstellar-verification.yml
File metadata and controls
326 lines (287 loc) · 11.5 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
name: Stellar Reproducible Build Verification
on:
schedule:
# Weekly: Monday at 06:00 UTC
- cron: '0 6 * * 1'
workflow_dispatch:
inputs:
network:
description: 'Stellar network to verify against'
required: true
default: 'testnet'
type: choice
options:
- testnet
- futurenet
- mainnet
skip_build:
description: 'Skip Docker build (use existing artifacts)'
required: false
default: false
type: boolean
permissions:
contents: write
id-token: write
jobs:
build-and-verify:
name: Build & Verify
runs-on: ubuntu-latest
# The reproducible-build verification pins the Debian base + rust
# toolchain + stellar-cli + soroban-sdk to specific versions. As
# transitive Cargo deps drift (edition 2024, MSRV bumps, etc.) the
# pinned combination stops compiling until someone bumps and re-audits.
# Keep this workflow non-blocking so a bit-rotted pin never blocks
# main-line contract merges — the real gates (SAC Integration Smoke
# Tests, Stellar Futurenet Integration Tests) run separately and stay
# authoritative.
continue-on-error: true
outputs:
status: ${{ steps.verify.outputs.status }}
summary: ${{ steps.verify.outputs.summary }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Get Commit Hash
id: vars
run: echo "commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Build Docker Image
if: ${{ !inputs.skip_build }}
run: |
docker build \
--build-arg COMMIT_HASH=${{ steps.vars.outputs.commit }} \
-t stellar-attestation-builder \
-f stellar/build/Dockerfile .
- name: Generate Attestation
id: attest
run: |
docker create --name builder stellar-attestation-builder
docker start -a builder
docker cp builder:/workspace/stellar/build/attestation.json ./attestation.json
docker rm builder
echo "Attestation generated."
- name: Display Attestation
run: |
echo "## Attestation Contents" >> $GITHUB_STEP_SUMMARY
echo '```json' >> $GITHUB_STEP_SUMMARY
cat attestation.json >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
working-directory: stellar
run: npm ci
- name: Verify Contracts Against Testnet
id: verify
working-directory: stellar
env:
CONTRACT_IDS: ${{ secrets.STELLAR_TESTNET_CONTRACT_IDS || '' }}
run: |
set -euo pipefail
NETWORK="${{ github.event.inputs.network || 'testnet' }}"
RESULTS_DIR="verification/results"
mkdir -p "../${RESULTS_DIR}"
CONTRACT_IDS_JSON="${CONTRACT_IDS:-{}}"
COMMIT_HASH="${{ steps.vars.outputs.commit }}"
# Track counters in a temp file to avoid subshell scoping issues
COUNTERS=$(mktemp)
echo 'failures=0' > "$COUNTERS"
echo 'passes=0' >> "$COUNTERS"
echo 'errors=0' >> "$COUNTERS"
# Initialize checks array as JSON
echo '[]' > "../${RESULTS_DIR}/checks.json"
for contract in "stealth-announcer" "stealth-registry" "stealth-sender" "wraith-names"; do
CONTRACT_NAME="$contract"
CONTRACT_ID=$(echo "$CONTRACT_IDS_JSON" | jq -r ".[\"${CONTRACT_NAME}\"] // empty" 2>/dev/null || echo "")
STATUS_FILE="../verification/results/${CONTRACT_NAME}.json"
if [ -z "$CONTRACT_ID" ]; then
echo "⚠️ No contract ID for ${CONTRACT_NAME}. Recording attestation-only check."
node build/verify.js \
--contract "${CONTRACT_NAME}" \
--network "${NETWORK}" \
--commit "${COMMIT_HASH}" \
--attestation "../attestation.json" \
--output "${STATUS_FILE}" \
|| true
source "$COUNTERS"
echo "errors=$((errors + 1))" > "$COUNTERS"
else
echo "🔍 Verifying ${CONTRACT_NAME} (${CONTRACT_ID})..."
if node build/verify.js \
--contract "${CONTRACT_NAME}" \
--id "${CONTRACT_ID}" \
--network "${NETWORK}" \
--commit "${COMMIT_HASH}" \
--attestation "../attestation.json" \
--output "${STATUS_FILE}"; then
source "$COUNTERS"
echo "passes=$((passes + 1))" > "$COUNTERS"
else
source "$COUNTERS"
echo "failures=$((failures + 1))" > "$COUNTERS"
fi
fi
# Append check result to checks array using jq
CHECK_CONTENT=$(cat "${STATUS_FILE}")
TMP_CHECK=$(mktemp)
jq --argjson check "$CHECK_CONTENT" '. += [$check]' "../${RESULTS_DIR}/checks.json" > "$TMP_CHECK"
mv "$TMP_CHECK" "../${RESULTS_DIR}/checks.json"
done
# Read counters
source "$COUNTERS"
rm -f "$COUNTERS"
# Determine overall status
if [ "$failures" -gt 0 ]; then
echo "status=fail" >> $GITHUB_OUTPUT
echo "summary=❌ ${failures} failure(s), ${passes} passed, ${errors} skipped" >> $GITHUB_OUTPUT
elif [ "$errors" -eq 4 ]; then
echo "status=pending" >> $GITHUB_OUTPUT
echo "summary=⚠️ Attestation generated but no contract IDs configured for verification" >> $GITHUB_OUTPUT
else
echo "status=pass" >> $GITHUB_OUTPUT
echo "summary=✅ All ${passes} contracts verified successfully" >> $GITHUB_OUTPUT
fi
- name: Publish Verification Status
run: |
set -euo pipefail
NETWORK="${{ github.event.inputs.network || 'testnet' }}"
STATUS="${{ steps.verify.outputs.status }}"
SUMMARY="${{ steps.verify.outputs.summary }}"
tmpfile=$(mktemp)
jq -n \
--arg status "$STATUS" \
--arg summary "$SUMMARY" \
--arg network "$NETWORK" \
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--arg commit "${{ steps.vars.outputs.commit }}" \
--arg run_id "${{ github.run_id }}" \
--arg run_url "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
'{
status: $status,
summary: $summary,
network: $network,
last_run_timestamp: $timestamp,
commit: $commit,
run_id: $run_id,
run_url: $run_url,
checks: []
}' > "$tmpfile"
# Merge check results if they exist
if [ -f "stellar/verification/results/checks.json" ]; then
CHECKS=$(cat "stellar/verification/results/checks.json")
jq --argjson checks "$CHECKS" '.checks = $checks' "$tmpfile" > stellar/verification/status.json
else
cp "$tmpfile" stellar/verification/status.json
fi
rm -f "$tmpfile"
echo "Status written to stellar/verification/status.json"
cat stellar/verification/status.json | jq .
- name: Commit and Push status.json
run: |
set -euo pipefail
git config user.name "wraith-bot"
git config user.email "bot@wraith-protocol.xyz"
git add stellar/verification/status.json
if git diff --cached --quiet; then
echo "No changes to status.json"
else
git commit -m "chore(verification): update verification status [skip ci]"
git push
echo "✅ status.json committed and pushed"
fi
- name: Send Webhook Notification (on failure)
if: steps.verify.outputs.status == 'fail'
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
set -euo pipefail
NETWORK="${{ github.event.inputs.network || 'testnet' }}"
STATUS="${{ steps.verify.outputs.status }}"
SUMMARY="${{ steps.verify.outputs.summary }}"
COMMIT="${{ steps.vars.outputs.commit }}"
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# Slack notification
if [ -n "${SLACK_WEBHOOK:-}" ]; then
echo "Sending Slack notification..."
PAYLOAD=$(jq -n \
--arg status "$STATUS" \
--arg summary "$SUMMARY" \
--arg network "$NETWORK" \
--arg commit "$COMMIT" \
--arg run_url "$RUN_URL" \
'{
text: ("🔴 *Wraith Contract Verification Failed*\nNetwork: " + $network + "\nStatus: " + $status + "\nSummary: " + $summary + "\nCommit: " + $commit + "\nRun: " + $run_url)
}')
curl -s -X POST -H 'Content-Type: application/json' -d "$PAYLOAD" "$SLACK_WEBHOOK" || echo "Slack notification failed"
fi
# Discord notification
if [ -n "${DISCORD_WEBHOOK:-}" ]; then
echo "Sending Discord notification..."
DISCORD_PAYLOAD=$(jq -n \
--arg summary "$SUMMARY" \
--arg network "$NETWORK" \
--arg commit "$COMMIT" \
--arg run_url "$RUN_URL" \
'{
embeds: [{
title: "🔴 Contract Verification Failed",
color: 15548997,
fields: [
{ name: "Network", value: $network, inline: true },
{ name: "Status", value: "fail", inline: true },
{ name: "Summary", value: $summary, inline: false },
{ name: "Commit", value: $commit, inline: true },
{ name: "Run", value: $run_url, inline: false }
],
timestamp: (now | todate)
}]
}')
curl -s -X POST -H 'Content-Type: application/json' -d "$DISCORD_PAYLOAD" "$DISCORD_WEBHOOK" || echo "Discord notification failed"
fi
- name: Upload Verification Artifacts
uses: actions/upload-artifact@v4
if: always()
with:
name: verification-results
path: |
attestation.json
stellar/verification/status.json
stellar/verification/results/*.json
github-pages-deploy:
name: Deploy Status Page
needs: build-and-verify
if: always()
runs-on: ubuntu-latest
continue-on-error: true
permissions:
contents: write
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Prepare deployment directory
run: |
mkdir -p _site
cp stellar/verification/index.html _site/
cp stellar/verification/status.json _site/
- name: Upload Pages Artifact
uses: actions/upload-pages-artifact@v3
with:
path: _site
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4