-
Notifications
You must be signed in to change notification settings - Fork 763
139 lines (117 loc) · 4.9 KB
/
verify-templates-dev-chain-spec.yml
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
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