Add development chain-spec file for minimal/parachain templates for Omni Node compatibility #8
Workflow file for this run
This file contains 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
name: Verify Templates Dev Chain Spec | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
permissions: | |
contents: read | |
jobs: | |
setup: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
template: | |
- package_name: 'parachain-template-runtime' | |
runtime_path: './templates/parachain/runtime' | |
artifact_name: 'wasm-parachain-template-runtime' | |
chain_spec_output: 'parachain_test_chain_spec.json' | |
runtime_wasm_path: 'parachain-template-runtime/parachain_template_runtime.compact.compressed.wasm' | |
relay_chain: 'rococo-local' | |
- package_name: 'minimal-template-runtime' | |
runtime_path: './templates/minimal/runtime' | |
artifact_name: 'wasm-minimal-template-runtime' | |
chain_spec_output: 'minimal_test_chain_spec.json' | |
runtime_wasm_path: 'minimal-template-runtime/minimal_template_runtime.compact.compressed.wasm' | |
relay_chain: 'dev' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set rust version from env file | |
run: | | |
RUST_VERSION=$(cat .github/env | sed -E 's/.*ci-unified:([^-]+)-([^-]+).*/\2/') | |
echo $RUST_VERSION | |
echo "RUST_VERSION=${RUST_VERSION}" >> $GITHUB_ENV | |
- name: Install Rust | |
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8 # v1.10.1 | |
with: | |
cache: false | |
toolchain: ${{ env.RUST_VERSION }} | |
components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std | |
- name: Install srtool-cli | |
run: | | |
cargo install --git https://github.com/chevdor/srtool-cli | |
echo "Using srtool-cli Version:" | |
srtool --version | |
- name: Pull srtool docker image | |
run: | | |
srtool pull | |
- name: Prepare build directories | |
run: | | |
sudo mkdir -p ${{ matrix.template.runtime_path }}/target | |
sudo chmod -R 777 ${{ matrix.template.runtime_path }}/target | |
- name: Build runtime binary | |
run: | | |
srtool build --package ${{ matrix.template.package_name }} --runtime-dir ${{ matrix.template.runtime_path }} --root | |
- name: Install staging-chain-spec-builder and deps | |
run: | | |
# Install protobuf compiler | |
sudo apt-get update | |
sudo apt-get install -y protobuf-compiler | |
# Verify protoc installation | |
protoc --version | |
cargo install --path substrate/bin/utils/chain-spec-builder | |
- name: Create chain spec | |
run: | | |
chain-spec-builder -c ${{ matrix.template.chain_spec_output }} create \ | |
--relay-chain "${{ matrix.template.relay_chain }}" \ | |
--para-id 1000 \ | |
--runtime "${{ matrix.template.runtime_path }}/target/srtool/release/wbuild/${{ matrix.template.runtime_wasm_path }}" \ | |
named-preset development | |
- name: Upload chain spec artifact | |
uses: actions/[email protected] | |
with: | |
name: ${{ matrix.template.chain_spec_output }} | |
path: ${{ matrix.template.chain_spec_output }} | |
verify-template-chain-specs: | |
if: success() | |
needs: setup | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
template: | |
- runtime_path: './templates/parachain' | |
chain_spec_output: 'parachain_test_chain_spec.json' | |
- runtime_path: './templates/minimal' | |
chain_spec_output: 'minimal_test_chain_spec.json' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Download generated spec | |
uses: actions/[email protected] | |
with: | |
name: ${{ matrix.template.chain_spec_output }} | |
path: ./downloaded_spec | |
- name: Compare chain specs | |
run: | | |
sudo apt-get update && sudo apt-get install -y jq | |
# Check if files exist | |
if [ ! -f "${{ matrix.template.runtime_path }}/dev_chain_spec.json" ]; then | |
echo "❌ Reference spec not found at ${{ matrix.template.runtime_path }}/dev_chain_spec.json" | |
exit 1 | |
fi | |
if [ ! -f "./downloaded_spec/${{ matrix.template.chain_spec_output }}" ]; then | |
echo "❌ Generated spec not found at ./downloaded_spec/${{ matrix.template.chain_spec_output }}" | |
exit 1 | |
fi | |
jq -S . ${{ matrix.template.runtime_path }}/dev_chain_spec.json > existing_spec_sorted.json | |
jq -S . ./downloaded_spec/${{ matrix.template.chain_spec_output }} > generated_spec_sorted.json | |
echo "❌ Spec files differ:" | |
# Output the first 30 characters of each differing line for brevity | |
diff -C 3 existing_spec_sorted.json generated_spec_sorted.json | while read -r line; do | |
echo "${line:0:200}..." | |
done | |
# Exit with failure | |
exit 1 |