forked from zecdev/ZecKit
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
287 lines (257 loc) · 10.7 KB
/
Copy pathaction.yml
File metadata and controls
287 lines (257 loc) · 10.7 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
name: 'ZecKit E2E'
description: 'Standardized Zcash E2E test suite for GitHub CI'
inputs:
backend:
description: "Light-client backend: 'lwd' or 'zaino'"
required: false
default: 'zaino'
startup_timeout_minutes:
description: 'Minutes to wait for Zebra + Backend to reach health'
required: false
default: '20'
block_wait_seconds:
description: 'Seconds to wait after mining for propagation'
required: false
default: '75'
send_amount:
description: 'Amount in ZEC for the E2E golden flow transaction'
required: false
default: '0.05'
send_memo:
description: 'Memo string for the E2E golden flow transaction'
required: false
default: 'ZecKit E2E Transaction'
upload_artifacts:
description: "Artifact upload policy: 'always' | 'on-failure' | 'never'"
required: false
default: 'on-failure'
ghcr_token:
description: 'GitHub token for pulling/pushing images'
required: false
image_prefix:
description: 'Custom prefix for docker images (if using local fork)'
required: false
default: ''
allow_build:
description: "Whether to allow building images from source if missing (default: true for stability)"
required: false
default: 'true'
miner_address:
description: 'Custom transparent address to receive Zebra mining rewards (uses embedded default if omitted)'
required: false
default: ''
fund_address:
description: 'Address to automatically fund after the devnet is healthy (skipped if omitted)'
required: false
default: ''
fund_amount:
description: 'Amount in ZEC to send to fund_address (default: 10.0)'
required: false
default: '10.0'
only_setup:
description: 'If true, skip the ZecKit smoke tests and only start the devnet'
required: false
default: 'false'
block_interval:
description: 'Custom block mining interval in seconds'
required: false
default: '15'
activation_heights:
description: 'Custom activation heights in key=value format (e.g. nu5=1,nu6=10)'
required: false
default: ''
outputs:
unified_address:
description: "Faucet's Unified Address"
value: ${{ steps.e2e.outputs.unified_address }}
shield_txid:
description: 'TXID of the transparent-to-shielded transaction'
value: ${{ steps.e2e.outputs.shield_txid }}
send_txid:
description: 'TXID of the E2E golden flow send'
value: ${{ steps.e2e.outputs.send_txid }}
final_orchard_balance:
description: 'Final Orchard balance of the faucet wallet'
value: ${{ steps.e2e.outputs.final_orchard_balance }}
test_result:
description: "Outcome of the E2E run: 'pass' | 'fail'"
value: ${{ steps.e2e.outputs.test_result }}
runs:
using: "composite"
steps:
- name: Set up environment
shell: bash
run: |
echo "Starting ZecKit E2E Action..."
echo "Backend: ${{ inputs.backend }}"
echo "Action Path: ${{ github.action_path }}"
echo "Action Ref: ${{ github.action_ref }}"
- name: Detect platform
id: platform
shell: bash
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
echo "binary=zeckit-linux-x86_64" >> $GITHUB_OUTPUT
elif [[ "$RUNNER_OS" == "macOS" ]]; then
if [[ "$RUNNER_ARCH" == "ARM64" ]]; then
echo "binary=zeckit-macos-aarch64" >> $GITHUB_OUTPUT
else
echo "binary=zeckit-macos-x86_64" >> $GITHUB_OUTPUT
fi
else
echo "Unsupported OS: $RUNNER_OS"
exit 1
fi
- name: Try to download prebuilt ZecKit CLI
id: download
continue-on-error: true
shell: bash
run: |
VERSION="${{ github.action_ref }}"
BINARY="${{ steps.platform.outputs.binary }}"
# If VERSION is empty, it means we are using the action locally (self-test)
# We should build from source to test the local CLI changes.
if [[ -z "$VERSION" ]]; then
echo "Local execution detected (action_ref is empty). Skipping download to build from source."
echo "downloaded=false" >> $GITHUB_OUTPUT
exit 0
fi
# Robustly detect the repository hosting the action (fork-safe)
# GitHub checkouts actions into _actions/<owner>/<repo>/ref
OWNER_REPO=$(echo "${{ github.action_path }}" | awk -F'/_actions/' '{print $2}' | cut -d'/' -f1,2)
if [ -z "$OWNER_REPO" ]; then
OWNER_REPO="zecdev/ZecKit" # Fallback to upstream
fi
BASE="https://github.com/${OWNER_REPO}/releases"
mkdir -p "${{ github.action_path }}/bin"
# Determine version for download
if [[ "$VERSION" == "main" ]] || [[ "$VERSION" == "m3-implementation" ]]; then
DL_URL="$BASE/latest/download/$BINARY"
else
# Clean version tag (strip 'refs/tags/' if present)
TAG="${VERSION#refs/tags/}"
DL_URL="$BASE/download/$TAG/$BINARY"
fi
echo "Attempting to download $DL_URL..."
curl -L -f -o "${{ github.action_path }}/bin/zeckit" "$DL_URL"
if [ $? -eq 0 ]; then
chmod +x "${{ github.action_path }}/bin/zeckit"
echo "✓ Successfully downloaded prebuilt binary"
echo "downloaded=true" >> $GITHUB_OUTPUT
else
echo "⚠️ Prebuilt binary not found for version $VERSION. Will fall back to building from source."
echo "downloaded=false" >> $GITHUB_OUTPUT
fi
- name: Build ZecKit CLI (Fallback)
if: steps.download.outputs.downloaded != 'true'
shell: bash
run: |
echo "Building ZecKit CLI from source..."
cd ${{ github.action_path }}
cargo build --locked -p zeckit
- name: Registry Login
if: inputs.ghcr_token != ''
shell: bash
run: |
echo "${{ inputs.ghcr_token }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Run E2E Suite
id: e2e
shell: bash
env:
ZECKIT_ALLOW_BUILD: "${{ inputs.allow_build }}"
ZECKIT_SRC_PATH: ${{ github.action_path }}
run: |
# Use downloaded binary or fall back to built one
if [[ "${{ steps.download.outputs.downloaded }}" == "true" ]]; then
CLI="${{ github.action_path }}/bin/zeckit"
else
CLI="${{ github.action_path }}/target/debug/zeckit"
fi
echo "Using ZecKit CLI at: $CLI"
# Build optional flags from action inputs
ZECKIT_UP_EXTRA_ARGS=()
if [ -n "${{ inputs.miner_address }}" ]; then
ZECKIT_UP_EXTRA_ARGS+=(--miner-address "${{ inputs.miner_address }}")
fi
if [ -n "${{ inputs.fund_address }}" ]; then
ZECKIT_UP_EXTRA_ARGS+=(--fund-address "${{ inputs.fund_address }}")
fi
if [ -n "${{ inputs.block_interval }}" ]; then
ZECKIT_UP_EXTRA_ARGS+=(--block-interval "${{ inputs.block_interval }}")
fi
if [ -n "${{ inputs.activation_heights }}" ]; then
ZECKIT_UP_EXTRA_ARGS+=(--activation-heights "${{ inputs.activation_heights }}")
fi
# Resolve image prefix
IMAGE_PREFIX="${{ inputs.image_prefix }}"
if [ -z "$IMAGE_PREFIX" ]; then
# Detect the repository hosting the action (fork-safe)
OWNER_REPO=$(echo "${{ github.action_path }}" | awk -F'/_actions/' '{print $2}' | cut -d'/' -f1,2)
if [ -z "$OWNER_REPO" ]; then
OWNER_REPO="intelliDean/ZecKit"
fi
IMAGE_PREFIX="ghcr.io/$(echo "$OWNER_REPO" | tr '[:upper:]' '[:lower:]')"
fi
echo "Resolved image prefix: $IMAGE_PREFIX"
# Run the devnet
"$CLI" up \
--backend "${{ inputs.backend }}" \
--timeout "${{ inputs.startup_timeout_minutes }}" \
--action-mode \
--fund-amount "${{ inputs.fund_amount }}" \
--image-prefix "$IMAGE_PREFIX" \
"${ZECKIT_UP_EXTRA_ARGS[@]}"
# Skip test phase if only_setup is true
if [ "${{ inputs.only_setup }}" = "true" ]; then
echo "only_setup=true: skipping smoke tests"
echo "test_result=skip" >> $GITHUB_OUTPUT
exit 0
fi
# Disable exit-on-error temporarily so we can parse outputs
set +e
# Run the tests
"$CLI" test \
--amount "${{ inputs.send_amount }}" \
--memo "${{ inputs.send_memo }}" \
--action-mode
CLI_EXIT_CODE=$?
# Re-enable exit-on-error
set -e
# Extract metadata from logs if exists
if [ -f ~/.zeckit/logs/run-summary.json ]; then
echo "unified_address=$(jq -r .faucet_address ~/.zeckit/logs/run-summary.json)" >> $GITHUB_OUTPUT
echo "shield_txid=$(jq -r .shield_txid ~/.zeckit/logs/run-summary.json)" >> $GITHUB_OUTPUT
echo "send_txid=$(jq -r .send_txid ~/.zeckit/logs/run-summary.json)" >> $GITHUB_OUTPUT
echo "final_orchard_balance=$(jq -r .final_balance ~/.zeckit/logs/run-summary.json)" >> $GITHUB_OUTPUT
echo "test_result=$(jq -r .test_result ~/.zeckit/logs/run-summary.json)" >> $GITHUB_OUTPUT
else
echo "test_result=fail" >> $GITHUB_OUTPUT
fi
echo "Exiting with CLI code: $CLI_EXIT_CODE"
exit $CLI_EXIT_CODE
- name: Collect Docker Logs
if: always()
shell: bash
run: |
echo "Collecting container logs..."
if [ ! -d ~/.zeckit ]; then echo "zeckit devnet never launched successfully - skipping artifact collection"; exit 0; fi
cd ~/.zeckit
mkdir -p logs
docker ps -a > logs/containers.log 2>&1 || true
docker network ls > logs/networks.log 2>&1 || true
docker compose -f docker-compose.yml logs zebra-miner > logs/zebra.log 2>&1 || true
docker compose -f docker-compose.yml logs faucet-${{ inputs.backend }} > logs/faucet.log 2>&1 || true
docker compose -f docker-compose.yml logs lightwalletd > logs/lightwalletd.log 2>&1 || true
docker compose -f docker-compose.yml logs zaino > logs/zaino.log 2>&1 || true
# Copy to workspace to avoid relative path tracking error in upload-artifact@v4
mkdir -p "${{ github.workspace }}/zeckit-e2e-logs-${{ inputs.backend }}"
cp -r logs/* "${{ github.workspace }}/zeckit-e2e-logs-${{ inputs.backend }}/" || true
- name: Upload Artifacts
if: |
always() &&
(inputs.upload_artifacts == 'always' || (inputs.upload_artifacts == 'on-failure' && steps.e2e.outputs.test_result != 'pass'))
uses: actions/upload-artifact@v4
with:
name: zeckit-e2e-logs-${{ github.job }}-${{ inputs.backend }}-${{ github.run_number }}
path: ${{ github.workspace }}/zeckit-e2e-logs-${{ inputs.backend }}/
retention-days: 14