Merge pull request #6680 from opf/fix/optimize_travis_caching

Fix/optimize travis caching

[ci skip]
pull/6721/head
Oliver Günther 6 years ago committed by GitHub
commit a58636592d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 145
      .travis.yml
  2. 49
      script/ci/cache_prepare.sh
  3. 18
      script/ci/runner.sh
  4. 26
      script/ci/setup.sh

@ -47,7 +47,10 @@ dist: trusty
cache:
bundler: true
directories:
- frontend/node_modules
- frontend/node_modules/foundation-apps
- public/assets
- app/assets/javascripts/bundles
- app/assets/javascripts/locales
branches:
only:
@ -60,56 +63,114 @@ env:
- CI=true
- RAILS_ENV=test
matrix:
- "TEST_SUITE=npm"
- "TEST_SUITE=spec_legacy DB=mysql GROUP_SIZE=1 GROUP=1"
- "TEST_SUITE=spec_legacy DB=postgres GROUP_SIZE=1 GROUP=1"
- "TEST_SUITE=cucumber DB=mysql GROUP_SIZE=1 GROUP=1"
- "TEST_SUITE=cucumber DB=postgres GROUP_SIZE=1 GROUP=1"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=4 GROUP=1"
- "TEST_SUITE=specs DB=postgres GROUP_SIZE=4 GROUP=1"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=4 GROUP=2"
- "TEST_SUITE=specs DB=postgres GROUP_SIZE=4 GROUP=2"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=4 GROUP=3"
- "TEST_SUITE=specs DB=postgres GROUP_SIZE=4 GROUP=3"
- "TEST_SUITE=specs DB=mysql GROUP_SIZE=4 GROUP=4"
- "TEST_SUITE=specs DB=postgres GROUP_SIZE=4 GROUP=4"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=4 GROUP=1"
- "TEST_SUITE=features DB=postgres GROUP_SIZE=4 GROUP=1"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=4 GROUP=2"
- "TEST_SUITE=features DB=postgres GROUP_SIZE=4 GROUP=2"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=4 GROUP=3"
- "TEST_SUITE=features DB=postgres GROUP_SIZE=4 GROUP=3"
- "TEST_SUITE=features DB=mysql GROUP_SIZE=4 GROUP=4"
- "TEST_SUITE=features DB=postgres GROUP_SIZE=4 GROUP=4"
before_install:
# Install pandoc for testing textile migration
- travis_retry sudo apt-get update -qq
- travis_retry sudo apt-get install -qq pandoc
# Install Node latest LTS
- "nvm install --lts"
# work around https://github.com/travis-ci/travis-ci/issues/8969
- travis_retry gem update --system
# Don't install 1.16.3
- gem install bundler -v 1.16.2
# Install Node latest LTS
# This should only be necessary when preparing the cache or for npm test runs
# but installing later fails for unknown reasons.
- nvm install --lts
bundler_args: --binstubs --without development production docker
before_script:
- bash script/ci_setup.sh $TEST_SUITE $DB
script:
- bash script/ci_runner.sh
stages:
- prepare cache
- test
jobs:
include:
- stage: prepare cache
name: 'Prepare cache'
script:
- bash script/ci/cache_prepare.sh
- stage: test
name: 'npm'
script:
- bash script/ci/setup.sh npm
- bash script/ci/runner.sh npm
- name: 'spec_legacy (1/1) - mysql'
script:
- bash script/ci/setup.sh spec_legacy mysql
- bash script/ci/runner.sh spec_legacy 1 1
- name: 'spec_legacy (1/1) - postgresql'
script:
- bash script/ci/setup.sh spec_legacy postgres
- bash script/ci/runner.sh spec_legacy 1 1
- name: 'cucumber (1/1) - mysql'
script:
- bash script/ci/setup.sh cucumber mysql
- bash script/ci/runner.sh cucumber 1 1
- name: 'cucumber (1/1) - postgresql'
script:
- bash script/ci/setup.sh cucumber postgres
- bash script/ci/runner.sh cucumber 1 1
- name: 'unit specs (1/4) - mysql'
script:
- bash script/ci/setup.sh specs mysql
- bash script/ci/runner.sh specs 4 1
- name: 'unit specs (1/4) - postgresql'
script:
- bash script/ci/setup.sh specs postgres
- bash script/ci/runner.sh specs 4 1
- name: 'unit specs (2/4) - mysql'
script:
- bash script/ci/setup.sh specs mysql
- bash script/ci/runner.sh specs 4 2
- name: 'unit specs (2/4) - postgresql'
script:
- bash script/ci/setup.sh spec postgres
- bash script/ci/runner.sh specs 4 2
- name: 'unit specs (3/4) - mysql'
script:
- bash script/ci/setup.sh specs mysql
- bash script/ci/runner.sh specs 4 3
- name: 'unit specs (3/4) - postgresql'
script:
- bash script/ci/setup.sh specs postgres
- bash script/ci/runner.sh specs 4 3
- name: 'unit specs (4/4) - mysql'
script:
- bash script/ci/setup.sh specs mysql
- bash script/ci/runner.sh specs 4 4
- name: 'unit specs (4/4) - postgresql'
script:
- bash script/ci/setup.sh specs postgres
- bash script/ci/runner.sh specs 4 4
- name: 'feature specs (1/4) - mysql'
script:
- bash script/ci/setup.sh features mysql
- bash script/ci/runner.sh features 4 1
- name: 'feature specs (1/4) - postgresql'
script:
- bash script/ci/setup.sh features postgres
- bash script/ci/runner.sh features 4 1
- name: 'feature specs (2/4) - mysql'
script:
- bash script/ci/setup.sh features mysql
- bash script/ci/runner.sh features 4 2
- name: 'feature specs (2/4) - postgresql'
script:
- bash script/ci/setup.sh features postgres
- bash script/ci/runner.sh features 4 2
- name: 'feature specs (3/4) - mysql'
script:
- bash script/ci/setup.sh features mysql
- bash script/ci/runner.sh features 4 3
- name: 'feature specs (3/4) - postgresql'
script:
- bash script/ci/setup.sh features postgres
- bash script/ci/runner.sh features 4 3
- name: 'feature specs (4/4) - mysql'
script:
- bash script/ci/setup.sh features mysql
- bash script/ci/runner.sh features 4 4
- name: 'feature specs (4/4) - postgresql'
script:
- bash script/ci/setup.sh features postgres
- bash script/ci/runner.sh features 4 4
addons:

