Skip to content

Commit a111150

Browse files
Merge pull request #1 from zemanlx/feature/optimise-travis-run
Feature/optimise travis run
2 parents 81df108 + 1c42d9f commit a111150

File tree

2 files changed

+71
-48
lines changed

2 files changed

+71
-48
lines changed

.travis.yml

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ jobs:
99
# CPP linter script
1010
- &linter-stage
1111
stage: test ubuntu + gcc compilation with extra flags for debug + Linter
12-
env:
13-
- NAME="CPP-LINT"
14-
- BUILD_PURPOSE="lint"
1512
addons:
1613
apt:
1714
packages:
1815
- libwww-perl
1916
script:
20-
- cp -r lib/cbmc/scripts . && scripts/travis_lint.sh
17+
- cp -r lib/cbmc/scripts .
18+
&& sed -i '/git fetch --unshallow/d' scripts/travis_lint.sh
19+
&& scripts/travis_lint.sh
2120
before_cache:
21+
env:
22+
- BUILD_PURPOSE="lint"
2223

2324
# Test - Ubuntu Linux with glibc using g++-5
2425
- stage: test ubuntu + gcc compilation with extra flags for debug + Linter
@@ -33,16 +34,12 @@ jobs:
3334
- ubuntu-toolchain-r-test
3435
packages:
3536
- libwww-perl
36-
- libthread-pool-simple-perl
3737
- g++-5
38-
- libubsan0
39-
- parallel
4038
before_install:
4139
- mkdir bin ; ln -s /usr/bin/gcc-5 bin/gcc
4240
env:
4341
- COMPILER="ccache g++-5"
4442
- BUILD_PURPOSE="test"
45-
- OS="ubuntu"
4643

4744
# Test - OS X using g++
4845
- stage: compile with extra flags for debug
@@ -51,13 +48,11 @@ jobs:
5148
compiler: gcc
5249
cache: ccache
5350
before_install:
54-
- HOMEBREW_NO_AUTO_UPDATE=1 brew install jq ccache parallel cpanm
55-
- sudo cpanm Thread::Pool::Simple
51+
- HOMEBREW_NO_AUTO_UPDATE=1 brew install jq ccache
5652
- export PATH=/usr/local/opt/ccache/libexec:$PATH
5753
env:
5854
- COMPILER="ccache g++"
5955
- BUILD_PURPOSE="test"
60-
- OS="osx"
6156

6257
# Test - OS X using clang++
6358
- stage: compile with extra flags for debug
@@ -66,13 +61,11 @@ jobs:
6661
compiler: clang
6762
cache: ccache
6863
before_install:
69-
- HOMEBREW_NO_AUTO_UPDATE=1 brew install jq ccache parallel cpanm
70-
- sudo cpanm Thread::Pool::Simple
64+
- HOMEBREW_NO_AUTO_UPDATE=1 brew install jq ccache
7165
- export PATH=/usr/local/opt/ccache/libexec:$PATH
7266
env:
7367
- COMPILER="ccache clang++ -Qunused-arguments -fcolor-diagnostics"
7468
- BUILD_PURPOSE="test"
75-
- OS="osx"
7669

7770
# Test - Ubuntu Linux with glibc using clang++-3.7
7871
- stage: compile with extra flags for debug
@@ -88,20 +81,52 @@ jobs:
8881
- llvm-toolchain-precise-3.7
8982
packages:
9083
- libwww-perl
91-
- libthread-pool-simple-perl
9284
- clang-3.7
9385
- libstdc++-5-dev
94-
- libubsan0
95-
- parallel
9686
before_install:
9787
- mkdir bin ; ln -s /usr/bin/clang-3.7 bin/gcc
9888
env:
9989
- COMPILER="ccache clang++-3.7 -Qunused-arguments -fcolor-diagnostics"
10090
- BUILD_PURPOSE="test"
10191
- CCACHE_CPP2=yes
102-
- OS="ubuntu"
10392

