-
Notifications
You must be signed in to change notification settings - Fork 2
277 lines (268 loc) · 10.7 KB
/
Copy pathci.yml
File metadata and controls
277 lines (268 loc) · 10.7 KB
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
name: CI
on:
push:
branches:
- main
tags:
- v*
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# common variable is defined in the workflow
# repo env variable doesn't work for PR from forks
env:
CI_IMAGE: "useink/ci"
POLKADOT_SDK_BRANCH: "unstable2507"
RUST_VERSION: 1.88.0
jobs:
set-image:
# This workaround sets the container image for each job using 'set-image' job output.
# env variables don't work for PR from forks, so we need to use outputs.
runs-on: ubuntu-latest
outputs:
CI_IMAGE: ${{ steps.set_image.outputs.CI_IMAGE }}
steps:
- id: set_image
run: echo "CI_IMAGE=${{ env.CI_IMAGE }}" >> $GITHUB_OUTPUT
fmt:
name: Cargo fmt
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- uses: actions/checkout@v6
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
cache-all-crates: true
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
- name: Cargo fmt
run: cargo +nightly fmt --all -- --check
build-test-linux:
name: Build Linux
runs-on: ubuntu-latest
timeout-minutes: 240
needs: [set-image, fmt]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Free Disk Space
uses: endersonmenezes/free-disk-space@v2
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_tool_cache: true
remove_swap: true
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
remove_packages_one_command: true
remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
testing: false
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
cache-all-crates: true
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
- name: Build and Test Linux
run: |
mkdir -p ./artifacts/ink-node-linux/
echo "######## cargo build ########"
cargo build --release
cp target/release/ink-node ./artifacts/ink-node-linux/ink-node
echo "######## cargo test ########"
cargo test --release --all
rm -rf target/
echo "######## Building eth-rpc ########"
git clone --depth 300 --branch $POLKADOT_SDK_BRANCH https://github.com/paritytech/polkadot-sdk.git
cd polkadot-sdk
git checkout $POLKADOT_SDK_BRANCH
cargo build --locked --profile production -p pallet-revive-eth-rpc --bin eth-rpc
cd ..
echo "######## Packing artifacts ########"
cp polkadot-sdk/target/production/eth-rpc ./artifacts/ink-node-linux/eth-rpc
ls -la ./artifacts/ink-node-linux/
- name: Upload artifacts
uses: actions/upload-artifact@v4.3.6
with:
name: build-linux
path: ./artifacts
build-linux-arm64:
name: Build Linux ARM64
runs-on: ubuntu-latest
timeout-minutes: 240
needs: [ set-image, fmt ]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- name: Free Disk Space
uses: endersonmenezes/free-disk-space@v2
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_tool_cache: true
remove_swap: true
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
remove_packages_one_command: true
remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
testing: false
- uses: actions/checkout@v6
- name: Install ARM64 toolchain
run: |
rustup target add aarch64-unknown-linux-gnu
apt update
apt install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
cache-all-crates: true
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
- name: Build and Test Linux ARM64
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
run: |
mkdir -p ./artifacts/ink-node-linux-arm64/
echo "######## cargo build ########"
cargo build --release --target aarch64-unknown-linux-gnu
cp target/aarch64-unknown-linux-gnu/release/ink-node ./artifacts/ink-node-linux-arm64/ink-node
rm -rf target/
echo "######## Building eth-rpc ########"
git clone --depth 300 --branch $POLKADOT_SDK_BRANCH https://github.com/paritytech/polkadot-sdk.git
cd polkadot-sdk
git checkout $POLKADOT_SDK_BRANCH
cargo build --locked --profile production -p pallet-revive-eth-rpc --bin eth-rpc --target aarch64-unknown-linux-gnu
cd ..
echo "######## Packing artifacts ########"
cp polkadot-sdk/target/aarch64-unknown-linux-gnu/production/eth-rpc ./artifacts/ink-node-linux-arm64/eth-rpc
ls -la ./artifacts/ink-node-linux-arm64/
- name: Upload artifacts
uses: actions/upload-artifact@v4.3.6
with:
name: build-linux-arm64
path: ./artifacts
build-macos:
timeout-minutes: 240
runs-on: macos-latest
needs: [fmt]
strategy:
fail-fast: false
matrix:
os: ["macos-latest"]
steps:
- uses: actions/checkout@v6
- name: Clone polkadot-sdk
run: |
git clone --depth 300 --branch $POLKADOT_SDK_BRANCH https://github.com/paritytech/polkadot-sdk.git
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@1ccc07ccd54b6048295516a3eb89b192c35057dc # master from 12.09.2024
- name: Install protobuf
run: brew install protobuf
- name: Install rust ${{ env.RUST_VERSION }}
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
with:
cache: false
toolchain: ${{ env.RUST_VERSION }}
target: wasm32-unknown-unknown, aarch64-apple-darwin, x86_64-apple-darwin
components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
brew install llvm
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
cache-all-crates: true
- name: Run cargo build
run: |
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
export LIBCLANG_PATH="$(brew --prefix llvm)/lib"
export LD_LIBRARY_PATH="$LIBCLANG_PATH:$LD_LIBRARY_PATH"
export CPATH="$(brew --prefix llvm)/include"
export PATH="$(brew --prefix llvm)/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"
export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"
echo "######## cargo build aarch64-apple-darwin ########"
cargo build --release --target aarch64-apple-darwin
echo "######## cargo build x86_64-apple-darwin ########"
cargo build --release --target x86_64-apple-darwin
echo "######## cargo build aarch64-apple-darwin eth-rpc ########"
cd polkadot-sdk
git checkout $POLKADOT_SDK_BRANCH
cargo build --locked --profile production -p pallet-revive-eth-rpc --bin eth-rpc --target aarch64-apple-darwin
echo "######## cargo build x86_64-apple-darwin eth-rpc ########"
cargo build --locked --profile production -p pallet-revive-eth-rpc --bin eth-rpc --target x86_64-apple-darwin
cd ..
echo "######## Packing artifacts ########"
mkdir -p ./artifacts/ink-node-mac/
lipo ./target/x86_64-apple-darwin/release/ink-node \
./target/aarch64-apple-darwin/release/ink-node \
-create -output ./artifacts/ink-node-mac/ink-node
lipo ./polkadot-sdk/target/x86_64-apple-darwin/production/eth-rpc \
./polkadot-sdk/target/aarch64-apple-darwin/production/eth-rpc \
-create -output ./artifacts/ink-node-mac/eth-rpc
ls -la ./artifacts/ink-node-mac/
- name: Upload artifacts
uses: actions/upload-artifact@v4.3.6
with:
name: build-macos
path: ./artifacts
publish:
name: Publish release
runs-on: ubuntu-latest
needs: [ build-test-linux, build-macos, build-linux-arm64 ]
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: build-linux
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: build-macos
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: build-linux-arm64
- name: Pack artifacts
run: |
tar -czvf ./ink-node-linux.tar.gz ./ink-node-linux
tar -czvf ./ink-node-mac-universal.tar.gz ./ink-node-mac
tar -czvf ./ink-node-linux-arm64.tar.gz ./ink-node-linux-arm64
ls -la
- name: Publish release
uses: ghalactic/github-release-from-tag@cebdacac0ccd08933b8e7f278f4123723ad978eb # v5.4.0
if: github.ref_type == 'tag'
with:
prerelease: false
draft: true
assets: |
- path: ink-node-linux.tar.gz
- path: ink-node-mac-universal.tar.gz
- path: ink-node-linux-arm64.tar.gz