Przeglądaj źródła

Merge pull request #688 from Smarticles101/build-matrix

Optimize CI Tests
FridaTveit 9 lat temu
rodzic
commit
5f7886a7dd
3 zmienionych plików z 28 dodań i 12 usunięć
  1. 4
    2
      .travis.yml
  2. 24
    9
      bin/journey-test.sh
  3. 0
    1
      bin/unit-tests.sh

+ 4
- 2
.travis.yml Wyświetl plik

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

+ 24
- 9
bin/journey-test.sh Wyświetl plik

3
 TRACK=java
3
 TRACK=java
4
 TRACK_REPO="$TRACK"
4
 TRACK_REPO="$TRACK"
5
 TRACK_SRC_EXT="java"
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
 on_exit() {
8
 on_exit() {
8
   echo ">>> on_exit()"
9
   echo ">>> on_exit()"
96
   esac
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
 download_exercism_cli() {
108
 download_exercism_cli() {
100
   local os="$1"
109
   local os="$1"
101
   local arch="$2"
110
   local arch="$2"
162
   cp -r ${track_root}/exercises tracks/${TRACK}
171
   cp -r ${track_root}/exercises tracks/${TRACK}
163
 
172
 
164
   gem install bundler
173
   gem install bundler
165
-  bundle install
174
+  bundle install --jobs $(get_optimal_amount_of_jobs)
166
   gem build trackler.gemspec
175
   gem build trackler.gemspec
167
 
176
 
168
   # Make *this* the gem that x-api uses when we build x-api.
177
   # Make *this* the gem that x-api uses when we build x-api.
179
   pushd $xapi_home
188
   pushd $xapi_home
180
 
189
 
181
   gem install bundler
190
   gem install bundler
182
-  bundle install
191
+  bundle install --jobs $(get_optimal_amount_of_jobs) 
183
   RACK_ENV=development rackup &
192
   RACK_ENV=development rackup &
184
   xapi_pid=$!
193
   xapi_pid=$!
185
   sleep 5
194
   sleep 5
267
 
276
 
268
   clean "${build_dir}"
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
   make_local_trackler "${trackler_home}" "${xapi_home}"
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
   start_x_api "${xapi_home}"
294
   start_x_api "${xapi_home}"
279
 
295
 
280
   # Create a CLI install and config just for this build; this script does not use your CLI install.
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
   configure_exercism_cli "${exercism_home}" "${exercism_configfile}" "${xapi_port}"
297
   configure_exercism_cli "${exercism_home}" "${exercism_configfile}" "${xapi_port}"
283
 
298
 
284
   solve_all_exercises "${exercism_home}" "${exercism_configfile}"
299
   solve_all_exercises "${exercism_home}" "${exercism_configfile}"

+ 0
- 1
bin/unit-tests.sh Wyświetl plik

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