-
Notifications
You must be signed in to change notification settings - Fork 9
355 lines (328 loc) · 16.4 KB
/
rust.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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
ubuntu-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install llvm 16
run: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 16 && rm llvm.sh
- name: Install riscv64 target
run: rustup target add riscv64imac-unknown-none-elf
- name: Install cargo generate
run: cargo install cargo-generate
- name: Generate workspace
run: cargo generate --path . workspace --name test-workspace
- name: Generate crates && contracts
run: cd test-workspace &&
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
- name: Submodules
run: cd test-workspace &&
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
- name: Run all checks
run: cd test-workspace && make build test check clippy
- name: Reproducible build runs
run: cd test-workspace && ./scripts/reproducible_build_docker --update && ./scripts/reproducible_build_docker --no-clean
- name: Generate standalone contract
run: cargo generate --path . standalone-contract --name test-contract
- name: Run all checks
run: cd test-contract && make build test check clippy
- name: Reproducible build runs
run: cd test-contract && ./scripts/reproducible_build_docker --update && ./scripts/reproducible_build_docker --no-clean
ubuntu-arm64-docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup qemu binfmt
run: docker run --privileged --rm tonistiigi/binfmt --install all
- name: Install cargo generate
run: cargo install cargo-generate
- name: Generate workspace
run: cargo generate --path . workspace --name test-workspace
- name: Generate crates && contracts
run: cd test-workspace &&
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
- name: Submodules
run: cd test-workspace &&
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
- name: Reproducible build runs
run: cd test-workspace && export DOCKER_RUN_ARGS="--platform linux/arm64" && ./scripts/reproducible_build_docker --update && ./scripts/reproducible_build_docker --no-clean
- name: Generate standalone contract
run: cargo generate --path . standalone-contract --name test-contract
- name: Reproducible build runs
run: cd test-contract && export DOCKER_RUN_ARGS="--platform linux/arm64" && ./scripts/reproducible_build_docker --update && ./scripts/reproducible_build_docker --no-clean
debian-build:
runs-on: ubuntu-latest
container:
image: debian:latest
env:
USER: ${{ github.actor }}
steps:
- name: Install dependencies
run: apt-get update && apt-get -y install curl git build-essential pkg-config libssl-dev lsb-release wget software-properties-common gnupg
- name: Install llvm 16
run: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh 16 && rm llvm.sh
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
target: riscv64imac-unknown-none-elf
- uses: actions/checkout@v3
with:
submodules: true
- name: Install cargo generate
run: cargo install cargo-generate
- name: Generate workspace
run: cargo generate --path . workspace --name test-workspace
- name: Generate crates && contracts
run: cd test-workspace &&
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
- name: Submodules
run: cd test-workspace &&
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
- name: Run all checks
run: cd test-workspace && make build test check clippy
- name: Generate standalone contract
run: cargo generate --path . standalone-contract --name test-contract
- name: Run all checks
run: cd test-contract && make build test check clippy
fedora-build:
runs-on: ubuntu-latest
container:
image: fedora:latest
env:
USER: ${{ github.actor }}
steps:
- name: Install dependencies
run: sudo dnf -y install clang llvm git make openssl-devel
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
target: riscv64imac-unknown-none-elf
- uses: actions/checkout@v3
with:
submodules: true
- name: Install cargo generate
run: cargo install cargo-generate
- name: Generate workspace
run: cargo generate --path . workspace --name test-workspace
- name: Generate crates && contracts
run: cd test-workspace &&
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
- name: Submodules
run: cd test-workspace &&
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
- name: Run all checks
run: cd test-workspace && make build test check clippy
- name: Generate standalone contract
run: cargo generate --path . standalone-contract --name test-contract
- name: Run all checks
run: cd test-contract && make build test check clippy
arch-build:
runs-on: ubuntu-latest
container:
image: archlinux:latest
env:
USER: ${{ github.actor }}
steps:
- name: Install dependencies
run: pacman --noconfirm -Syu clang llvm git make openssl pkgconf
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
target: riscv64imac-unknown-none-elf
- uses: actions/checkout@v3
with:
submodules: true
- name: Install cargo generate
run: cargo install cargo-generate
- name: Generate workspace
run: cargo generate --path . workspace --name test-workspace
- name: Generate crates && contracts
run: cd test-workspace &&
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
- name: Submodules
run: cd test-workspace &&
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
- name: Run all checks
run: cd test-workspace && make build test check clippy
- name: Generate standalone contract
run: cargo generate --path . standalone-contract --name test-contract
- name: Run all checks
run: cd test-contract && make build test check clippy
macos-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install llvm 16
run: brew install llvm@16
- name: Install riscv64 target
run: rustup target add riscv64imac-unknown-none-elf
- name: Install cargo generate
run: cargo install cargo-generate
- name: Generate workspace
run: cargo generate --path . workspace --name test-workspace
- name: Generate crates && contracts
run: cd test-workspace &&
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
- name: Submodules
run: cd test-workspace &&
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
- name: Run all checks
run: cd test-workspace && make build test check clippy
- name: Generate standalone contract
run: cargo generate --path . standalone-contract --name test-contract
- name: Run all checks
run: cd test-contract && make build test check clippy
# For now, github action's latest arm64-based macos runner does not support docker. We will have to
# Use an order version for now to test reproducible build on macOS. Maybe when macOS 15 is out we can
# re-test later.
#
# References:
# * https://github.com/orgs/community/discussions/69211
# * https://github.com/marketplace/actions/setup-docker-on-macos
# NOTE: this test is not stable right now, disabling it till we can find a better solution
# macos-x64-reproducible-build:
#
# runs-on: macos-13
#
# steps:
# - uses: actions/checkout@v3
# with:
# submodules: true
# - name: Setup Docker on macOS
# run: brew install docker colima && colima start
# - name: Install llvm 16
# run: brew install llvm@16
# - name: Install riscv64 target
# run: rustup target add riscv64imac-unknown-none-elf
# - name: Install cargo generate
# run: cargo install cargo-generate
# - name: Generate workspace
# run: cargo generate --path . workspace --name test-workspace
# - name: Generate crates && contracts
# run: cd test-workspace &&
# make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
# make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
# make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
# make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
# make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
# - name: Submodules
# run: cd test-workspace &&
# git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
# git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
# - name: Reproducible build runs
# run: cd test-workspace && ./scripts/reproducible_build_docker --update && ./scripts/reproducible_build_docker --no-clean
# - name: Generate standalone contract
# run: cargo generate --path . standalone-contract --name test-contract
# - name: Reproducible build runs
# run: cd test-contract && ./scripts/reproducible_build_docker --update && ./scripts/reproducible_build_docker --no-clean
windows-build:
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install llvm
shell: pwsh
# https://github.com/ScoopInstaller/Install#for-admin
#
# Note that on Windows we cannot choose LLVM 16 here, we have to settle on latest stable LLVM
run: |
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
scoop install llvm yasm
echo "$env:USERPROFILE\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Install riscv64 target
run: rustup target add riscv64imac-unknown-none-elf
- name: Install cargo generate
run: cargo install cargo-generate
- name: Generate workspace
run: cargo generate --path . workspace --name test-workspace
- name: Generate crates && contracts
run: cd test-workspace &&
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
- name: Submodules
run: cd test-workspace &&
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
- name: Run all checks
run: cd test-workspace && make build test check clippy
- name: Generate standalone contract
run: cargo generate --path . standalone-contract --name test-contract
- name: Run all checks
run: cd test-contract && make build test check clippy
freebsd-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Build in FreeBSD VM
uses: vmactions/freebsd-vm@v1
with:
usesh: true
prepare: |
set -ex
pkg install -y llvm16 git gmake bash
curl https://sh.rustup.rs -sSf | sh -s -- -y
. $HOME/.cargo/env
rustup target add riscv64imac-unknown-none-elf
cargo install cargo-generate
run: |
set -ex
. $HOME/.cargo/env
cargo generate --path . standalone-contract --name test-contract
cd test-contract
gmake build test check clippy
cd ..
cargo generate --path . workspace --name test-workspace
cd test-workspace
gmake generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=..
gmake generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=..
gmake generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
gmake generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
gmake generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
gmake build test check clippy