-
Notifications
You must be signed in to change notification settings - Fork 24
292 lines (272 loc) · 9.81 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
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
on:
pull_request:
push:
branches:
- main
tags:
- 'v*'
name: CI
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: arduino/setup-protoc@v2
- uses: actions/checkout@v3
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- run: cargo check --workspace --all-features
test:
name: Test Suite
needs:
- check
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
toolchain: stable
- os: [self-hosted, linux, arm64]
rustflags: --cfg=aes_armv8
toolchain: nightly-2023-06-27 # required for AES (https://docs.rs/aes/0.8.2/aes/#armv8-intrinsics-nightly-only)
- os: [self-hosted, macos, arm64]
rustflags: --cfg=aes_armv8
toolchain: nightly-2023-06-27 # required for AES (https://docs.rs/aes/0.8.2/aes/#armv8-intrinsics-nightly-only)
- os: macos-latest
toolchain: stable
- os: windows-2019
toolchain: stable
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- if: matrix.os == 'ubuntu-20.04'
run: sudo apt-get install -y libpocl2 mesa-opencl-icd ocl-icd-opencl-dev
name: Install dependencies for testing openCL
- if: matrix.os == 'windows-2019'
name: Install dependencies for linking openCL
run: |
choco install -y wget unzip opencl-intel-cpu-runtime
wget https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v2023.04.17/OpenCL-SDK-v2023.04.17-Win-x64.zip
unzip -j OpenCL-SDK-v2023.04.17-Win-x64.zip OpenCL-SDK-v2023.04.17-Win-x64/lib/OpenCL.lib
- uses: Swatinem/rust-cache@v2
- name: Test post crate
run: cargo test --all-features --release
env:
RUSTFLAGS: ${{ matrix.rustflags }}
# https://github.com/tevador/RandomX/issues/262
# https://github.com/tari-project/randomx-rs/issues/48
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk"
- name: Test scrypt-ocl crate
if: matrix.os != 'windows-2019'
run: cargo test -p scrypt-ocl --all-features --release -- --test-threads=1
env:
RUSTFLAGS: ${{ matrix.rustflags }}
# https://github.com/tevador/RandomX/issues/262
# https://github.com/tari-project/randomx-rs/issues/48
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk"
- name: Test ffi crate
run: cargo test -p post-cbindings --all-features --release -- --test-threads=1
env:
RUSTFLAGS: ${{ matrix.rustflags }}
# https://github.com/tevador/RandomX/issues/262
# https://github.com/tari-project/randomx-rs/issues/48
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk"
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: arduino/setup-protoc@v2
- uses: actions/checkout@v3
with:
submodules: true
- uses: dtolnay/rust-toolchain@master
with:
components: clippy
toolchain: nightly-2023-06-27
- uses: Swatinem/rust-cache@v2
- name: Annotate commit with clippy warnings
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features --workspace
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Install stable
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo generate-lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile
- name: cargo llvm-cov
run: cargo llvm-cov --locked --all-features --lcov --output-path lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build library
runs-on: ${{ matrix.os }}
needs:
- test
- fmt
- clippy
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-20.04
dylib: libpost.so
staticlib: libpost.a
artifact-name: linux
toolchain: stable
- os: [self-hosted, linux, arm64]
dylib: libpost.so
staticlib: libpost.a
rustflags: --cfg=aes_armv8
artifact-name: linux-arm64
toolchain: nightly-2023-06-27 # required for AES (https://docs.rs/aes/0.8.2/aes/#armv8-intrinsics-nightly-only)
- os: [self-hosted, macos, arm64]
dylib: libpost.dylib
staticlib: libpost.a
rustflags: --cfg=aes_armv8
artifact-name: macos-m1
toolchain: nightly-2023-06-27 # required for AES (https://docs.rs/aes/0.8.2/aes/#armv8-intrinsics-nightly-only)
- os: macos-latest
dylib: libpost.dylib
staticlib: libpost.a
artifact-name: macos
toolchain: stable
- os: windows-2019
dylib: post.dll
staticlib: post.lib
artifact-name: windows
toolchain: stable
steps:
- if: matrix.os == 'ubuntu-20.04'
run: sudo apt-get install -y libpocl2 mesa-opencl-icd ocl-icd-opencl-dev
name: Install opencl
- if: matrix.os == 'windows-2019'
name: Install opencl
run: vcpkg install opencl
- uses: actions/checkout@v3
with:
submodules: true
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ join( matrix.os, '-' ) }}
- if: matrix.os == 'windows-2019'
name: Download OpenCL.lib
run: |
choco install -y wget unzip
wget https://github.com/KhronosGroup/OpenCL-SDK/releases/download/v2023.04.17/OpenCL-SDK-v2023.04.17-Win-x64.zip
unzip -j OpenCL-SDK-v2023.04.17-Win-x64.zip OpenCL-SDK-v2023.04.17-Win-x64/lib/OpenCL.lib
- name: Version suffix (for release only)
id: version
run: echo "suffix=${{ github.ref_type == 'tag' && '-' || ''}}${{ github.ref_type == 'tag' && github.ref || ''}}" >> $GITHUB_OUTPUT
- name: Build clib
run: cargo build -p post-cbindings --profile release-clib
env:
RUSTFLAGS: ${{ matrix.rustflags }}
# https://github.com/tevador/RandomX/issues/262
# https://github.com/tari-project/randomx-rs/issues/48
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk"
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: libpost-${{ matrix.artifact-name }}${{ steps.version.output.suffix }}
path: |
ffi/post.h
target/release-clib/${{ matrix.dylib }}
target/release-clib/${{ matrix.staticlib }}
if-no-files-found: error
- name: Build profiler tool
run: cargo build -p profiler --release
env:
RUSTFLAGS: ${{ matrix.rustflags }}
# https://github.com/tevador/RandomX/issues/262
# https://github.com/tari-project/randomx-rs/issues/48
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk"
- name: Archive profiler artifacts
uses: actions/upload-artifact@v3
with:
name: profiler-${{ matrix.artifact-name }}${{ steps.version.output.suffix }}
path: |
target/release/profiler${{ matrix.os == 'windows-2019' && '.exe' || '' }}
if-no-files-found: error
- uses: arduino/setup-protoc@v2
- name: Build service
run: cargo build -p service --release
env:
RUSTFLAGS: ${{ matrix.rustflags }}
SDKROOT: "/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk"
- name: Archive service artifacts
uses: actions/upload-artifact@v3
with:
name: service-${{ matrix.artifact-name }}${{ steps.version.output.suffix }}
path: |
target/release/service${{ matrix.os == 'windows-2019' && '.exe' || '' }}
if-no-files-found: error
release:
name: Publish release
if: github.event_name == 'push' && github.ref_type == 'tag'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: ./artifacts
- name: List artifacts
run: ls -R ./artifacts
- name: Create a draft release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false
- name: Pack artifacts
run: >
mkdir ./assets;
for dir in ./artifacts/*/; do
zip -o -j -r "./assets/$(basename "$dir")-$TAG.zip" "$dir";
done
env:
TAG: ${{ github.ref_name }}
- name: Upload Release Assets
run: gh release upload $TAG ./assets/*.zip
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}