-
Notifications
You must be signed in to change notification settings - Fork 12
ci: chainspec sync check #537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9ecc264
ci: chainspec sync check for Polkadot, Westend, and Paseo
x3c41a 5885523
ci: decouple chainspec sync omni-node version from runtime SDK pin
x3c41a 478cae1
ci: use just binaries-polkadot for omni-node download
x3c41a 9e26019
ci: drop workflow env overrides, use shared .github/env values
x3c41a 5360c29
ci: run chainspec sync step under bash for pipefail support
x3c41a ecec2ed
ci: pre-warm omni-node cache in dedicated setup job
x3c41a c6353ac
ci: extract chainspec sync logic to scripts/chainspec_sync_check.sh
x3c41a File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| name: Chainspec sync check | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - 'chainspecs/**' | ||
| - '.github/workflows/chainspec-sync-check.yml' | ||
| - '.github/env' | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| set-image: | ||
| uses: ./.github/workflows/set-image.yml | ||
|
|
||
| # Pre-warm the binary cache once so matrix legs hit the cache instead of | ||
| # each one source-building polkadot-omni-node independently. | ||
| setup: | ||
| needs: [set-image] | ||
| name: Setup | ||
| runs-on: parity-large | ||
| container: | ||
| image: ${{ needs.set-image.outputs.CI_IMAGE }} | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Load common environment variables via env file | ||
| run: cat .github/env >> $GITHUB_ENV | ||
|
|
||
| - uses: ./.github/actions/install-just | ||
|
|
||
| - name: Cache polkadot-node binaries | ||
| id: cache-binaries | ||
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 | ||
| with: | ||
| path: ${{ env.POLKADOT_BINARIES_DIR }}/polkadot-node | ||
| key: polkadot-node-${{ runner.os }}-${{ env.POLKADOT_NODE_VERSION }} | ||
|
|
||
| - name: Populate cache | ||
| if: steps.cache-binaries.outputs.cache-hit != 'true' | ||
| run: just binaries-polkadot | ||
|
|
||
| sync-check: | ||
| needs: [set-image, setup] | ||
| name: Sync (${{ matrix.name }}) | ||
| runs-on: parity-large | ||
| container: | ||
| image: ${{ needs.set-image.outputs.CI_IMAGE }} | ||
| timeout-minutes: 30 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - name: polkadot | ||
| chainspec: chainspecs/polkadot-chainspec.json | ||
| relay_rpc: wss://rpc.polkadot.io | ||
| - name: westend | ||
| chainspec: chainspecs/westend-chainspec.json | ||
| relay_rpc: wss://westend-rpc.polkadot.io | ||
| - name: paseo-next | ||
| chainspec: chainspecs/paseo-next-chainspec.json | ||
| relay_rpc: wss://paseo.dotters.network | ||
| - name: paseo-next-v2 | ||
| chainspec: chainspecs/paseo-next-v2-chainspec.json | ||
| relay_rpc: wss://paseo.dotters.network | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Load common environment variables via env file | ||
| run: cat .github/env >> $GITHUB_ENV | ||
|
|
||
| - uses: ./.github/actions/install-just | ||
|
|
||
| - name: Restore binary cache | ||
| uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 | ||
| with: | ||
| path: ${{ env.POLKADOT_BINARIES_DIR }}/polkadot-node | ||
| key: polkadot-node-${{ runner.os }}-${{ env.POLKADOT_NODE_VERSION }} | ||
| fail-on-cache-miss: true | ||
|
|
||
| - name: Resolve binary directory | ||
| run: | | ||
| POLKADOT_DIR="$(just binaries-polkadot)" | ||
| echo "$POLKADOT_DIR" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Sync a few blocks | ||
| shell: bash | ||
| env: | ||
| CHAINSPEC: ${{ matrix.chainspec }} | ||
| RELAY_RPC: ${{ matrix.relay_rpc }} | ||
| run: | | ||
| set -euo pipefail | ||
| LOG="omni-node.log" | ||
| TARGET_BLOCKS=3 | ||
| TIMEOUT_SECONDS=600 | ||
|
|
||
| polkadot-omni-node \ | ||
| --chain "$CHAINSPEC" \ | ||
| --tmp \ | ||
| --no-hardware-benchmarks \ | ||
| --rpc-port 9944 \ | ||
| --relay-chain-rpc-urls "$RELAY_RPC" \ | ||
| --log info \ | ||
| > "$LOG" 2>&1 & | ||
| NODE_PID=$! | ||
|
|
||
| cleanup() { | ||
| kill "$NODE_PID" 2>/dev/null || true | ||
| wait "$NODE_PID" 2>/dev/null || true | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| deadline=$(( $(date +%s) + TIMEOUT_SECONDS )) | ||
| best=0 | ||
| while [ "$(date +%s)" -lt "$deadline" ]; do | ||
| if ! kill -0 "$NODE_PID" 2>/dev/null; then | ||
| echo "polkadot-omni-node exited before reaching block $TARGET_BLOCKS" | ||
| tail -n 200 "$LOG" | ||
| exit 1 | ||
| fi | ||
|
|
||
| response=$(curl -fs -m 5 -H "Content-Type: application/json" \ | ||
| -d '{"jsonrpc":"2.0","method":"chain_getHeader","params":[],"id":1}' \ | ||
| http://127.0.0.1:9944 || true) | ||
| hex=$(echo "$response" | jq -r '.result.number // "0x0"' 2>/dev/null || echo "0x0") | ||
| best=$(( hex )) | ||
| echo "best block: $best" | ||
|
|
||
| if [ "$best" -ge "$TARGET_BLOCKS" ]; then | ||
| echo "imported $best blocks for $CHAINSPEC" | ||
| exit 0 | ||
| fi | ||
|
|
||
| sleep 10 | ||
| done | ||
|
|
||
| echo "did not import $TARGET_BLOCKS blocks within ${TIMEOUT_SECONDS}s (last best=$best)" | ||
| tail -n 200 "$LOG" | ||
| exit 1 | ||
|
|
||
| - name: Upload omni-node log on failure | ||
| if: failure() | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: omni-node-${{ matrix.name }}.log | ||
| path: omni-node.log | ||
| retention-days: 7 | ||
|
|
||
| sync-check-complete: | ||
| name: All chainspec sync checks passed | ||
| needs: [sync-check] | ||
| if: always() | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Decide outcome | ||
| if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') | ||
| run: | | ||
| echo "Chainspec sync check failed or was cancelled" | ||
| exit 1 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.