@ -0,0 +1,49 @@
#!/bin/bash
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
run() {
echo $1;
eval $1;
echo $2;
eval $2;
}
run "mysql -u root -e \"CREATE DATABASE IF NOT EXISTS travis_ci_test DEFAULT CHARACTER SET = 'utf8' DEFAULT COLLATE 'utf8_general_ci';\""
run "mysql -u root -e \"GRANT ALL ON travis_ci_test.* TO 'travis'@'localhost';\""
run "cp script/templates/database.travis.mysql.yml config/database.yml"
run "bundle exec rake db:migrate"
run "for i in {1..3}; do npm install && break || sleep 15; done"
run "bundle exec rails assets:precompile assets:clean"
run "cp -rp config/frontend_assets.manifest.json public/assets/frontend_assets.manifest.json"

@ -27,7 +27,12 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
# script/ci_runner.sh
# script/ci/runner.sh
# $1 = TEST_SUITE
# $2 = GROUP_SIZE
# $3 = GROUP
#!/bin/sh
set -e
@ -38,7 +43,7 @@ export CI_SEED=$(git rev-parse HEAD | tr -d 'a-z' | cut -b 1-5 | tr -d '0')
# by rails assets:precompile
export OPENPROJECT_CLI_PROXY=''
case "$TEST_SUITE" in
case "$1" in
npm)
npm test
;;
@ -48,11 +53,14 @@ case "$TEST_SUITE" in
exec bundle exec rspec -I spec_legacy -o "--seed $CI_SEED" spec_legacy
;;
specs)
bin/parallel_test --type rspec -o "--seed $CI_SEED" -n $GROUP_SIZE --only-group $GROUP --pattern '^spec/(?!features\/)' spec
bin/parallel_test --type rspec -o "--seed $CI_SEED" -n $2 --only-group $3 --pattern '^spec/(?!features\/)' spec
;;
features)
bin/parallel_test --type rspec -o "--seed $CI_SEED" -n $GROUP_SIZE --only-group $GROUP --pattern '^spec\/features\/' spec
bin/parallel_test --type rspec -o "--seed $CI_SEED" -n $2 --only-group $3 --pattern '^spec\/features\/' spec
;;
cucumber)
bin/parallel_test --type cucumber -n $2 --only-group $3 features
;;
*)
bundle exec rake parallel:$TEST_SUITE
bundle exec rake parallel:$1
esac

@ -28,7 +28,7 @@
# See doc/COPYRIGHT.rdoc for more details.
#++
# script/ci_setup.sh
# script/ci/setup.sh
# $1 = TEST_SUITE
# $2 = DB
@ -55,25 +55,15 @@ if [ $1 != 'npm' ]; then
run "bundle exec rake db:migrate"
fi
run "for i in {1..3}; do npm install && break || sleep 15; done"
if [ $1 = 'npm' ]; then
run "for i in {1..3}; do npm install && break || sleep 15; done"
echo "No asset compilation required"
elif [ $1 != 'specs' ] && [ $1 != 'spec_legacy' ]; then
run "bundle exec rails assets:precompile"
else
# fake result of npm/asset run
run "mkdir -p public/assets/frontend/"
run "touch public/assets/frontend/runtime.js"
run "touch public/assets/frontend/vendor.js"
run "touch public/assets/frontend/main.js"
run "touch public/assets/frontend/styles.js"
run "touch public/assets/frontend/styles.css"
run "mkdir -p app/assets/javascripts/bundles"
run "touch app/assets/javascripts/bundles/openproject-legacy-app.js"
fi
run "mkdir -p app/assets/javascripts/locales"
run "touch app/assets/javascripts/locales/en.js"
if [ $1 = 'specs' ]; then
# Install pandoc for testing textile migration
run "travis_retry sudo apt-get update -qq"
run "travis_retry sudo apt-get install -qq pandoc"
fi
run "cp -rp public/assets/frontend_assets.manifest.json config/frontend_assets.manifest.json"
Loading…
Cancel
Save