Skip to content

Commit 4ddf46c

Browse files
authored
Setup CI (#1)
* Create rust.yml * Update rust.yml * Update rust.yml * Update rust.yml * Update rust.yml * Update rust.yml * Update rust.yml * Update rust.yml * Update rust.yml * Portable sed * Update rust.yml * Update Makefile * Update Makefile * Use portable sed commands * Update sed command * Update Makefile * Try another attempt * Update rust.yml * Another attempt * Remove unneeded piece
1 parent f0c684b commit 4ddf46c

File tree

2 files changed

+200
-1
lines changed

2 files changed

+200
-1
lines changed

.github/workflows/rust.yml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
ubuntu-build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Install llvm 16
20+
run: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 16 && rm llvm.sh
21+
- name: Install riscv64 target
22+
run: rustup target add riscv64imac-unknown-none-elf
23+
- name: Install cargo generate
24+
run: cargo install cargo-generate
25+
- name: Generate workspace
26+
run: cargo generate --path . workspace --name test-workspace
27+
- name: Generate crates && contracts
28+
run: cd test-workspace &&
29+
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
30+
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
31+
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
32+
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
33+
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
34+
- name: Submodules
35+
run: cd test-workspace &&
36+
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
37+
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
38+
- name: Run all checks
39+
run: cd test-workspace && make build test check clippy
40+
- name: Generate standalone contract
41+
run: cargo generate --path . standalone-contract --name test-contract
42+
- name: Run all checks
43+
run: cd test-contract && make build test check clippy
44+
45+
fedora-build:
46+
47+
runs-on: ubuntu-latest
48+
container:
49+
image: fedora:latest
50+
env:
51+
USER: ${{ github.actor }}
52+
53+
steps:
54+
- name: Install dependencies
55+
run: sudo dnf -y install clang git make openssl-devel
56+
- uses: actions-rust-lang/setup-rust-toolchain@v1
57+
with:
58+
components: clippy
59+
target: riscv64imac-unknown-none-elf
60+
- uses: actions/checkout@v3
61+
with:
62+
submodules: true
63+
- name: Install cargo generate
64+
run: cargo install cargo-generate
65+
- name: Generate workspace
66+
run: cargo generate --path . workspace --name test-workspace
67+
- name: Generate crates && contracts
68+
run: cd test-workspace &&
69+
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
70+
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
71+
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
72+
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
73+
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
74+
- name: Submodules
75+
run: cd test-workspace &&
76+
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
77+
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
78+
- name: Run all checks
79+
run: cd test-workspace && make build test check clippy
80+
- name: Generate standalone contract
81+
run: cargo generate --path . standalone-contract --name test-contract
82+
- name: Run all checks
83+
run: cd test-contract && make build test check clippy
84+
85+
arch-build:
86+
87+
runs-on: ubuntu-latest
88+
container:
89+
image: archlinux:latest
90+
env:
91+
USER: ${{ github.actor }}
92+
93+
steps:
94+
- name: Install dependencies
95+
run: pacman --noconfirm -Syu clang git make openssl pkgconf
96+
- uses: actions-rust-lang/setup-rust-toolchain@v1
97+
with:
98+
components: clippy
99+
target: riscv64imac-unknown-none-elf
100+
- uses: actions/checkout@v3
101+
with:
102+
submodules: true
103+
- name: Install cargo generate
104+
run: cargo install cargo-generate
105+
- name: Generate workspace
106+
run: cargo generate --path . workspace --name test-workspace
107+
- name: Generate crates && contracts
108+
run: cd test-workspace &&
109+
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
110+
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
111+
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
112+
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
113+
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
114+
- name: Submodules
115+
run: cd test-workspace &&
116+
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
117+
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
118+
- name: Run all checks
119+
run: cd test-workspace && make build test check clippy
120+
- name: Generate standalone contract
121+
run: cargo generate --path . standalone-contract --name test-contract
122+
- name: Run all checks
123+
run: cd test-contract && make build test check clippy
124+
125+
macos-build:
126+
127+
runs-on: macos-latest
128+
129+
steps:
130+
- uses: actions/checkout@v3
131+
with:
132+
submodules: true
133+
- name: Install llvm 16
134+
run: brew install llvm@16
135+
- name: Install riscv64 target
136+
run: rustup target add riscv64imac-unknown-none-elf
137+
- name: Install cargo generate
138+
run: cargo install cargo-generate
139+
- name: Generate workspace
140+
run: cargo generate --path . workspace --name test-workspace
141+
- name: Generate crates && contracts
142+
run: cd test-workspace &&
143+
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
144+
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
145+
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
146+
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
147+
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
148+
- name: Submodules
149+
run: cd test-workspace &&
150+
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
151+
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
152+
- name: Run all checks
153+
run: cd test-workspace && make build test check clippy
154+
- name: Generate standalone contract
155+
run: cargo generate --path . standalone-contract --name test-contract
156+
- name: Run all checks
157+
run: cd test-contract && make build test check clippy
158+
159+
windows-build:
160+
161+
runs-on: windows-2019
162+
163+
steps:
164+
- uses: actions/checkout@v3
165+
with:
166+
submodules: true
167+
- name: Install llvm
168+
shell: pwsh
169+
# https://github.com/ScoopInstaller/Install#for-admin
170+
#
171+
# Note that on Windows we cannot choose LLVM 16 here, we have to settle on latest stable LLVM
172+
run: |
173+
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
174+
scoop install llvm yasm
175+
echo "$env:USERPROFILE\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
176+
- name: Install riscv64 target
177+
run: rustup target add riscv64imac-unknown-none-elf
178+
- name: Install cargo generate
179+
run: cargo install cargo-generate
180+
- name: Generate workspace
181+
run: cargo generate --path . workspace --name test-workspace
182+
- name: Generate crates && contracts
183+
run: cd test-workspace &&
184+
make generate CRATE=clib TEMPLATE=c-wrapper-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
185+
make generate CRATE=rlib TEMPLATE=x64-simulator-crate DESTINATION=crates TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
186+
make generate CRATE=c1 TEMPLATE=contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
187+
make generate CRATE=c2 TEMPLATE=atomics-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=.. &&
188+
make generate CRATE=c3 TEMPLATE=stack-reorder-contract TEMPLATE_TYPE=--path TEMPLATE_REPO=..
189+
- name: Submodules
190+
run: cd test-workspace &&
191+
git submodule add https://github.com/nervosnetwork/ckb-c-stdlib deps/ckb-c-stdlib &&
192+
git submodule add https://github.com/xxuejie/lib-dummy-atomics deps/lib-dummy-atomics
193+
- name: Run all checks
194+
run: cd test-workspace && make build test check clippy
195+
- name: Generate standalone contract
196+
run: cargo generate --path . standalone-contract --name test-contract
197+
- name: Run all checks
198+
run: cd test-contract && make build test check clippy

workspace/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ generate:
9898
cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) $(TEMPLATE) \
9999
--destination $(DESTINATION) \
100100
--name $(CRATE); \
101-
sed -i '/@@INSERTION_POINT@@/a \ \ "$(DESTINATION)/$(CRATE)",' Cargo.toml; \
101+
sed '/@@INSERTION_POINT@@/s/$$/\n "$(DESTINATION)\/$(CRATE)",/' Cargo.toml > Cargo.toml.new; \
102+
mv Cargo.toml.new Cargo.toml; \
102103
fi
103104

104105
prepare:

0 commit comments

Comments
 (0)