10493
install:
10594
- ccache --max-size=1G
95+
- perl -pe 's/git\@github.com:/https:\/\/github.com\//' -i .gitmodules
96+
- |
97+
# Fetch forks. If this is a PR or a master/develop branch, CBMC submodule has to refer to
98+
# 'diffblue/cbmc' not to a fork so no need to fetch anything
99+
set -euo pipefail
100+
if [[ "${TRAVIS_PULL_REQUEST}" == "false" && ! ( "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" =~ ^(master|develop)$ ) ]]
101+
then
102+
# Get list of all contributors who have cbmc forks, to fetch these.
103+
CONTRIBUTORS=$(mktemp)
104+
# Note: the following curl might not return all entries
105+
# if there is too many contributors/forks, so we might need
106+
# to adapt this as DiffBlue grows :-)
107+
curl -H "Authorization: token ${GITHUB_TOKEN}" \
108+
"https://api.github.com/repos/diffblue/musketeer/contributors?per_page=100" \
109+
| jq -r '.[] | .login' \
110+
| sort > ${CONTRIBUTORS}
111+
112+
export USERS
113+
USERS=$(cat ${CONTRIBUTORS} | tr "\n" " ")
114+
115+
echo "List of forks to pull >${USERS}<"
116+
else
117+
echo "No forks will be fetched"
118+
fi
119+
set +u
106120
- make -C src setup-cbmc
107-
- make -C src "CXX=${COMPILER}" "CXXFLAGS=-Wall -Werror -pedantic -O2 -g ${EXTRA_CXXFLAGS}" -j2
121+
- |
122+
# Compile for test builds
123+
( set -euo pipefail
124+
if [[ "${BUILD_PURPOSE}" =~ ^(test)$ ]]
125+
then
126+
make -C src "CXX=${COMPILER}" "CXXFLAGS=-Wall -Werror -pedantic -O2 -g" -j2
127+
fi
128+
set +u
129+
)
130+
131+
script:
132+
- make -C regression test

src/setup_submodules.sh

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
11
#!/bin/bash
22

3-
# Initialize both submodules
4-
git submodule init
3+
set -euo pipefail
54

6-
git submodule update ../lib/cbmc
5+
# Initialize submodules
6+
git submodule update --init
77

88
# The forks of diffblue/cbmc that should be fetched into the submodule
99
# allowing for getting commits that aren't yet merged into the upstream fork
10-
req_forks=( "$@" )
1110

12-
cd ../lib/cbmc/
13-
14-
for fork in "${req_forks[@]}"
15-
do
16-
# We should use the following command to check whether the fork exists:
17-
# but it is unreliable so we just assume it exists.
18-
# curl https://api.github.com/repos/$fork/cbmc | jq ".id" -e
19-
# Return code is 0 if the repos exists
20-
21-
# Check whether the specific fork is already a remote
22-
git remote | grep $fork > /dev/null
23-
result=$?
24-
25-
if [ $result -ne 0 ]
26-
then
27-
# Fork not found - add it
28-
echo Adding fork $fork
29-
remote_add_result=`git remote add $fork [email protected]:$fork/cbmc.git`
30-
fi
31-
32-
# Fetch all the forks to ensure we are up to date
33-
echo Fetching fork $fork
34-
git fetch $fork
35-
36-
done
11+
if [ ! -z "$*" ]
12+
then
13+
req_forks=( "$@" )
14+
cd ../lib/cbmc/
15+
for fork in "${req_forks[@]}"
16+
do
17+
# We should use the following command to check whether the fork exists:
18+
# but it is unreliable so we just assume it exists.
19+
# curl https://api.github.com/repos/$fork/cbmc | jq ".id" -e
20+
# Return code is 0 if the repos exists
21+
22+
# Check whether the specific fork is already a remote
23+
if ! git remote | grep "${fork}" > /dev/null
24+
then
25+
# Fork not found - add it
26+
echo Adding fork "${fork}"
27+
git remote add "${fork}" "https://github.com/${fork}/cbmc.git"
28+
fi
29+
30+
# Fetch all the forks to ensure we are up to date
31+
echo Fetching fork "${fork}"
32+
git fetch "${fork}"
33+
done
34+
fi

0 commit comments

Comments
 (0)