-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
152 lines (142 loc) · 6.23 KB
/
.travis.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
# We pretend to be Java because we need GNU Octave which is not
# available (as of January 2016)
language: java
###############################################################################
cache:
# Downloading octave takes a while, so let's cache apt
apt: true
directories:
# Cache octave packages
- $HOME/octave
###############################################################################
env:
matrix:
- COVERAGE="false"
- COVERAGE="true"
matrix:
allow_failures:
- env: COVERAGE="true"
fast_finish: true
###############################################################################
# Command to install dependencies
before_install:
# Remember the directory where our repository to test is located
- REPOPATH="$(pwd)" && pwd
# ---------------------------------------------------------------------------
# Check whether we need to upgrade the gcc and g++ versions. We do need to if
# the version is less the 4.8 and we need to install the image package from
# Octave Forge (possibly for other packages as well).
# For now, lets just always say we do need to do this.
- UPGRADE_GCC="true"
# ---------------------------------------------------------------------------
# Add repository for octave
- travis_retry sudo add-apt-repository -y ppa:octave/stable
# Add repository for installing g++-4.8 on Ubuntu 12.04
- if [ "$UPGRADE_GCC" = "true" ]; then
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;
fi
# Update apt-get to include the contents from the new locations
- travis_retry sudo apt-get update -qq
# Install octave with apt-get
- travis_retry sudo apt-get install -y octave liboctave-dev
# Add a C++11 compiler so we can install image package
- if [ "$UPGRADE_GCC" = "true" ]; then
travis_retry sudo apt-get install -y gcc-4.8 g++-4.8;
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50;
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50;
fi;
# Check which versions of g++ and gcc we are using
- which g++;
g++ --version;
which gcc;
gcc --version;
# ---------------------------------------------------------------------------
# Go up one level and retrieve MOxUnit from its repository
- cd ..;
ls -alh;
# Remove directory if it is already there from previous build
- rm -rf MOxUnit;
- git clone https://github.com/MOxUnit/MOxUnit.git
# Install MOxUnit, which adds itself to the startup path
- make -C MOxUnit install
# Install MOcov, which adds itself to the startup path
- if [ "$COVERAGE" = "true" ]; then
rm -rf MOcov;
git clone https://github.com/MOcov/MOcov.git;
make -C MOcov install;
fi;
# Go back to the repository directory
- cd ${REPOPATH}
###############################################################################
install:
# Move any .m files in the root level into a subfolder so we can test their
# coverage without including the tests too
- mkdir -p mopi;
mv *.m mopi;
# Before running the tests, we will have to add our package and our
# external dependencies to the octave path
- PACKAGE_FOLDER="mopi";
ADDPATH_COMMAND="addpath(genpath(fullfile(pwd, '$PACKAGE_FOLDER')));";
echo "ADDPATH_COMMAND| $ADDPATH_COMMAND";
###############################################################################
before_script:
- TEST_ARGS="'-recursive', '-verbose', '-junit_xml_file', 'testresults.xml'";
if [ "$COVERAGE" = "true" ]; then
TEST_ARGS+=", '-with_coverage', '-cover', '$PACKAGE_FOLDER'";
TEST_ARGS+=", '-cover_xml_file', 'coverage.xml'";
TEST_ARGS+=", '-cover_json_file', 'coveralls.json'";
fi;
TEST_COMMAND="exit(~moxunit_runtests('tests', $TEST_ARGS));";
echo "TEST_COMMAND| $TEST_COMMAND";
# Double-check we are still in the right directory
- pwd
# Check what octave packages we have installed
- octave -q --eval "ver"
# ---------------------------------------------------------------------------
# Remove any cached results files from previous build, if present
- rm -f testresults.xml;
rm -f coverage.xml;
rm -f .coverage;
rm -f coveralls.json;
# ---------------------------------------------------------------------------
# Set up folders for test results on Shippable
- if [ "$SHIPPABLE" = "true" ]; then
rm -fr shippable;
mkdir -p shippable/testresults;
mkdir -p shippable/codecoverage;
fi;
###############################################################################
script:
- octave -q --eval "$ADDPATH_COMMAND $TEST_COMMAND";
###############################################################################
after_script:
# Check where we ended up and what's going on where we are
- pwd
- ls -alh
# ---------------------------------------------------------------------------
# Move results and coverage files into appropriate places
- if [ "$SHIPPABLE" = "true" ] && [ -f testresults.xml ]; then
mv testresults.xml shippable/testresults/;
fi;
if [ "$SHIPPABLE" = "true" ] && [ -f coverage.xml ]; then
cp coverage.xml shippable/codecoverage/;
fi;
###############################################################################
after_success:
# Only run coveralls on Travis. When running on a public Travis-CI, the
# repo token is automatically inferred, but to run coveralls on Shippable
# the repo token needs to be specified in a .coveralls.yml or as an
# environment variable COVERALLS_REPO_TOKEN. This should be kept hidden
# from public viewing, either by encrypting the token or running on a
# private build.
# We ignore coverage push failures because the servers are not 100%
# reliable and we don't want the CI to report a failure just because the
# coverage report wasn't published.
# For Codecov, we use this https://github.com/codecov/codecov-bash
- if [ "$COVERAGE" = "true" ] && [ "$TRAVIS" = "true" ] && [ "$SHIPPABLE" != "true" ]; then
curl --verbose -F json_file=@`pwd`/coveralls.json https://coveralls.io/api/v1/jobs || echo "Coveralls push failed";
bash <(curl -s https://codecov.io/bash) || echo "Codecov push failed";
fi;
###############################################################################
# Enable archiving of artifacts on Shippable (does nothing on Travis)
archive: true