-
Notifications
You must be signed in to change notification settings - Fork 24
283 lines (263 loc) · 8.64 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
on:
pull_request:
push:
branches:
- main
tags:
- 'v*'
name: CI
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/[email protected]
- uses: Swatinem/rust-cache@v2
- run: cargo check --workspace --all-features
test:
name: Test Suite
needs:
- check
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- os: [self-hosted, linux, x64, intel]
- os: ubuntu-latest-arm-8-cores
rustflags: --cfg=aes_armv8
- os: [self-hosted, macos, arm64]
rustflags: --cfg=aes_armv8
- os: macos-13
toolchain: stable
- os: windows-2019
steps:
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/[email protected]
- if: matrix.os == 'ubuntu-latest-arm-8-cores'
run: sudo apt-get update && sudo apt-get install -y libpocl2 pocl-opencl-icd ocl-icd-opencl-dev
name: Install dependencies for testing openCL on Linux
- if: matrix.os == 'windows-2019'
name: Install dependencies for testing openCL on Windows
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: Benchmarks
run: cargo bench --no-run
env:
RUSTFLAGS: ${{ matrix.rustflags }}
- name: Tests
run: cargo test --workspace --exclude scrypt-ocl
env:
RUSTFLAGS: ${{ matrix.rustflags }}
- name: Test scrypt-ocl crate
if: matrix.os != 'windows-2019'
run: cargo test -p scrypt-ocl -- --test-threads=1
env:
RUSTFLAGS: ${{ matrix.rustflags }}
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/[email protected]
with:
components: rustfmt
- uses: Swatinem/rust-cache@v2
- run: cargo fmt --all -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/rust-toolchain@master
with:
components: clippy
toolchain: stable
- 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: [self-hosted, linux, x64, intel]
steps:
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install opencl
run: sudo apt-get update && sudo apt-get install -y libpocl2 pocl-opencl-icd ocl-icd-opencl-dev
- uses: actions/checkout@v4
with:
submodules: true
- name: Install stable
uses: dtolnay/[email protected]
with:
components: llvm-tools-preview
- name: cargo install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: cargo llvm-cov
run: cargo llvm-cov --locked --lcov --output-path lcov.info --workspace --ignore-filename-regex "main.rs" -- --test-threads=1
- name: Upload to codecov.io
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
build:
name: Build library
runs-on: ${{ matrix.os }}
needs:
- test
- fmt
- clippy
strategy:
fail-fast: false
matrix:
include:
- os: [self-hosted, linux, x64, intel]
dylib: libpost.so
staticlib: libpost.a
artifact-name: linux
- os: ubuntu-latest-arm-8-cores
dylib: libpost.so
staticlib: libpost.a
rustflags: --cfg=aes_armv8
artifact-name: linux-arm64
- os: [self-hosted, macos, arm64]
dylib: libpost.dylib
staticlib: libpost.a
rustflags: --cfg=aes_armv8
artifact-name: macos-m1
- os: macos-13
dylib: libpost.dylib
staticlib: libpost.a
artifact-name: macos
- os: windows-2019
dylib: post.dll
staticlib: post.lib
artifact-name: windows
steps:
- if: matrix.os == 'ubuntu-latest-arm-8-cores'
run: sudo apt-get update && sudo apt-get install -y ocl-icd-opencl-dev
name: Install opencl
- if: matrix.os == 'windows-2019'
name: Install opencl
run: vcpkg install opencl
- uses: actions/checkout@v4
with:
submodules: true
- uses: dtolnay/[email protected]
- 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: Build clib
run: cargo build -p post-cbindings --profile release-clib
env:
RUSTFLAGS: ${{ matrix.rustflags }}
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: libpost-${{ matrix.artifact-name }}
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 }}
- name: Archive profiler artifacts
uses: actions/upload-artifact@v4
with:
name: profiler-${{ matrix.artifact-name }}
path: |
target/release/profiler${{ matrix.os == 'windows-2019' && '.exe' || '' }}
if-no-files-found: error
- uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build service
run: cargo build -p service --release
env:
RUSTFLAGS: ${{ matrix.rustflags }}
- name: Archive service artifacts
uses: actions/upload-artifact@v4
with:
name: post-service-${{ matrix.artifact-name }}
path: |
target/release/post-service${{ matrix.os == 'windows-2019' && '.exe' || '' }}
if-no-files-found: error
- name: Build k2pow service
run: cargo build -p k2pow-service --release
env:
RUSTFLAGS: ${{ matrix.rustflags }}
- name: Archive k2pow service artifacts
uses: actions/upload-artifact@v4
with:
name: k2pow-service-${{ matrix.artifact-name }}
path: |
target/release/k2pow-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@v4
- name: Download artifacts
uses: actions/download-artifact@v4
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 }}