Skip to content

Commit 8c02e46

Browse files
committedJan 29, 2021
ci: Add support for Cirrus CI
1 parent f2d9aea commit 8c02e46

9 files changed

+293
-1
lines changed
 

‎.cirrus.yml

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
env:
2+
WIDEMUL: auto
3+
BIGNUM: auto
4+
STATICPRECOMPUTATION: yes
5+
ECMULTGENPRECISION: auto
6+
ASM: no
7+
BUILD: check
8+
WITH_VALGRIND: yes
9+
RUN_VALGRIND: no
10+
EXTRAFLAGS:
11+
HOST:
12+
ECDH: no
13+
RECOVERY: no
14+
SCHNORRSIG: no
15+
EXPERIMENTAL: no
16+
CTIMETEST: yes
17+
BENCH: yes
18+
ITERS: 2
19+
# We only need the top commit
20+
CIRRUS_CLONE_DEPTH: 1
21+
22+
cat_logs_snippet: &CAT_LOGS
23+
always:
24+
test_logs_script:
25+
- cat tests.log || true
26+
- cat exhaustive_tests.log || true
27+
- cat valgrind_ctime_test.log || true
28+
- cat bench.log || true
29+
on_failure:
30+
debug_output_script:
31+
- cat config.log || true
32+
- cat test_env.log || true
33+
- env
34+
35+
task:
36+
name: "x86_64: Linux (Alpine Linux, Nix Shell)"
37+
container:
38+
dockerfile: ci/linux-nixos.Dockerfile
39+
# Reduce number of CPUs to be able to do more builds in parallel.
40+
cpu: 1
41+
# More than enough for our scripts.
42+
memory: 1G
43+
matrix: &ENV_MATRIX
44+
- env: {WIDEMUL: int64, RECOVERY: yes}
45+
- env: {WIDEMUL: int64, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
46+
- env: {WIDEMUL: int128}
47+
- env: {WIDEMUL: int128, RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
48+
- env: {WIDEMUL: int128, ECDH: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
49+
- env: {WIDEMUL: int128, ASM: x86_64}
50+
- env: {BIGNUM: no}
51+
- env: {BIGNUM: no, RECOVERY: yes, EXPERIMENTAL: yes, SCHNORRSIG: yes}
52+
- env: {BIGNUM: no, STATICPRECOMPUTATION: no}
53+
- env: {BUILD: distcheck, WITH_VALGRIND: no, CTIMETEST: no, BENCH: no}
54+
- env: {CPPFLAGS: -DDETERMINISTIC}
55+
- env: {CFLAGS: -O0, CTIMETEST: no}
56+
- env:
57+
CFLAGS: "-fsanitize=undefined -fno-omit-frame-pointer"
58+
LDFLAGS: "-fsanitize=undefined -fno-omit-frame-pointer"
59+
UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1"
60+
BIGNUM: no
61+
ASM: x86_64
62+
ECDH: yes
63+
RECOVERY: yes
64+
EXPERIMENTAL: yes
65+
SCHNORRSIG: yes
66+
CTIMETEST: no
67+
- env: { ECMULTGENPRECISION: 2 }
68+
- env: { ECMULTGENPRECISION: 8 }
69+
- env:
70+
RUN_VALGRIND: yes
71+
BIGNUM: no
72+
ASM: x86_64
73+
ECDH: yes
74+
RECOVERY: yes
75+
EXPERIMENTAL: yes
76+
SCHNORRSIG: yes
77+
EXTRAFLAGS: "--disable-openssl-tests"
78+
BUILD:
79+
matrix:
80+
- env:
81+
CC: gcc
82+
- env:
83+
CC: clang
84+
test_script:
85+
- nix-shell ci/shell.nix --run ./ci/cirrus.sh
86+
<< : *CAT_LOGS
87+
88+
task:
89+
name: "i686: Linux (Alpine Linux, Nix Shell)"
90+
container:
91+
dockerfile: ci/linux-nixos.Dockerfile
92+
cpu: 1
93+
memory: 1G
94+
env:
95+
HOST: i686-linux-gnu
96+
ECDH: yes
97+
RECOVERY: yes
98+
EXPERIMENTAL: yes
99+
SCHNORRSIG: yes
100+
matrix:
101+
- env:
102+
CC: gcc
103+
- env:
104+
CC: clang
105+
matrix:
106+
- env:
107+
BIGNUM: gmp
108+
- env:
109+
BIGNUM: no
110+
test_script:
111+
- nix-shell ci/shell-i686.nix --run ./ci/cirrus.sh
112+
<< : *CAT_LOGS
113+
114+
task:
115+
name: "x86_64: macOS Catalina"
116+
macos_instance:
117+
image: catalina-base
118+
matrix:
119+
<< : *ENV_MATRIX
120+
matrix:
121+
- env:
122+
CC: gcc-9
123+
- env:
124+
CC: clang
125+
# Update Command Line Tools
126+
# Uncomment this if the Command Line Tools on the CirrusCI macOS image are too old to brew valgrind.
127+
# See https://apple.stackexchange.com/a/195963 for the implementation.
128+
## update_clt_script:
129+
## - system_profiler SPSoftwareDataType
130+
## - touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
131+
## - |-
132+
## PROD=$(softwareupdate -l | grep "*.*Command Line" | tail -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | sed 's/Label: //g' | tr -d '\n')
133+
## # For debugging
134+
## - softwareupdate -l && echo "PROD: $PROD"
135+
## - softwareupdate -i "$PROD" --verbose
136+
## - rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
137+
##
138+
brew_script:
139+
# TODO cache the binaries
140+
- export HOMEBREW_NO_AUTO_UPDATE=1
141+
- export HOMEBREW_NO_INSTALL_CLEANUP=1
142+
- brew config
143+
- brew tap --shallow LouisBrunner/valgrind
144+
- brew install --HEAD LouisBrunner/valgrind/valgrind
145+
- brew install automake libtool gmp gcc@9
146+
test_script:
147+
- ./ci/cirrus.sh
148+
<< : *CAT_LOGS
149+
150+
task:
151+
name: "s390x (big-endian): Linux (Debian QEMU)"
152+
container:
153+
dockerfile: ci/linux-debian-s390-qemu.Dockerfile
154+
cpu: 1
155+
memory: 1G
156+
env:
157+
QEMU_CMD: qemu-s390x
158+
HOST: s390x-linux-gnu
159+
BUILD:
160+
WITH_VALGRIND: no
161+
BIGNUM: no
162+
ECDH: yes
163+
RECOVERY: yes
164+
EXPERIMENTAL: yes
165+
SCHNORRSIG: yes
166+
CTIMETEST: no
167+
test_script:
168+
# https://sourceware.org/bugzilla/show_bug.cgi?id=27008
169+
- rm /etc/ld.so.cache
170+
- ./ci/cirrus.sh
171+
<< : *CAT_LOGS

‎.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ before_script: ./autogen.sh
9797
script:
9898
- function keep_alive() { while true; do echo -en "\a"; sleep 60; done }
9999
- keep_alive &
100-
- ./contrib/travis.sh
100+
- ./ci/travis.sh
101101
- kill %keep_alive
102102

103103
after_script:

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ libsecp256k1
22
============
33

44
[![Build Status](https://travis-ci.org/bitcoin-core/secp256k1.svg?branch=master)](https://travis-ci.org/bitcoin-core/secp256k1)
5+
[![Build Status](https://api.cirrus-ci.com/github/bitcoin-core/secp256k1.svg?branch=master)](https://cirrus-ci.com/github/bitcoin-core/secp256k1)
56

67
Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1.
78

‎ci/cirrus.sh

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/sh
2+
3+
set -e
4+
set -x
5+
6+
export LC_ALL=C
7+
8+
env >> test_env.log
9+
10+
$CC -v || true
11+
valgrind --version || true
12+
13+
./autogen.sh
14+
15+
# Nix doesn't store GNU file in /usr/bin, see https://lists.gnu.org/archive/html/bug-libtool/2015-09/msg00000.html .
16+
# The -i'' is necessary for macOS portability, see https://stackoverflow.com/a/4247319 .
17+
sed -i'' -e 's@/usr/bin/file@$(which file)@g' configure
18+
19+
./configure \
20+
--enable-experimental="$EXPERIMENTAL" \
21+
--with-test-override-wide-multiply="$WIDEMUL" --with-bignum="$BIGNUM" --with-asm="$ASM" \
22+
--enable-ecmult-static-precomputation="$STATICPRECOMPUTATION" --with-ecmult-gen-precision="$ECMULTGENPRECISION" \
23+
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
24+
--enable-module-schnorrsig="$SCHNORRSIG" \
25+
--with-valgrind="$WITH_VALGRIND" \
26+
--host="$HOST" $EXTRAFLAGS
27+
28+
if [ -n "$BUILD" ]
29+
then
30+
make -j2 "$BUILD"
31+
fi
32+
33+
if [ "$RUN_VALGRIND" = "yes" ]
34+
then
35+
make -j2
36+
# the `--error-exitcode` is required to make the test fail if valgrind found errors, otherwise it'll return 0 (https://www.valgrind.org/docs/manual/manual-core.html)
37+
valgrind --error-exitcode=42 ./tests 16
38+
valgrind --error-exitcode=42 ./exhaustive_tests
39+
fi
40+
41+
if [ -n "$QEMU_CMD" ]
42+
then
43+
make -j2
44+
$QEMU_CMD ./tests 16
45+
$QEMU_CMD ./exhaustive_tests
46+
fi
47+
48+
if [ "$BENCH" = "yes" ]
49+
then
50+
# Using the local `libtool` because on macOS the system's libtool has nothing to do with GNU libtool
51+
EXEC='./libtool --mode=execute'
52+
if [ -n "$QEMU_CMD" ]
53+
then
54+
EXEC="$EXEC $QEMU_CMD"
55+
fi
56+
if [ "$RUN_VALGRIND" = "yes" ]
57+
then
58+
EXEC="$EXEC valgrind --error-exitcode=42"
59+
fi
60+
# This limits the iterations in the benchmarks below to ITER iterations.
61+
export SECP256K1_BENCH_ITERS="$ITERS"
62+
{
63+
$EXEC ./bench_ecmult
64+
$EXEC ./bench_internal
65+
$EXEC ./bench_sign
66+
$EXEC ./bench_verify
67+
} >> bench.log 2>&1
68+
if [ "$RECOVERY" = "yes" ]
69+
then
70+
$EXEC ./bench_recover >> bench.log 2>&1
71+
fi
72+
if [ "$ECDH" = "yes" ]
73+
then
74+
$EXEC ./bench_ecdh >> bench.log 2>&1
75+
fi
76+
if [ "$SCHNORRSIG" = "yes" ]
77+
then
78+
$EXEC ./bench_schnorrsig >> bench.log 2>&1
79+
fi
80+
fi
81+
if [ "$CTIMETEST" = "yes" ]
82+
then
83+
./libtool --mode=execute valgrind --error-exitcode=42 ./valgrind_ctime_test > valgrind_ctime_test.log 2>&1
84+
fi

‎ci/linux-debian-s390-qemu.Dockerfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM debian
2+
3+
RUN dpkg --add-architecture s390x
4+
RUN apt-get update
5+
RUN apt-get install --no-install-recommends --no-upgrade -y make automake libtool
6+
RUN apt-get install --no-install-recommends --no-upgrade -y gcc-s390x-linux-gnu libc6-dev-s390x-cross qemu-user libc6:s390x

‎ci/linux-nixos.Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM nixos/nix
2+
3+
COPY ci/shell.nix /tmp
4+
COPY ci/shell-i686.nix /tmp
5+
6+
RUN nix-channel --remove nixpkgs
7+
RUN nix-channel --add https://nixos.org/channels/nixos-20.09 nixpkgs
8+
RUN nix-channel --update
9+
10+
# Run dummy command "true" in the nix-shell just to get the packages prepared.
11+
RUN nix-shell /tmp/shell.nix --command true
12+
RUN nix-shell /tmp/shell-i686.nix --command true

‎ci/shell-i686.nix

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
with (import <nixpkgs> {}).pkgsi686Linux;
2+
mkShell {
3+
buildInputs = [
4+
bash file pkgconfig autoconf automake libtool gmp valgrind clang gcc
5+
];
6+
shellHook = ''
7+
echo Running nix-shell with nixpkgs version: $(nix eval --raw nixpkgs.lib.version)
8+
'';
9+
}

‎ci/shell.nix

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
with (import <nixpkgs> {});
2+
mkShell {
3+
buildInputs = [
4+
bash file pkgconfig autoconf automake libtool gmp valgrind clang gcc
5+
];
6+
shellHook = ''
7+
echo Running nix-shell with nixpkgs version: $(nix eval --raw nixpkgs.lib.version)
8+
'';
9+
}

‎contrib/travis.sh ‎ci/travis.sh

File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.