|
9 | 9 | options: [preprod, preview] |
10 | 10 | required: false |
11 | 11 | demo_target_epoch: |
12 | | - description: "Override DEMO_TARGET_EPOCH (leave empty for latest)" |
| 12 | + description: "Override DEMO_TARGET_EPOCH (leave empty for fixed epoch)" |
13 | 13 | required: false |
14 | 14 | timeout: |
15 | 15 | description: "Override timeout for snapshot tests" |
|
31 | 31 | ~/.cargo/registry/cache/ |
32 | 32 | ~/.cargo/git/db/ |
33 | 33 | target/ |
34 | | - INPUT_TIMEOUT: ${{ github.event.inputs.timeout }} |
35 | | - AMARU_TRACE: ${{ github.event.inputs.demo_trace_level }} |
36 | 34 | RUSTUP_LOG: error |
37 | 35 |
|
38 | 36 | permissions: |
39 | 37 | contents: read |
| 38 | + actions: write |
40 | 39 |
|
41 | 40 | jobs: |
42 | 41 | build: |
@@ -187,229 +186,24 @@ jobs: |
187 | 186 | token: ${{ secrets.CODECOV_TOKEN }} |
188 | 187 | files: lcov.info |
189 | 188 |
|
190 | | - snapshots-instance-choice: |
191 | | - name: End-to-end snapshot preparation |
192 | | - runs-on: ubuntu-22.04 |
193 | | - outputs: |
194 | | - runner: ${{ steps.alt-runner.outputs.runner || 'ubuntu-22.04' }} |
195 | | - steps: |
196 | | - - id: alt-runner |
197 | | - if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' |
198 | | - run: echo "runner=buildjet-4vcpu-ubuntu-2204" >> $GITHUB_OUTPUT |
199 | | - |
200 | 189 | snapshots: |
201 | 190 | name: End-to-end snapshot tests |
202 | | - needs: snapshots-instance-choice |
203 | | - runs-on: ${{ needs.snapshots-instance-choice.outputs.runner }} |
204 | | - strategy: |
205 | | - matrix: |
206 | | - network: |
207 | | - - name: preprod |
208 | | - magic: 1 |
209 | | - target_epoch: 176 |
210 | | - default-timeout-light-run: 15 |
211 | | - default-timeout-full-run: 60 |
212 | | - - name: preview |
213 | | - magic: 2 |
214 | | - target_epoch: 680 |
215 | | - tests-may-fail: true |
216 | | - default-timeout-light-run: 15 |
217 | | - default-timeout-full-run: 60 |
218 | | - cardano_node_version: [10.5.3] |
219 | | - env: |
220 | | - AMARU_TRACE: info,amaru::consensus=debug,amaru::ledger=debug,pure_stage=warn,amaru_protocols=warn,amaru_consensus=info |
221 | | - AMARU_NETWORK: ${{ matrix.network.name }} |
222 | | - BUILD_PROFILE: test |
223 | | - AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} |
224 | | - AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} |
225 | | - AWS_DEFAULT_REGION: auto |
226 | | - ENDPOINT: ${{ secrets.S3_ENDPOINT }} |
227 | | - OBJECT: "s3://${{ secrets.CARDANO_NODE_BUCKET_NAME }}/${{ matrix.network.name }}.tar.zstd" |
228 | | - CARDANO_CLI_VERSION: 10.11.0.0 |
229 | | - DEFAULT_TIMEOUT_LIGHT: ${{ matrix.network.default-timeout-light-run }} |
230 | | - DEFAULT_TIMEOUT_FULL: ${{ matrix.network.default-timeout-full-run }} |
231 | 191 | if: ${{ !github.event.pull_request.draft }} |
232 | | - continue-on-error: true |
233 | | - |
234 | | - steps: |
235 | | - - name: Gate and prepare environment |
236 | | - shell: bash |
237 | | - continue-on-error: true |
238 | | - run: | |
239 | | - set -eux |
240 | | -
|
241 | | - SHOULD_RUN=true |
242 | | -
|
243 | | - # Skip this network test if a specific network is requested |
244 | | - if [ "${{ github.event_name }}" = "workflow_dispatch" ] && \ |
245 | | - [ -n "${{ github.event.inputs.network }}" ] && \ |
246 | | - [ "${{ github.event.inputs.network }}" != "${{ matrix.network.name }}" ]; then |
247 | | - SHOULD_RUN=false |
248 | | - fi |
249 | | -
|
250 | | - if [ "$SHOULD_RUN" != "true" ]; then |
251 | | - echo "Skipping network '${{ matrix.network.name }}' as per workflow_dispatch input" |
252 | | - exit 1 |
253 | | - fi |
254 | | -
|
255 | | - TIMEOUT_RUN="${DEFAULT_TIMEOUT_LIGHT}" |
256 | | - if [ -n "${{ github.event.inputs.demo_target_epoch }}" ]; then |
257 | | - DEMO_TARGET_EPOCH="${{ github.event.inputs.demo_target_epoch }}" |
258 | | - echo "Using DEMO_TARGET_EPOCH from workflow_dispatch: $DEMO_TARGET_EPOCH" |
259 | | - elif [ "${{ github.event_name }}" = "pull_request" ]; then |
260 | | - DEMO_TARGET_EPOCH=${{ matrix.network.target_epoch }} |
261 | | - echo "Using DEMO_TARGET_EPOCH from matrix.network: $DEMO_TARGET_EPOCH" |
262 | | - else |
263 | | - # For pushes, we will retrieve the latest epoch in a later step |
264 | | - DEMO_TARGET_EPOCH="" |
265 | | - TIMEOUT_RUN="${DEFAULT_TIMEOUT_FULL}" |
266 | | - fi |
267 | | -
|
268 | | - if [ -n "$INPUT_TIMEOUT" ]; then |
269 | | - echo "Using INPUT_TIMEOUT from workflow_dispatch: $INPUT_TIMEOUT" |
270 | | - TIMEOUT_RUN="${INPUT_TIMEOUT}" |
271 | | - fi |
272 | | -
|
273 | | - # Make sure to export all env variables for subsequent steps |
274 | | - echo "DEMO_TARGET_EPOCH=$DEMO_TARGET_EPOCH" >> "$GITHUB_ENV" |
275 | | - echo "TIMEOUT_RUN=$TIMEOUT_RUN" >> "$GITHUB_ENV" |
276 | | -
|
277 | | - - name: Support longpaths |
278 | | - run: git config --system core.longpaths true |
279 | | - if: contains(needs.snapshots-instance-choice.outputs.runner, 'windows') |
280 | | - - uses: actions/checkout@v4 |
281 | | - |
282 | | - - name: Reclaim Disk Space |
283 | | - run: | |
284 | | - chmod +x ./scripts/cleanup-runner.sh |
285 | | - ./scripts/cleanup-runner.sh |
286 | | -
|
287 | | - - id: timestamp |
288 | | - shell: bash |
289 | | - run: | |
290 | | - echo "value=$(/bin/date -u '+%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT |
291 | | -
|
292 | | - - name: Download (Haskell) cardano-node's db |
293 | | - shell: bash |
294 | | - run: | |
295 | | - set -euo pipefail |
296 | | - mkdir -p "${{ runner.temp }}/db" |
297 | | - aws s3 cp "$OBJECT" - --endpoint-url "$ENDPOINT" | tar --zstd -xf - -C "${{ runner.temp }}/db" |
298 | | - touch ${{ runner.temp }}/db/clean |
299 | | -
|
300 | | - - name: Spawn Haskell Node |
301 | | - id: spawn-cardano-node |
302 | | - shell: bash |
303 | | - run: | |
304 | | - docker pull ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano_node_version }} |
305 | | - make HASKELL_NODE_CONFIG_DIR=cardano-node-config AMARU_NETWORK=${{ matrix.network.name }} download-haskell-config |
306 | | - jq 'del(.bootstrapPeers)' ./cardano-node-config/topology.json > cardano-node-config/topology.patched.json |
307 | | - mv cardano-node-config/topology.patched.json cardano-node-config/topology.json |
308 | | - docker run -d --name cardano-node \ |
309 | | - -v ${{ runner.temp }}/db:/db \ |
310 | | - -v ${{ runner.temp }}/ipc:/ipc \ |
311 | | - -v ./cardano-node-config:/config \ |
312 | | - -v ./cardano-node-config:/genesis \ |
313 | | - -p 3001:3001 \ |
314 | | - ghcr.io/intersectmbo/cardano-node:${{ matrix.cardano_node_version }} run \ |
315 | | - --config /config/config.json \ |
316 | | - --database-path /db \ |
317 | | - --socket-path /ipc/node.socket \ |
318 | | - --topology /config/topology.json |
319 | | -
|
320 | | - - uses: actions/cache/restore@v4 |
321 | | - with: |
322 | | - path: ${{ env.RUST_CACHE_PATH }} |
323 | | - key: cargo-x86_64-unknown-linux-gnu |
324 | | - restore-keys: | |
325 | | - cargo-x86_64-unknown-linux-gnu |
326 | | -
|
327 | | - - name: Build Amaru |
328 | | - shell: bash |
329 | | - run: | |
330 | | - cargo test --profile $BUILD_PROFILE --no-run -p amaru |
331 | | -
|
332 | | - - name: Cache Amaru's ledger.${{ matrix.network.name }}.db |
333 | | - id: cache-ledger-db |
334 | | - uses: actions/cache/restore@v4 |
335 | | - with: |
336 | | - path: ./ledger.${{ matrix.network.name }}.db |
337 | | - # If the ledger store serialisation format changes and become |
338 | | - # incompatible, it is necessary to bump the index below to invalidate |
339 | | - # the cached ledger snapshots, and recompute them from the CBOR ones |
340 | | - # (i.e. Full bootstrap below) |
341 | | - key: ${{ runner.OS }}-ledger-cache-v12-${{ steps.timestamp.outputs.value }} |
342 | | - restore-keys: | |
343 | | - ${{ runner.OS }}-ledger-cache-v12 |
344 | | -
|
345 | | - - name: Full bootstrap amaru |
346 | | - if: steps.cache-ledger-db.outputs.cache-hit == '' |
347 | | - shell: bash |
348 | | - run: | |
349 | | - make bootstrap |
350 | | -
|
351 | | - - name: Light bootstrap amaru |
352 | | - if: steps.cache-ledger-db.outputs.cache-hit != '' |
353 | | - shell: bash |
354 | | - run: | |
355 | | - make import-headers |
356 | | - make import-nonces |
357 | | -
|
358 | | - - uses: actions/cache/save@v4 |
359 | | - if: github.event_name == 'push' || steps.cache-ledger-db.outputs.cache-hit == '' |
360 | | - with: |
361 | | - path: ./ledger.${{ matrix.network.name }}.db |
362 | | - key: ${{ runner.OS }}-ledger-cache-v12-${{ steps.timestamp.outputs.value }} |
363 | | - |
364 | | - - name: Retrieve latest epoch if needed |
365 | | - if: env.DEMO_TARGET_EPOCH == '' |
366 | | - shell: bash |
367 | | - run: | |
368 | | - curl -L -o cardano-cli.tar.gz \ |
369 | | - "https://github.com/IntersectMBO/cardano-cli/releases/download/cardano-cli-${CARDANO_CLI_VERSION}/cardano-cli-${CARDANO_CLI_VERSION}-x86_64-linux.tar.gz" |
370 | | -
|
371 | | - mkdir -p cardano-cli-bin |
372 | | - tar -xzf cardano-cli.tar.gz -C cardano-cli-bin |
373 | | - mv cardano-cli-bin/cardano-cli* cardano-cli-bin/cardano-cli |
374 | | - chmod +x cardano-cli-bin/cardano-cli |
375 | | -
|
376 | | - DEMO_TARGET_EPOCH=$( |
377 | | - sudo $PWD/cardano-cli-bin/cardano-cli query tip \ |
378 | | - --socket-path ${{ runner.temp }}/ipc/node.socket \ |
379 | | - --testnet-magic ${{ matrix.network.magic }} \ |
380 | | - | jq '.epoch - 1' |
381 | | - ) |
382 | | -
|
383 | | - echo "Auto-resolved DEMO_TARGET_EPOCH=$DEMO_TARGET_EPOCH" |
384 | | -
|
385 | | - # Make sure to export DEMO_TARGET_EPOCH for subsequent steps |
386 | | - echo "DEMO_TARGET_EPOCH=$DEMO_TARGET_EPOCH" >> "$GITHUB_ENV" |
387 | | -
|
388 | | - - name: Run node |
389 | | - timeout-minutes: ${{ fromJSON(env.TIMEOUT_RUN) }} |
390 | | - shell: bash |
391 | | - run: make AMARU_MAX_EXTRA_LEDGER_SNAPSHOTS=all demo |
392 | | - |
393 | | - - name: Run tests |
394 | | - if: github.event_name == 'pull_request' |
395 | | - continue-on-error: ${{ matrix.network.tests-may-fail || false }} |
396 | | - shell: bash |
397 | | - run: | |
398 | | - make test-e2e |
399 | | -
|
400 | | - - name: Teardown haskell node |
401 | | - if: ${{ always() }} |
402 | | - shell: bash |
403 | | - run: | |
404 | | - docker logs --tail 200 cardano-node || true |
405 | | - docker stop cardano-node |
406 | | - docker rm cardano-node |
407 | | -
|
408 | | - - uses: actions/cache/save@v4 |
409 | | - if: github.event_name == 'push' |
410 | | - with: |
411 | | - path: ${{ runner.temp }}/db-${{ matrix.network.name }} |
412 | | - key: cardano-node-ogmios-${{ matrix.network.name }}-${{ steps.timestamp.outputs.value }} |
| 192 | + uses: ./.github/workflows/snapshot-tests.yml |
| 193 | + with: |
| 194 | + use_fixed_epoch: true |
| 195 | + default_timeout: 15 |
| 196 | + network: ${{ github.event.inputs.network || '' }} |
| 197 | + demo_target_epoch: ${{ github.event.inputs.demo_target_epoch || '' }} |
| 198 | + timeout: ${{ github.event.inputs.timeout || '' }} |
| 199 | + demo_trace_level: ${{ github.event.inputs.demo_trace_level || '' }} |
| 200 | + use_buildjet_runner: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' }} |
| 201 | + run_tests: ${{ github.event_name == 'pull_request' }} |
| 202 | + secrets: |
| 203 | + R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} |
| 204 | + R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} |
| 205 | + S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} |
| 206 | + CARDANO_NODE_BUCKET_NAME: ${{ secrets.CARDANO_NODE_BUCKET_NAME }} |
413 | 207 |
|
414 | 208 | examples: |
415 | 209 | name: Examples |
|
0 commit comments