Skip to content

Commit 6ffcd1e

Browse files
authored
Merge pull request #14 from gap-packages/ci-setup
Set up Travis CI and CodeCov integration
2 parents a04d0df + 6210f07 commit 6ffcd1e

File tree

7 files changed

+199
-0
lines changed

7 files changed

+199
-0
lines changed

.codecov.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
coverage:
2+
precision: 2
3+
round: down
4+
range: "70...100"
5+
6+
status:
7+
project: no
8+
patch: yes
9+
changes: no
10+
11+
comment:
12+
layout: "header, diff, changes, tree"
13+
behavior: default
14+
15+
ignore:
16+
- "PackageInfo.g"
17+
- "init.g"
18+
- "read.g"
19+
- "tst/*" # ignore test harness code
20+
- "tst/**/*" # ignore test harness code

.travis.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
language: c
2+
env:
3+
global:
4+
- GAPROOT=gaproot
5+
- COVDIR=coverage
6+
7+
addons:
8+
apt_packages:
9+
- libgmp-dev
10+
- libreadline-dev
11+
- libgmp-dev:i386
12+
- libreadline-dev:i386
13+
- gcc-multilib
14+
- g++-multilib
15+
16+
matrix:
17+
include:
18+
- env: CFLAGS="-O2" CC=clang CXX=clang++
19+
compiler: clang
20+
- env: CFLAGS="-O2"
21+
compiler: gcc
22+
- env: ABI=32
23+
24+
branches:
25+
only:
26+
- master
27+
28+
before_script:
29+
- export GAPROOT="$HOME/gap"
30+
- scripts/build_gap.sh
31+
script:
32+
- scripts/build_pkg.sh && scripts/run_tests.sh
33+
after_script:
34+
- bash scripts/gather-coverage.sh
35+
- bash <(curl -s https://codecov.io/bash)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Build Status](https://travis-ci.org/gap-packages/PatternClass.svg?branch=master)](https://travis-ci.org/gap-packages/PatternClass)
2+
[![Code Coverage](https://codecov.io/github/gap-packages/PatternClass/coverage.svg?branch=master&token=)](https://codecov.io/gh/gap-packages/PatternClass)
13

24
The 'PatternClass' GAP 4 package
35
================================

scripts/build_gap.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
#
3+
# DO NOT EDIT THIS FILE!
4+
#
5+
# If you have any questions about this script, or think it is not general
6+
# enough to cover your use case (i.e., you feel that you need to modify it
7+
# anyway), please contact Max Horn <[email protected]>.
8+
#
9+
set -ex
10+
11+
# clone GAP into a subdirectory
12+
git clone --depth=2 -b ${GAPBRANCH:-master} https://github.com/gap-system/gap.git $GAPROOT
13+
cd $GAPROOT
14+
15+
# for HPC-GAP, install ward, add suitable flags
16+
if [[ $HPCGAP = yes ]]; then
17+
git clone https://github.com/gap-system/ward
18+
cd ward
19+
CFLAGS= LDFLAGS= ./build.sh
20+
cd ..
21+
GAP_CONFIGFLAGS="$GAP_CONFIGFLAGS --enable-hpcgap"
22+
fi
23+
24+
# build GAP in a subdirectory
25+
./autogen.sh
26+
./configure $GAP_CONFIGFLAGS
27+
make -j4 V=1
28+
29+
# download packages; instruct wget to retry several times if the
30+
# connection is refused, to work around intermittent failures
31+
make bootstrap-pkg-full WGET="wget -N --no-check-certificate --tries=5 --waitretry=5 --retry-connrefused"
32+
33+
# build some packages; default is to build 'io' and 'profiling', in order to
34+
# generate coverage results. If you need to build additional packages (or for
35+
# some reason need to build a custom version of io or profiling), please set
36+
# the GAP_PKGS_TO_BUILD environment variable (e.g. in your .travis.yml), or
37+
# directly call BuildPackages.sh from .travis.yml. For an example of the
38+
# former, take a look at the cvec package.
39+
cd pkg
40+
for pkg in ${GAP_PKGS_TO_BUILD-io profiling}; do
41+
../bin/BuildPackages.sh --strict $pkg*
42+
done

scripts/build_pkg.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env bash
2+
#
3+
# DO NOT EDIT THIS FILE!
4+
#
5+
# If you have any questions about this script, or think it is not general
6+
# enough to cover your use case (i.e., you feel that you need to modify it
7+
# anyway), please contact Max Horn <[email protected]>.
8+
#
9+
set -ex
10+
11+
# ensure coverage is turned on
12+
export CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
13+
export LDFLAGS="$LDFLAGS -fprofile-arcs"
14+
15+
# adjust build flags for 32bit builds
16+
if [[ $ABI = 32 ]]; then
17+
export CFLAGS="$CFLAGS -m32"
18+
export LDFLAGS="$LDFLAGS -m32"
19+
fi
20+
21+
# build this package, if necessary
22+
if [[ -x autogen.sh ]]; then
23+
./autogen.sh
24+
./configure --with-gaproot=$GAPROOT
25+
make -j4 V=1
26+
elif [[ -x configure ]]; then
27+
./configure $GAPROOT
28+
make -j4
29+
fi
30+
31+
# set up a custom GAP root containing only this package, so that
32+
# we can force GAP to load the correct version of this package
33+
mkdir -p gaproot/pkg/
34+
ln -s $PWD gaproot/pkg/

scripts/gather-coverage.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
#
3+
# DO NOT EDIT THIS FILE!
4+
#
5+
# If you need to collect additional coverage data, please do so
6+
# from your .travis.yml or a custom script.
7+
#
8+
# If you have any questions about this script, or think it is not general
9+
# enough to cover your use case (i.e., you feel that you need to modify it
10+
# anyway), please contact Max Horn <[email protected]>.
11+
#
12+
set -ex
13+
14+
# If we don't care about code coverage, do nothing
15+
if [[ -n $NO_COVERAGE ]]; then
16+
exit 0
17+
fi
18+
19+
# start GAP with custom GAP root, to ensure correct package version is loaded
20+
GAP="$GAPROOT/bin/gap.sh -l $PWD/gaproot; --quitonbreak -q"
21+
22+
# generate library coverage reports
23+
$GAP -a 500M -m 500M -q <<GAPInput
24+
if LoadPackage("profiling") <> true then
25+
Print("ERROR: could not load profiling package");
26+
FORCE_QUIT_GAP(1);
27+
fi;
28+
d := Directory("$COVDIR");;
29+
covs := [];;
30+
for f in DirectoryContents(d) do
31+
if f in [".", ".."] then continue; fi;
32+
Add(covs, Filename(d, f));
33+
od;
34+
Print("Merging coverage results from ", covs, "\n");
35+
r := MergeLineByLineProfiles(covs);;
36+
Print("Outputting JSON\n");
37+
OutputJsonCoverage(r, "gap-coverage.json");;
38+
QUIT_GAP(0);
39+
GAPInput
40+
41+
# generate source coverage reports by running gcov
42+
gcov -o . src/*.c*

scripts/run_tests.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
#
3+
# DO NOT EDIT THIS FILE!
4+
#
5+
# If you need to run additional setup steps before the package tests,
6+
# edit the run script in .travis.yml instead
7+
#
8+
# If you have any questions about this script, or think it is not general
9+
# enough to cover your use case (i.e., you feel that you need to modify it
10+
# anyway), please contact Max Horn <[email protected]>.
11+
#
12+
set -ex
13+
14+
# start GAP with custom GAP root, to ensure correct package version is loaded
15+
GAP="$GAPROOT/bin/gap.sh -l $PWD/gaproot; --quitonbreak"
16+
17+
# Unless explicitly turned off by setting the NO_COVERAGE environment variable,
18+
# we collect coverage data
19+
if [[ -z $NO_COVERAGE ]]; then
20+
mkdir $COVDIR
21+
GAP="$GAP --cover $COVDIR/test.coverage"
22+
fi
23+
24+
$GAP tst/testall.g

0 commit comments

Comments
 (0)