Skip to content

Commit a1baa97

Browse files
authored
Merge pull request #573 from libtom/port-from-develop
Port CI and CMake support from develop
2 parents ce591b5 + c81d069 commit a1baa97

File tree

9 files changed

+973
-93
lines changed

9 files changed

+973
-93
lines changed

.github/workflows/deploy.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#############################################################################
2+
# #
3+
# Packagecloud deployment via GH actions for LibTomMath #
4+
# (https://github.com/libtom/libtommath.git) #
5+
# #
6+
#############################################################################
7+
8+
name: Deploy
9+
10+
on:
11+
workflow_dispatch
12+
13+
jobs:
14+
deploy-to-packagecloud:
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
matrix:
18+
os: [ ubuntu-20.04, ubuntu-22.04 ]
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: set Ubuntu codename
22+
run: |
23+
echo "ubuntu_codename="$(lsb_release -sc) >> "$GITHUB_ENV"
24+
- name: install dependencies
25+
run: |
26+
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
27+
echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ ${{ env.ubuntu_codename }} main" | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
28+
sudo apt-get update -qq
29+
sudo apt-get install -y cmake gcc
30+
- name: build packages
31+
run: |
32+
mkdir -p build
33+
cd build
34+
cmake -DBUILD_SHARED_LIBS=Off -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="/usr" ..
35+
make -j$(nproc)
36+
cpack -G DEB
37+
cmake -DBUILD_SHARED_LIBS=On -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="/usr" ..
38+
make -j$(nproc)
39+
cpack -G DEB
40+
- name: push deb packages to packagecloud.io
41+
uses: computology/packagecloud-github-action@v0.6
42+
with:
43+
PACKAGE-NAME: build/packages/ubuntu/${{ env.ubuntu_codename }}/*.deb
44+
PACKAGECLOUD-USERNAME: libtom
45+
PACKAGECLOUD-REPONAME: packages
46+
PACKAGECLOUD-DISTRO: ubuntu/${{ env.ubuntu_codename }}
47+
PACKAGECLOUD-TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}

.github/workflows/main.yml

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
#############################################################################
2+
# #
3+
# GitHub Actions test-suite for LibTomMath #
4+
# (https://github.com/libtom/libtommath.git) #
5+
# #
6+
#############################################################################
7+
8+
name: CI
9+
10+
# Tests restricted to the following branches of LTM.
11+
on:
12+
push:
13+
branches:
14+
- master
15+
- develop
16+
- /^release\/.*$/
17+
- /^support\/.*$/
18+
- /^ci\/.*$/
19+
pull_request:
20+
branches:
21+
- master
22+
- develop
23+
- /^release\/.*$/
24+
- /^support\/.*$/
25+
- /^ci\/.*$/
26+
27+
jobs:
28+
Docs:
29+
runs-on: ubuntu-20.04
30+
container: texlive/texlive:latest-full
31+
steps:
32+
- uses: actions/checkout@v3
33+
- name: generate PDF
34+
run: |
35+
make docs V=1
36+
cp doc/bn.pdf bn-${{ github.run_id }}.pdf
37+
- name: upload PDF
38+
uses: actions/upload-artifact@v3
39+
with:
40+
name: bn-${{ github.run_id }}.pdf
41+
path: bn-${{ github.run_id }}.pdf
42+
Testme:
43+
runs-on: ${{ matrix.os }}
44+
strategy:
45+
matrix:
46+
os: [ ubuntu-20.04 ]
47+
# The environment given to the programs in the build
48+
# We have only one program and the variable $BUILDOPTIONS
49+
# has only the options to that program: testme.sh
50+
51+
config:
52+
# Check source code format
53+
- { BUILDOPTIONS: '--format', SANITIZER: '', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'astyle' }
54+
# Run always with valgrind (no sanitizer, but debug info)
55+
- { BUILDOPTIONS: '--with-cc=gcc --with-m64 --with-valgrind', SANITIZER: '', COMPILE_DEBUG: '1', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: '' }
56+
# Alternative big-int version of mp_log(_n)
57+
- { BUILDOPTIONS: '--with-cc=gcc --with-m64 --cflags=-DS_MP_WORD_TOO_SMALL_C="" --with-valgrind', SANITIZER: '', COMPILE_DEBUG: '1', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: '' }
58+
# Shared library build
59+
- { BUILDOPTIONS: '--with-cc=gcc --make-option=-f --make-option=makefile.shared', SANITIZER: '', COMPILE_DEBUG: '0', COMPILE_LTO: '1', CONV_WARNINGS: '', OTHERDEPS: 'libtool-bin' }
60+
# GCC for the 32-bit architecture (no valgrind)
61+
- { BUILDOPTIONS: '--with-cc=gcc --with-m32', SANITIZER: '', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'libc6-dev-i386 gcc-multilib' }
62+
# Alternative big-int version of mp_log(_n) for the 32-bit architecture (no valgrind)
63+
- { BUILDOPTIONS: '--with-cc=gcc --with-m32 --cflags=-DS_MP_WORD_TOO_SMALL_C="" ', SANITIZER: '', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'libc6-dev-i386 gcc-multilib' }
64+
# clang for the 32-bit architecture (no valgrind)
65+
- { BUILDOPTIONS: '--with-cc=clang-10 --with-m32', SANITIZER: '', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-10 llvm-10 gcc-multilib' }
66+
# RSA superclass with tests (no sanitizer, but debug info)
67+
- { BUILDOPTIONS: '--with-cc=gcc --with-m64 --cflags=-DLTM_NOTHING --cflags=-DSC_RSA_1_WITH_TESTS --limit-valgrind', SANITIZER: '', COMPILE_DEBUG: '1', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: '' }
68+
69+
# Test "autotuning", the automatic evaluation and setting of the Toom-Cook cut-offs.
70+
#- env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_16BIT --limit-valgrind --make-option=tune'
71+
#- env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --cflags=-DMP_32BIT --limit-valgrind --make-option=tune'
72+
#- env: SANITIZER=1 BUILDOPTIONS='--with-cc=gcc-5 --limit-valgrind --make-option=tune'
73+
#- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_16BIT --limit-valgrind --make-option=tune'
74+
#- env: SANITIZER=1 BUILDOPTIONS='--with-cc=clang-7 --cflags=-DMP_32BIT --limit-valgrind --make-option=tune'
75+
- { BUILDOPTIONS: '--with-cc=clang-10 --limit-valgrind --make-option=tune', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-10 llvm-10' }
76+
77+
# GCC for the x86-64 architecture testing against a different Bigint-implementation
78+
# with 333333 different inputs.
79+
#- env: BUILDOPTIONS='--with-cc=gcc --test-vs-mtest=333333 --limit-valgrind'
80+
# ... and a better random source.
81+
- { BUILDOPTIONS: '--with-cc=gcc --test-vs-mtest=333333 --mtest-real-rand --limit-valgrind', SANITIZER: '', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: '' }
82+
83+
# clang for the x86-64 architecture testing against a different Bigint-implementation
84+
# with 333333 different inputs
85+
- { BUILDOPTIONS: '--with-cc=clang-10 --test-vs-mtest=333333 --limit-valgrind', SANITIZER: '', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-10 llvm-10' }
86+
# ... and a better random source.
87+
- { BUILDOPTIONS: '--with-cc=clang-10 --test-vs-mtest=333333 --mtest-real-rand --limit-valgrind', SANITIZER: '', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-10 llvm-10' }
88+
89+
# GCC for the x64_32 architecture (32-bit longs and 32-bit pointers)
90+
# TODO: Probably not possible to run anything in x32 in GH actions
91+
# but needs to be checked to be sure.
92+
- { BUILDOPTIONS: '--with-cc=gcc --with-mx32', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'libc6-dev-x32 gcc-multilib' }
93+
94+
# GCC for the x86-64 architecture (64-bit longs and 64-bit pointers)
95+
- { BUILDOPTIONS: '--with-cc=gcc --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: '' }
96+
- { BUILDOPTIONS: '--with-cc=gcc-10 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'gcc-10' }
97+
- { BUILDOPTIONS: '--with-cc=gcc-8 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'gcc-8' }
98+
- { BUILDOPTIONS: '--with-cc=gcc-7 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'gcc-7' }
99+
100+
# clang for x86-64 architecture (64-bit longs and 64-bit pointers)
101+
- { BUILDOPTIONS: '--with-cc=clang-10 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: 'relaxed', OTHERDEPS: 'clang-10 llvm-10' }
102+
- { BUILDOPTIONS: '--with-cc=clang-10 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: 'strict', OTHERDEPS: 'clang-10 llvm-10' }
103+
- { BUILDOPTIONS: '--with-cc=clang-10 --cflags=-DMP_USE_MEMOPS --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: 'strict', OTHERDEPS: 'clang-10 llvm-10' }
104+
- { BUILDOPTIONS: '--with-cc=clang-10 --with-m64 --limit-valgrind --cflags=-DMP_PREC=MP_MIN_PREC', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-10 llvm-10' }
105+
- { BUILDOPTIONS: '--with-cc=clang-12 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-12 llvm-12' }
106+
- { BUILDOPTIONS: '--with-cc=clang-9 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-9 llvm-9' }
107+
- { BUILDOPTIONS: '--with-cc=clang-8 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-8 llvm-8' }
108+
- { BUILDOPTIONS: '--with-cc=clang-7 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-7 llvm-7' }
109+
- { BUILDOPTIONS: '--with-cc=clang-6.0 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang-6.0 llvm-6.0' }
110+
# Link time optimization
111+
- { BUILDOPTIONS: '--with-cc=gcc --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '1', CONV_WARNINGS: '', OTHERDEPS: '' }
112+
#- { BUILDOPTIONS: '--with-cc=clang-7 --with-m64 --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '1', CONV_WARNINGS: '', OTHERDEPS: '' }
113+
114+
# GCC for the x86-64 architecture with restricted limb sizes
115+
# formerly started with the option "--with-low-mp" to testme.sh
116+
# but testing all three in one run took to long and timed out.
117+
- { BUILDOPTIONS: '--with-cc=gcc --cflags=-DMP_16BIT --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: '' }
118+
- { BUILDOPTIONS: '--with-cc=gcc --cflags=-DMP_32BIT --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: '' }
119+
# Alternative big-int version of mp_log(_n)
120+
- { BUILDOPTIONS: '--with-cc=gcc --cflags=-DMP_16BIT --cflags=-DS_MP_WORD_TOO_SMALL_C="" --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: '' }
121+
- { BUILDOPTIONS: '--with-cc=gcc --cflags=-DMP_32BIT --cflags=-DS_MP_WORD_TOO_SMALL_C="" --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: '' }
122+
123+
# clang for the x86-64 architecture with restricted limb sizes
124+
- { BUILDOPTIONS: '--with-cc=clang --cflags=-DMP_16BIT --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang llvm' }
125+
- { BUILDOPTIONS: '--with-cc=clang --cflags=-DMP_32BIT --limit-valgrind', SANITIZER: '1', COMPILE_DEBUG: '0', COMPILE_LTO: '0', CONV_WARNINGS: '', OTHERDEPS: 'clang llvm' }
126+
steps:
127+
- uses: actions/checkout@v3
128+
- name: install dependencies
129+
run: |
130+
sudo apt-get update -qq
131+
sudo apt-get install -y valgrind ${{ matrix.config.OTHERDEPS }}
132+
sudo apt-cache search gcc | grep '^gcc-[0-9\.]* '
133+
sudo apt-cache search clang | grep compiler
134+
- name: run tests
135+
env:
136+
SANITIZER: ${{ matrix.config.SANITIZER }}
137+
COMPILE_DEBUG: ${{ matrix.config.COMPILE_DEBUG }}
138+
COMPILE_LTO: ${{ matrix.config.COMPILE_LTO }}
139+
CONV_WARNINGS: ${{ matrix.config.CONV_WARNINGS }}
140+
COMMIT_MESSAGE: ${{ github.event.commits[0].message }}
141+
PR_NUMBER: ${{ github.event.number }}
142+
# The actual script the jobs run.
143+
run: |
144+
./testme.sh ${{ matrix.config.BUILDOPTIONS }}
145+
# In case of a CI error a success might get signaled
146+
# even without any test run. This file also keeps any notes
147+
# printed from the tests which might come handy from time
148+
# to time.
149+
# Valgrid will print its output to stderr which will not show up
150+
# in test_*.log. testme.sh accepts one additional option to
151+
# valgrind and "--valgrind-options=--log-fd=1" sends the output
152+
# of Valgrind to stdout instead.
153+
- name: regular logs
154+
if: ${{ !failure() }}
155+
run: |
156+
cat test_*.log || true
157+
# Compilation failures are in gcc_errors_*.log
158+
# Failed tests in test_*.log
159+
# Files do not exist in case of success
160+
- name: error logs
161+
if: ${{ failure() }}
162+
run: |
163+
cat test_*.log || true
164+
cat valgrind_test.log || true
165+
cat gcc_errors_*.log || true
166+
167+
CMake:
168+
runs-on: ${{ matrix.os }}
169+
strategy:
170+
matrix:
171+
os: [ ubuntu-20.04, ubuntu-22.04 ]
172+
build_type: [ '', -DCMAKE_BUILD_TYPE=Debug, -DCMAKE_BUILD_TYPE=Release, -DCMAKE_BUILD_TYPE=RelWithDebInfo, -DCMAKE_BUILD_TYPE=MinSizeRel ]
173+
cc: [ clang, gcc ]
174+
config:
175+
# Static library build
176+
- { CMAKEOPTIONS: '-DBUILD_SHARED_LIBS=Off' }
177+
# Shared library build
178+
- { CMAKEOPTIONS: '-DBUILD_SHARED_LIBS=On' }
179+
steps:
180+
- uses: actions/checkout@v3
181+
- name: install dependencies
182+
run: |
183+
sudo apt-get update -qq
184+
sudo apt-get install -y cmake gcc clang llvm
185+
- name: build
186+
run: |
187+
mkdir build
188+
cd build
189+
CC=${{ matrix.cc }} cmake ${{ matrix.config.CMAKEOPTIONS }} ${{ matrix.build_type }} ..
190+
make -j$(nproc)
191+
- name: test
192+
run: |
193+
cd build
194+
CC=${{ matrix.cc }} cmake ${{ matrix.config.CMAKEOPTIONS }} ${{ matrix.build_type }} -DBUILD_TESTING=On ..
195+
make -j$(nproc)
196+
ctest
197+
- name: test (in demo folder)
198+
run: |
199+
mkdir -p demo/build
200+
cd demo/build
201+
CC=${{ matrix.cc }} cmake ${{ matrix.config.CMAKEOPTIONS }} ${{ matrix.build_type }} ..
202+
make -j$(nproc)
203+
ctest

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,7 @@ test_*.txt
9696
doc/pics/*.ps
9797

9898
callgraph.txt
99+
100+
# cmake build directories
101+
build*/
102+

0 commit comments

Comments
 (0)