Browse Source

Use travis setup from main repo

master
Josh Hagins 9 years ago
parent
commit
b58fc49984
  1. 83
      .travis.yml
  2. 5
      ci/travis/README.md
  3. 67
      ci/travis/before_install.sh
  4. 21
      ci/travis/before_script.sh
  5. 55
      ci/travis/helpers.sh
  6. 21
      ci/travis/install.sh
  7. 22
      ci/travis/script.sh
  8. 1
      test/layout_test.rb

83
.travis.yml

@ -1,64 +1,52 @@
language: objective-c
# todo
#
# test with Ruby 2.1, but allow failure
#
sudo: false
# "Current" is dependent on OS X release. At the time of writing, it
# is always either 1.8 or 2.0
env:
matrix:
- CASK_RUBY_TEST_VERSION="2.0"
- CASK_RUBY_TEST_VERSION="Current"
global:
- LANG=en_US.UTF-8
- LANGUAGE=en_US.UTF-8
- LC_ALL=en_US.UTF-8
# permit "Current" to fail without affecting our badge
matrix:
allow_failures:
- env: CASK_RUBY_TEST_VERSION="Current"
include:
- env: OSX=10.11 HOMEBREW_RUBY=2.0.0
os: osx
osx_image: xcode7.2
rvm: system
- env: OSX=10.10 HOMEBREW_RUBY=2.0.0
os: osx
osx_image: xcode7.1
rvm: system
- env: OSX=10.9 HOMEBREW_RUBY=2.0.0
os: osx
osx_image: beta-xcode6.2
rvm: system
fast_finish: true
# before_install steps
# * turn off RVM
# * set PATH according to env matrix
# * update Homebrew
# * informational feedback
branches:
only:
- master
cache:
directories:
- /usr/local
- $HOME/.gem
before_install:
- rvm use system
- export PATH="/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin":"$PATH"
- brew update
- printenv PATH
- /usr/bin/which ruby
- ruby --version
- /usr/bin/which rake
- rake --version
- echo ls_ruby_bindir; ls "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin"
- . ci/travis/before_install.sh
# install steps
# * bundler gem
# * Ruby gems required for brew-cask
install:
- echo gem_install_bundler; sudo "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin/gem" install bundler --bindir="/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin"
- echo bundle; sudo "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin/bundle" --system
- brew install caskroom/cask/brew-cask
- . ci/travis/install.sh
# informational feedback
before_script:
- printenv PATH
- /usr/bin/which ruby
- ruby --version
- /usr/bin/which bundle
- bundle --version
- /usr/bin/which rake
- rake --version
- echo ls_ruby_bindir; ls "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin"
- . ci/travis/before_script.sh
# the test itself
# path-quoting is different here due to YAML constraints
script:
- /System/Library/Frameworks/Ruby.framework/Versions/"${CASK_RUBY_TEST_VERSION}"/usr/bin/bundle exec "/System/Library/Frameworks/Ruby.framework/Versions/${CASK_RUBY_TEST_VERSION}/usr/bin/rake" test
- . ci/travis/script.sh
notifications:
email: false
irc:
channels:
- "chat.freenode.net#homebrew-cask"
@ -66,4 +54,9 @@ notifications:
- "(%{repository_name}) %{build_number}: %{branch}@%{commit} %{author} -> %{message} %{build_url}"
use_notice: true
skip_join: true
email: false
webhooks:
urls:
- "https://webhooks.gitter.im/e/712d699360b239db14a5"
on_success: change
on_failure: always
on_start: never

5
ci/travis/README.md

@ -0,0 +1,5 @@
## Travis-CI Scripts
The bash scripts in this directory are run only in Travis-CI, and are placed here to help simplify the [`.travis.yml`](../../.travis.yml) configuration file.
These scripts are not meant to be run locally by users or developers of Homebrew-Cask.

67
ci/travis/before_install.sh

