-
Notifications
You must be signed in to change notification settings - Fork 4
293 lines (256 loc) · 9.26 KB
/
contracts.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
name: Contracts builds and tests
on:
workflow_call:
inputs:
rust-toolchain:
description: 'Rust toolchain to use'
default: 'nightly'
required: false
type: string
sc-meta-version:
description: 'multiversx-sc-meta version'
default: ''
required: false
type: string
mx-scenario-go-version:
description: 'sc-scenario-go version'
default: ''
required: false
type: string
path-to-sc-meta:
description: 'multiversx-sc-meta from local'
default: ''
required: false
type: string
clippy-args:
description: 'cargo clippy arguments'
default: '--all-targets --all-features'
required: false
type: string
enable-contracts-size-report:
description: 'Enable contracts size report'
default: true
required: false
type: boolean
coverage-args:
description: 'sc-meta test-coverage arguments'
default: '--output ./coverage.md'
required: false
type: string
wabt-version:
description: 'wabt version to use'
default: '1.0.27-1'
required: false
type: string
secrets:
token:
description: 'Github token'
required: true
jobs:
wasm_test:
name: Wasm tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ inputs.rust-toolchain }}
target: wasm32-unknown-unknown
- name: Install prerequisites
run: |
sudo apt install -y wabt=${{ inputs.wabt-version }}
cargo install wasm-opt
cargo install twiggy
if [[ "${{ inputs.path-to-sc-meta }}" ]];
then
cargo install --path ${{ inputs.path-to-sc-meta }}
elif [[ -z "${{ inputs.sc-meta-version }}" ]];
then
cargo install multiversx-sc-meta --locked
else
cargo install multiversx-sc-meta --version ${{ inputs.sc-meta-version }} --locked
fi
if [[ -z "${{ inputs.mx-scenario-go-version }}" ]];
then
sc-meta install mx-scenario-go
else
sc-meta install mx-scenario-go --tag ${{ inputs.mx-scenario-go-version }}
fi
which wasm-opt
which mx-scenario-go
- name: Build the wasm contracts
env:
RUSTFLAGS: ""
run: sc-meta all build --no-imports --target-dir $(pwd)/target --path .
- name: Run the wasm tests
env:
RUSTFLAGS: ""
run: cargo test --features multiversx-sc-scenario/run-go-tests
- name: Generate the contract report via sc-meta
if: ${{ inputs.enable-contracts-size-report }}
env:
RUSTFLAGS: ""
run: |
sc-meta report compile --path . --output report.json
- name: Upload the report json from sc-meta
if: ${{ inputs.enable-contracts-size-report }}
uses: actions/upload-artifact@v3
with:
name: report
path: report.json
- name: Download the base report
uses: dawidd6/action-download-artifact@v2
if: ${{ github.event_name == 'pull_request' && inputs.enable-contracts-size-report }}
continue-on-error: true
with:
workflow: actions.yml
name: report
commit: ${{ github.event.pull_request.base.sha }}
path: base-report
- name: Generate the report template
if: ${{ github.event_name == 'pull_request' && inputs.enable-contracts-size-report }}
run: |
echo "Contract comparison - from {{ .base }} to {{ .head }}" > report.md
sc-meta report compare --baseline base-report/report.json --new report.json --output report-table.md
cat report-table.md >> report.md
- name: Render the report from the template
id: template
uses: chuhlomin/render-template@v1
if: ${{ github.event_name == 'pull_request' && inputs.enable-contracts-size-report }}
with:
template: report.md
vars: |
base: ${{ github.event.pull_request.base.sha }}
head: ${{ github.event.pull_request.head.sha }}
- name: Upload the report markdown
uses: actions/upload-artifact@v3
if: ${{ github.event_name == 'pull_request' && inputs.enable-contracts-size-report }}
with:
name: report-markdown
path: report.md
- name: Find the comment containing the report
id: fc
uses: peter-evans/find-comment@v2
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && inputs.enable-contracts-size-report }}
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Contract comparison'
- name: Create or update the report comment
uses: peter-evans/create-or-update-comment@v2
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && inputs.enable-contracts-size-report }}
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.template.outputs.result }}
edit-mode: replace
interactor_tests:
name: Interactor tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ inputs.rust-toolchain }}
target: wasm32-unknown-unknown
- name: Install prerequisites
run: |
cargo install wasm-opt
cargo install twiggy
if [[ "${{ inputs.path-to-sc-meta }}" ]];
then
cargo install --path ${{ inputs.path-to-sc-meta }}
elif [[ -z "${{ inputs.sc-meta-version }}" ]];
then
cargo install multiversx-sc-meta --locked
else
cargo install multiversx-sc-meta --version ${{ inputs.sc-meta-version }} --locked
fi
which wasm-opt
- name: Build the wasm contracts
env:
RUSTFLAGS: ""
run: sc-meta all build --no-imports --target-dir $(pwd)/target --path .
- name: Run the interactor tests
env:
RUSTFLAGS: ""
run: make chain-simulator
test_coverage:
name: Test Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ inputs.rust-toolchain }}
target: wasm32-unknown-unknown
- name: Install prerequisites
run: |
rustup component add llvm-tools-preview
dirname $(find ~/.rustup -name llvm-cov) >> $GITHUB_PATH
echo $(dirname $(find ~/.rustup -name llvm-cov))
if [[ "${{ inputs.path-to-sc-meta }}" ]];
then
cargo install --path ${{ inputs.path-to-sc-meta }}
elif [[ -z "${{ inputs.sc-meta-version }}" ]];
then
cargo install multiversx-sc-meta --locked
else
cargo install multiversx-sc-meta --version ${{ inputs.sc-meta-version }} --locked
fi
- name: Run tests and generate report
env:
RUSTFLAGS: ""
run: |
sc-meta test-coverage ${{ inputs.coverage-args }}
- name: Upload the report
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage.md
- name: Find the comment containing the report
id: fc
uses: peter-evans/find-comment@v2
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "Coverage Summary"
- name: Create or update the report comment
uses: peter-evans/create-or-update-comment@v2
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-file: ./coverage.md
edit-mode: replace
rust_test:
name: Rust tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ inputs.rust-toolchain }}
- name: Run the rust tests
env:
RUSTFLAGS: ""
run: cargo test
clippy_check:
name: Clippy linter check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ inputs.rust-toolchain }}
components: clippy
- uses: giraffate/clippy-action@v1
env:
RUSTFLAGS: ""
with:
github_token: ${{ github.token }}
clippy_flags: ${{ inputs.clippy-args }}