Browse Source

Merge pull request #688 from Smarticles101/build-matrix

Optimize CI Tests
FridaTveit 9 years ago
parent
commit
5f7886a7dd
3 changed files with 28 additions and 12 deletions
  1. 4
    2
      .travis.yml
  2. 24
    9
      bin/journey-test.sh
  3. 0
    1
      bin/unit-tests.sh

+ 4
- 2
.travis.yml View File

@@ -2,6 +2,9 @@
2 2
 language: java
3 3
 jdk:
4 4
   - oraclejdk8
5
+env:
6
+  - SCRIPT=bin/unit-tests.sh
7
+  - SCRIPT=bin/journey-test.sh
5 8
 
6 9
 # http://docs.travis-ci.com/user/migrating-from-legacy
7 10
 sudo: false
@@ -23,8 +26,7 @@ before_script:
23 26
   - export PATH=$TRAVIS_BUILD_DIR/bin:$PATH  # ensure our tools are prefered over included ones.
24 27
 
25 28
 script:
26
-  - bin/unit-tests.sh
27
-  - bin/journey-test.sh
29
+  - $SCRIPT
28 30
 
29 31
 # configure caching (https://docs.travis-ci.com/user/languages/java/#Caching)
30 32
 before_cache:

+ 24
- 9
bin/journey-test.sh View File

@@ -3,6 +3,7 @@
3 3
 TRACK=java
4 4
 TRACK_REPO="$TRACK"
5 5
 TRACK_SRC_EXT="java"
6
+CPU_CORES=`getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1`
6 7
 
7 8
 on_exit() {
8 9
   echo ">>> on_exit()"
@@ -96,6 +97,14 @@ get_cpu_architecture() {
96 97
   esac
97 98
 }
98 99
 
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
+
99 108
 download_exercism_cli() {
100 109
   local os="$1"
101 110
   local arch="$2"
@@ -162,7 +171,7 @@ make_local_trackler() {
162 171
   cp -r ${track_root}/exercises tracks/${TRACK}
163 172
 
164 173
   gem install bundler
165
-  bundle install
174
+  bundle install --jobs $(get_optimal_amount_of_jobs)
166 175
   gem build trackler.gemspec
167 176
 
168 177
   # Make *this* the gem that x-api uses when we build x-api.
@@ -179,7 +188,7 @@ start_x_api() {
179 188
   pushd $xapi_home
180 189
 
181 190
   gem install bundler
182
-  bundle install
191
+  bundle install --jobs $(get_optimal_amount_of_jobs) 
183 192
   RACK_ENV=development rackup &
184 193
   xapi_pid=$!
185 194
   sleep 5
@@ -267,18 +276,24 @@ main() {
267 276
 
268 277
   clean "${build_dir}"
269 278
 
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
274 291
   make_local_trackler "${trackler_home}" "${xapi_home}"
275 292
 
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.
278 294
   start_x_api "${xapi_home}"
279 295
 
280 296
   # 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}"
282 297
   configure_exercism_cli "${exercism_home}" "${exercism_configfile}" "${xapi_port}"
283 298
 
284 299
   solve_all_exercises "${exercism_home}" "${exercism_configfile}"

+ 0
- 1
bin/unit-tests.sh View File

@@ -12,4 +12,3 @@ echo ""
12 12
 echo ">>> Running tests..."
13 13
 TERM=dumb ../gradlew check compileStarterSourceJava --parallel --continue
14 14
 popd
15
-