@ -0,0 +1,67 @@
#!/usr/bin/env bash
#
# before_install.sh
#
# This file is meant to be sourced during the `before_install` phase of the
# Travis build. Do not attempt to source or run it locally.
#
# shellcheck disable=SC1090
. "${TRAVIS_BUILD_DIR}/ci/travis/helpers.sh"
enter_build_step
header 'Running before_install.sh...'
# unset rvm hook functions
run unset -f cd gem
# print all travis-defined environment variables
run 'env | sort'
# see https://github.com/travis-ci/travis-ci/issues/2666
run export BRANCH_COMMIT="${TRAVIS_COMMIT_RANGE##*.}"
run export TARGET_COMMIT="${TRAVIS_COMMIT_RANGE%%.*}"
# shellcheck disable=SC2016
run 'MERGE_BASE="$(git merge-base "${BRANCH_COMMIT}" "${TARGET_COMMIT}")"'
run export MERGE_BASE="${MERGE_BASE}"
run export TRAVIS_COMMIT_RANGE="${MERGE_BASE}...${BRANCH_COMMIT}"
# print detailed OSX version info
run sw_vers
# capture system ruby and gem locations
run export SYSTEM_RUBY_HOME="/System/Library/Frameworks/Ruby.framework/Versions/${HOMEBREW_RUBY%.*}"
run export SYSTEM_RUBY_BINDIR="${SYSTEM_RUBY_HOME}/usr/bin"
run export SYSTEM_GEM_HOME="${SYSTEM_RUBY_HOME}/usr/lib/ruby/gems/${HOMEBREW_RUBY}"
run export SYSTEM_GEM_BINDIR="${SYSTEM_GEM_HOME}/bin"
# capture user gem locations
run export GEM_HOME="$HOME/.gem/ruby/${HOMEBREW_RUBY}"
run export GEM_BINDIR="${GEM_HOME}/bin"
# ensure that the gems we install are used before system gems
run export GEM_PATH="${GEM_HOME}:${SYSTEM_GEM_HOME}"
run export PATH="${GEM_BINDIR}:${SYSTEM_GEM_BINDIR}:${SYSTEM_RUBY_BINDIR}:$PATH"
# ensure that brew uses the ruby we want it to
run export HOMEBREW_RUBY_PATH="${SYSTEM_RUBY_BINDIR}/ruby"
run which ruby
run ruby --version
run which gem
run gem --version
run brew update
# ensure that we are the only brew-cask available
run brew uninstall --force brew-cask
# mirror the repo as a tap, then run the build from there
run export CASK_TAP_DIR='/usr/local/Library/Taps/caskroom/homebrew-versions'
run mkdir -p "${CASK_TAP_DIR}"
run rsync -az --delete "${TRAVIS_BUILD_DIR}/" "${CASK_TAP_DIR}/"
run export TRAVIS_BUILD_DIR="${CASK_TAP_DIR}"
run cd "${CASK_TAP_DIR}" || exit 1
exit_build_step

21
ci/travis/before_script.sh

@ -0,0 +1,21 @@
#!/usr/bin/env bash
#
# before_script.sh
#
# This file is meant to be sourced during the `before_script` phase of the
# Travis build. Do not attempt to source or run it locally.
#
# shellcheck disable=SC1090
. "${TRAVIS_BUILD_DIR}/ci/travis/helpers.sh"
enter_build_step
header 'Running before_script.sh...'
run which bundle
run bundle --version
run which rake
run rake --version
exit_build_step

55
ci/travis/helpers.sh

@ -0,0 +1,55 @@
#!/usr/bin/env bash
#
# helpers.sh
#
# Helper functions for Travis build scripts.
#
# force strict error checking
set -o errexit
set -o pipefail
# enable extended globbing syntax
shopt -s extglob
CYAN='\033[0;36m'
MAGENTA='\033[1;35m'
NC='\033[0m' # no color
# log command before running and add a blank line
run () {
echo -e "${MAGENTA}>>>${NC} $*"
eval "$*"
local retval=$?
echo
return $retval
}
# print args as a cyan header
header () {
echo
echo -e "${CYAN}$*${NC}"
echo
}
# disallow unbound variables during build step
enter_build_step () {
set -o nounset
}
# allow unbound variables so Travis doesn't get mad at us
exit_build_step () {
set +o nounset
}
modified_cask_files () {
if [[ -z "${MODIFIED_CASK_FILES+defined}" ]]; then
MODIFIED_CASK_FILES="$(git diff --name-only --diff-filter=AM "${TRAVIS_COMMIT_RANGE}" -- Casks/*.rb)"
export MODIFIED_CASK_FILES
fi
echo "${MODIFIED_CASK_FILES}"
}
any_casks_modified () {
[[ -n "$(modified_cask_files)" ]]
}

21
ci/travis/install.sh

@ -0,0 +1,21 @@
#!/usr/bin/env bash
#
# install.sh
#
# This file is meant to be sourced during the `install` phase of the Travis
# build. Do not attempt to source or run it locally.
#
# shellcheck disable=SC1090
. "${TRAVIS_BUILD_DIR}/ci/travis/helpers.sh"
enter_build_step
header 'Running install.sh...'
# install bundler and project dependencies in $GEM_HOME
run gem install --no-ri --no-rdoc bundler
run which bundle
run bundle --version
run bundle install --path="${GEM_HOME%/*/*}"
exit_build_step

22
ci/travis/script.sh

@ -0,0 +1,22 @@
#!/usr/bin/env bash
#
# script.sh
#
# This file is meant to be sourced during the `script` phase of the Travis
# build. Do not attempt to source or run it locally.
#
# shellcheck disable=SC1090
. "${TRAVIS_BUILD_DIR}/ci/travis/helpers.sh"
enter_build_step
header 'Running script.sh...'
if any_casks_modified; then
modified_casks=($(modified_cask_files))
run brew cask style "${modified_casks[@]}"
fi
run bundle exec rake test
exit_build_step

1
test/layout_test.rb

@ -24,6 +24,7 @@ describe "Repo layout" do
TOPLEVEL_DIRS = %w{
.git
Casks
ci
developer
spec
test

Loading…
Cancel
Save