-
Notifications
You must be signed in to change notification settings - Fork 180
259 lines (235 loc) · 8.16 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
name: build
on:
push:
branches:
- '**'
workflow_dispatch:
branches:
- '**'
pull_request:
branches:
- master
jobs:
rust-n-go:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v3
- name: Get date
id: get-date
run: echo "date=$(date -u +%Y-%m)" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/cache@v3
with:
path: |
~/.cargo/registry
**/Cargo.lock
**/bindings/rust/target
key: ${{ runner.os }}-cargo-${{ steps.get-date.outputs.date }}
- name: Environment
shell: bash
run: |
lscpu 2>/dev/null && echo --- || true
sysctl hw 2>/dev/null && echo --- || true
env | sort
- name: Rust
shell: bash
run: |
rustc --version --verbose
export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse
cd bindings/rust
sed "s/^crit/#crit/" Cargo.toml > Cargo.$$.toml && \
mv Cargo.$$.toml Cargo.toml
if [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then
cargo update
fi
cargo test --release
echo '--- test portable'
echo
cargo test --release --features=portable
echo '--- test no-threads'
echo
cargo test --release --features=no-threads
echo '--- test serde-secret'
echo
cargo test --release --features=serde-secret
echo '--- test no_std'
echo
echo 'set -e' > ulimit-s
echo 'export RUST_MIN_STACK=$(($1 * 1024)); shift' >> ulimit-s
echo 'exec "$@"' >> ulimit-s
triplet=`rustc -vV | awk '/host:/ {print $2}' | tr 'a-z-' 'A-Z_'`
stack_size=`[ $OSTYPE = "msys" ] && echo 65 || echo 56`
env BLST_TEST_NO_STD= \
CARGO_TARGET_${triplet}_RUNNER="bash ulimit-s $stack_size" \
cargo test --release
if [ `uname -s` = "Linux" ]; then
echo '--- test wasm32-wasi'
echo
rustup target add wasm32-wasi
curl https://wasmtime.dev/install.sh -sSf | bash
env PATH=$PATH:~/.wasmtime/bin:`clang -print-search-dirs | awk -F= '/^programs:/{print$2}'` \
AR=llvm-ar CARGO_TARGET_WASM32_WASI_RUNNER=wasmtime \
cargo test --release --target=wasm32-wasi
cargo clean -p blst --release --target=wasm32-wasi
echo '--- test -mlvi-hardening'
echo
env CC=clang CFLAGS="-mlvi-hardening -D__SGX_LVI_HARDENING__" \
cargo test --release
echo '--- build x86_64-fortanix-unknown-sgx'
echo
rustup target add x86_64-fortanix-unknown-sgx
cargo test --release --target=x86_64-fortanix-unknown-sgx --no-run
cargo clean -p blst --release --target=x86_64-fortanix-unknown-sgx
echo '--- dry-run publish'
echo
./publish.sh --dry-run
elif [ `uname -s` = "Darwin" ]; then
echo '--- build aarch64-apple-darwin'
echo
rustup target add aarch64-apple-darwin
cargo test --release --target=aarch64-apple-darwin --no-run
cargo clean -p blst --release --target=aarch64-apple-darwin
elif [ $OSTYPE = "msys" ]; then
echo '-- test x86_64-pc-windows-gnu'
echo
rustup target add x86_64-pc-windows-gnu
cargo test --release --target=x86_64-pc-windows-gnu
cargo clean -p blst --release --target=x86_64-pc-windows-gnu
echo '-- build aarch64-pc-windows-msvc'
echo
rustup target add aarch64-pc-windows-msvc
mkdir .cargo
echo '[patch.crates-io]' > .cargo/config.toml
echo 'cc = { git = "https://github.com/rust-lang/cc-rs" }' >> .cargo/config.toml
cargo test --release --target=aarch64-pc-windows-msvc --no-run
find target/aarch64-pc-windows-msvc -name blst-\*.exe -exec cp {} blst-arm-test.exe \; -quit
cargo clean -p blst --release --target=aarch64-pc-windows-msvc
fi
echo
echo '--- cargo clippy'
echo
cargo clippy --release
cargo clean -p blst
cargo clean -p blst --release
rm -rf target/.rustc_info.json
rm -rf target/package
rm -rf target/{debug,release}/incremental
rm -rf target/*/{debug,release}/incremental
rm -rf ~/.cargo/registry/src
rm -rf ~/.cargo/registry/index/*/.cache
- name: Go
shell: bash
run: |
go version
if ! (grep -q -e '^flags.*\badx\b' /proc/cpuinfo) 2>/dev/null; then
export CGO_CFLAGS="-O -D__BLST_PORTABLE__"
fi
cd bindings/go
go test -test.v
- uses: actions/upload-artifact@v3
if: ${{ runner.os == 'Windows' }}
with:
name: blst-arm-test.exe
path: bindings/rust/blst-arm-test.exe
if-no-files-found: ignore
cargo-test-windows-on-arm:
runs-on: ubuntu-latest
needs: rust-n-go
steps:
- uses: actions/download-artifact@v3
with:
name: blst-arm-test.exe
- name: wine-arm64
uses: addnab/docker-run-action@v3
with:
registry: https://index.docker.io/v1/
image: linaro/wine-arm64
options: --volume ${{ github.workspace }}:/blst --network=none
run: wine-arm64 cmd /c "cd \ && \blst\blst-arm-test.exe"
misc-ubuntu-latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/swig
key: ${{ runner.os }}-swig-github
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 11
- uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Environment
run: |
lscpu
echo ---
env | sort
- name: Python
run: if [ -x bindings/python/run.me ]; then bindings/python/run.me; fi
- name: Java
run: if [ -x bindings/java/run.me ]; then bindings/java/run.me; fi
- name: Node.js
run: |
node_js=bindings/node.js
if [ -x $node_js/run.me ]; then
if [ ! -x ~/swig/bin/swig ]; then
( git clone https://github.com/swig/swig;
cd swig;
./autogen.sh;
./configure --prefix=$HOME/swig;
make;
make install;
(cd ~/swig/share/swig && ln -s `ls` current)
)
fi
env PATH=~/swig/bin:$PATH SWIG_LIB=~/swig/share/swig/current \
$node_js/run.me
fi
- name: node-gyp
run: |
node_js=bindings/node.js
if [ -f $node_js/binding.gyp -a -f $node_js/blst_wrap.cpp ]; then
npm install --global node-gyp || true
if which node-gyp > /dev/null 2>&1; then
( export PATH=~/swig/bin:$PATH SWIG_LIB=~/swig/share/swig/current;
cd $node_js;
node-gyp configure;
node-gyp build;
env NODE_PATH=build/Release: node runnable.js;
)
fi
fi
- name: TypeScript
run: |
node_js=bindings/node.js
if [ -f $node_js/blst.hpp.ts -a -f $node_js/blst.node ]; then
npm install --global typescript || true
if which tsc > /dev/null 2>&1; then
( cd $node_js;
npm install @types/node
tsc runnable.ts;
env NODE_PATH=.: node runnable.js;
)
fi
fi
- name: Emscripten
uses: addnab/docker-run-action@v3
with:
registry: https://index.docker.io/v1/
image: emscripten/emsdk
options: --volume ${{ github.workspace }}:/blst --network=none
run: git clone -q /blst /tmp/blst && /tmp/blst/bindings/emscripten/run.me -O2
- name: C#
run: |
if [ -x bindings/c#/run.me ]; then
bindings/c#/run.me;
if which dotnet > /dev/null 2>&1; then
cd bindings/c#
dotnet run -c Release
fi
fi