Skip to content

Commit 5f7886a

Browse files
authored
Merge pull request exercism#688 from Smarticles101/build-matrix
Optimize CI Tests
2 parents d2fd031 + bb2c32f commit 5f7886a

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
language: java
33
jdk:
44
- oraclejdk8
5+
env:
6+
- SCRIPT=bin/unit-tests.sh
7+
- SCRIPT=bin/journey-test.sh
58

69
# http://docs.travis-ci.com/user/migrating-from-legacy
710
sudo: false
@@ -23,8 +26,7 @@ before_script:
2326
- export PATH=$TRAVIS_BUILD_DIR/bin:$PATH # ensure our tools are prefered over included ones.
2427

2528
script:
26-
- bin/unit-tests.sh
27-
- bin/journey-test.sh
29+
- $SCRIPT
2830

2931
# configure caching (https://docs.travis-ci.com/user/languages/java/#Caching)
3032
before_cache:

bin/journey-test.sh

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
TRACK=java
44
TRACK_REPO="$TRACK"
55
TRACK_SRC_EXT="java"
6+
CPU_CORES=`getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1`
67

78
on_exit() {
89
echo ">>> on_exit()"
@@ -96,6 +97,14 @@ get_cpu_architecture() {
9697
esac
9798
}
9899

100+
get_optimal_amount_of_jobs() {
101+
if [ "$CPU_CORES" -gt "1" ]; then
102+
echo $((CPU_CORES-1))
103+
else
104+
echo 1
105+
fi
106+
}
107+
99108
download_exercism_cli() {
100109
local os="$1"
101110
local arch="$2"
@@ -162,7 +171,7 @@ make_local_trackler() {
162171
cp -r ${track_root}/exercises tracks/${TRACK}
163172

164173
gem install bundler
165-
bundle install
174+
bundle install --jobs $(get_optimal_amount_of_jobs)
166175
gem build trackler.gemspec
167176

168177
# Make *this* the gem that x-api uses when we build x-api.
@@ -179,7 +188,7 @@ start_x_api() {
179188
pushd $xapi_home
180189

181190
gem install bundler
182-
bundle install
191+
bundle install --jobs $(get_optimal_amount_of_jobs)
183192
RACK_ENV=development rackup &
184193
xapi_pid=$!
185194
sleep 5
@@ -267,18 +276,24 @@ main() {
267276

268277
clean "${build_dir}"
269278

270-
# Make a local version of trackler that includes the source from this repo.
271-
git_clone "x-api" "${xapi_home}"
272-
git_clone "trackler" "${trackler_home}"
273-
assert_ruby_installed "${trackler_home}"
279+
# Download everything we need in parallel
280+
git_clone "x-api" "${xapi_home}" &
281+
git_clone "trackler" "${trackler_home}" &
282+
download_exercism_cli $(get_operating_system) $(get_cpu_architecture) "${exercism_home}" &
283+
wait
284+
285+
# Check and install the ruby stuff we need in parallel
286+
assert_ruby_installed "${trackler_home}" &
287+
assert_ruby_installed "${xapi_home}" &
288+
wait
289+
290+
# Make a local version of trackler
274291
make_local_trackler "${trackler_home}" "${xapi_home}"
275292

276-
# Stand-up a local instance of x-api so we can fetch the exercises through it.
277-
assert_ruby_installed "${xapi_home}"
293+
# Start-up a local instance of x-api so we can fetch the exercises through it.
278294
start_x_api "${xapi_home}"
279295

280296
# Create a CLI install and config just for this build; this script does not use your CLI install.
281-
download_exercism_cli $(get_operating_system) $(get_cpu_architecture) "${exercism_home}"
282297
configure_exercism_cli "${exercism_home}" "${exercism_configfile}" "${xapi_port}"
283298

284299
solve_all_exercises "${exercism_home}" "${exercism_configfile}"

bin/unit-tests.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ echo ""
1212
echo ">>> Running tests..."
1313
TERM=dumb ../gradlew check compileStarterSourceJava --parallel --continue
1414
popd
15-

0 commit comments

Comments
 (0)