-
Notifications
You must be signed in to change notification settings - Fork 53
230 lines (200 loc) · 8.01 KB
/
ci.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
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
name: continuous-integration/examples
on:
push:
branches:
- main
tags:
- v*
paths-ignore:
- '**.gitignore'
- '.images/**'
- '**README.md'
- 'LICENSE'
pull_request:
branches:
- main
paths-ignore:
- '**.gitignore'
- '.images/**'
- '**README.md'
- 'LICENSE'
jobs:
prepare_matrix:
name:
runs-on: ubuntu-latest
env:
# constant values for matrix
platform: '[\"ubuntu-latest\", \"macos-latest\"]'
toolchain: '[\"stable\"]'
outputs:
MATRIX: ${{ steps.build_matrix.outputs.MATRIX }}
SKIP_CHECKS: ${{ steps.build_matrix.outputs.SKIP_CHECKS }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Look for changes in standalone contracts
id: CHANGED_CONTRACTS
uses: tj-actions/changed-files@v41
with:
dir_names: "true"
dir_names_exclude_current_dir: "true"
dir_names_max_depth: 1
files_ignore: |
.github/**
.vscode/**
**/.gitignore
**/*.md
multi-contract-caller/**
upgradeable-contracts/**
workspace-contracts/**
ui/**
**/frontend/**
json: true
- name: Look for changes in multi and upgradable contracts
id: CHANGED_MULTI_AND_UPGRADEABLE_CONTRACTS
uses: tj-actions/changed-files@v41
with:
dir_names: "true"
dir_names_exclude_current_dir: "true"
dir_names_max_depth: 2
files: |
multi-contract-caller/**
upgradeable-contracts/**
files_ignore: |
**/.gitignore
**/*.md
workspace-contracts/**
json: true
- name: Look for changes in workspace contracts
id: CHANGED_WORKSPACE_CONTRACTS
uses: tj-actions/changed-files@v41
with:
dir_names: "true"
dir_names_exclude_current_dir: "true"
dir_names_max_depth: 2
files: |
workspace-contracts/**
files_ignore: |
**/.gitignore
**/*.md
json: true
- name: List all changed files
run: |
echo " Changed workspace contracts "
for file in ${{ steps.CHANGED_WORKSPACE_CONTRACTS.outputs.all_changed_files }}; do
echo "$file was changed"
done
echo "no more files.."
- name: Build matrix
id: build_matrix
run: |
ALL_CHANGED_CONTRACTS=$(jq -s 'add' \
<(echo "${{ steps.CHANGED_CONTRACTS.outputs.all_changed_files }}") \
<(echo "${{ steps.CHANGED_MULTI_AND_UPGRADEABLE_CONTRACTS.outputs.all_changed_files }}"))
if [ ${{steps.CHANGED_WORKSPACE_CONTRACTS.outputs.all_changed_files }} = "[]" ]
then
echo "Nothing important changed. Workspace contracts job will be skipped."
else
ALL_CHANGED_CONTRACTS=$(jq -s 'add' \
<(echo "$ALL_CHANGED_CONTRACTS") \
<(echo "[\"workspace-contracts\"]"))
fi
if [ $ALL_CHANGED_CONTRACTS = "[]" ]
then
echo "Nothing important changed. Checks job will be skipped."
echo "SKIP_CHECKS=true" >> $GITHUB_OUTPUT
else
echo "There are changes in following contracts: $ALL_CHANGED_CONTRACTS"
echo "SKIP_CHECKS=false" >> $GITHUB_OUTPUT
fi
echo "MATRIX={\"platform\":${{env.platform}},\
\"toolchain\":${{env.toolchain}},\
\"contract\":"$ALL_CHANGED_CONTRACTS"}"\
>> $GITHUB_OUTPUT
- name: Show resulting matrix
run: |
echo "Following matrix will be used to generate test jobs."
echo ${{ toJson(steps.build_matrix.outputs.MATRIX) }} | jq
check:
name: examples
needs: prepare_matrix
if: ${{ needs.prepare_matrix.outputs.SKIP_CHECKS == 'false' }}
env:
RUST_BACKTRACE: full
strategy:
matrix:
${{ fromJson(needs.prepare_matrix.outputs.MATRIX) }}
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout sources & submodules
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: recursive
- name: Install toolchain
id: toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
components: rust-src
override: true
- name: Rust Cache
uses: Swatinem/[email protected]
with:
cache-on-failure: true
workspaces: ${{ matrix.contract }}
key: ${{ matrix.contract }}
- name: Install `cargo-contract` `main`
uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941 # v2.2.0
with:
crate: cargo-contract
git: https://github.com/paritytech/cargo-contract.git
cache-key: ${{ matrix.platform }}
- name: Install cargo-dylint
uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941 # v2.2.0
with:
crate: cargo-dylint
version: 1
- name: Install dylint-link
uses: baptiste0928/cargo-install@21a18ba3bf4a184d1804e8b759930d3471b1c941 # v2.2.0
with:
crate: dylint-link
version: 1
- name: Download and run latest `substrate-contracts-node` binary
if: runner.os == 'Linux'
run: |
curl -L -o substrate-contracts-node.zip 'https://gitlab.parity.io/parity/mirrors/substrate-contracts-node/-/jobs/artifacts/main/download?job=build-linux' && \
unzip substrate-contracts-node.zip && \
chmod +x artifacts/substrate-contracts-node-linux/substrate-contracts-node &&
./artifacts/substrate-contracts-node-linux/substrate-contracts-node -linfo,runtime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &
- name: Download and run latest `substrate-contracts-node` binary
if: runner.os == 'macOS'
run: |
curl -L -o substrate-contracts-node.zip 'https://gitlab.parity.io/parity/mirrors/substrate-contracts-node/-/jobs/artifacts/main/download?job=build-mac' && \
unzip substrate-contracts-node.zip && \
chmod +x artifacts/substrate-contracts-node-mac/substrate-contracts-node &&
./artifacts/substrate-contracts-node-mac/substrate-contracts-node -linfo,runtime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &
- name: Install and run latest `substrate-contracts-node` binary
if: runner.os == 'Windows'
run: |
cargo install contracts-node --git https://github.com/paritytech/substrate-contracts-node.git --force --locked && \
substrate-contracts-node -lruntime::contracts=debug 2>&1 | tee /tmp/contracts-node.log &
- name: Output versions
run: |
cargo -vV
cargo contract --version
- name: Build ${{ matrix.contract }} on ${{ matrix.platform }}-${{ matrix.toolchain }}
if: runner.os != 'Windows' && matrix.contract != 'workspace-contracts'
run: cargo contract build --verbose --manifest-path=${{ matrix.contract }}/Cargo.toml;
- name: Test ${{ matrix.contract }} on ${{ matrix.platform }}-${{ matrix.toolchain }}
if: runner.os != 'Windows' && matrix.contract != 'workspace-contracts'
run: cargo test --verbose --manifest-path=${{ matrix.contract }}/Cargo.toml;
- name: Build workspace ${{ matrix.contract }} on ${{ matrix.platform }}-${{ matrix.toolchain }}
if: runner.os != 'Windows' && matrix.contract == 'workspace-contracts'
run: |
echo FOLLOWING SEEMS TO WORK WITH CARGO-CONTRACT 4.0
cargo contract build --verbose --manifest-path=workspace-contracts/flipper/Cargo.toml
cargo contract build --verbose --manifest-path=workspace-contracts/incrementer/Cargo.toml