-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8871e34
commit edcd00d
Showing
16 changed files
with
364 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
language: ruby | ||
|
||
sudo: false | ||
|
||
env: | ||
global: | ||
- LANG=en_US.UTF-8 | ||
- LANGUAGE=en_US.UTF-8 | ||
- LC_ALL=en_US.UTF-8 | ||
|
||
matrix: | ||
include: | ||
- env: OSX=10.11 HOMEBREW_RUBY=2.0.0 | ||
os: osx | ||
osx_image: xcode7.3 | ||
rvm: system | ||
- env: OSX=10.10 HOMEBREW_RUBY=2.0.0 | ||
os: osx | ||
osx_image: xcode7.1 | ||
rvm: system | ||
fast_finish: true | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
cache: | ||
directories: | ||
- $HOME/.gem | ||
|
||
before_install: | ||
- . ci/travis/before_install.sh | ||
|
||
install: | ||
- . ci/travis/install.sh | ||
|
||
before_script: | ||
- . ci/travis/before_script.sh | ||
|
||
script: | ||
- . ci/travis/script.sh |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
require "rake/testtask" | ||
require "rubocop/rake_task" | ||
|
||
Rake::TestTask.new do |t| | ||
t.pattern = "test/**/*_test.rb" | ||
t.libs << "test" | ||
end | ||
|
||
RuboCop::RakeTask.new(:rubocop) do |t| | ||
t.options = ["--force-exclusion"] | ||
end | ||
|
||
task default: [:test, :rubocop] | ||
task default: :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/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" | ||
|
||
header 'Running before_install.sh...' | ||
|
||
# https://github.com/rvm/rvm/pull/3627 | ||
run rvm get head | ||
|
||
# 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 | ||
if ! run 'MERGE_BASE="$(git merge-base "${BRANCH_COMMIT}" "${TARGET_COMMIT}")"'; then | ||
run git fetch --unshallow | ||
run 'MERGE_BASE="$(git merge-base "${BRANCH_COMMIT}" "${TARGET_COMMIT}")"' | ||
fi | ||
run export MERGE_BASE="${MERGE_BASE}" | ||
run export TRAVIS_COMMIT_RANGE="${MERGE_BASE}...${BRANCH_COMMIT}" | ||
|
||
# print detailed macOS 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/reitermarkus/homebrew-tap' | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/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" | ||
|
||
header 'Running before_script.sh...' | ||
|
||
run which bundle | ||
run bundle --version | ||
|
||
run which rake | ||
run rake --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/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 | ||
} | ||
|
||
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}" | ||
} | ||
|
||
modified_files_outside_casks () { | ||
if [[ -z "${MODIFIED_FILES_OUTSIDE_CASKS+defined}" ]]; then | ||
MODIFIED_FILES_OUTSIDE_CASKS="$(git diff --name-only "${TRAVIS_COMMIT_RANGE}" -- !(Casks))" | ||
export MODIFIED_FILES_OUTSIDE_CASKS | ||
fi | ||
echo "${MODIFIED_FILES_OUTSIDE_CASKS}" | ||
} | ||
|
||
any_casks_modified () { | ||
[[ -n "$(modified_cask_files)" ]] | ||
} | ||
|
||
must_run_tests () { | ||
[[ -n "$(modified_files_outside_casks)" ]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/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" | ||
|
||
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%/*/*}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/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" | ||
|
||
header 'Running script.sh...' | ||
|
||
if any_casks_modified; then | ||
modified_casks=($(modified_cask_files)) | ||
run brew cask style "${modified_casks[@]}" | ||
fi | ||
|
||
if must_run_tests; then | ||
run bundle exec rubocop | ||
run bundle exec rake test | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require "test_helper" | ||
|
||
describe "Casks" do | ||
Hbc.all.each do |cask| | ||
describe cask.to_s do | ||
it "passes audit" do | ||
audit = Hbc::Audit.new(cask) | ||
audit.run! | ||
audit.errors.must_equal [], "[#{cask}] Cask audit must be error free" | ||
audit.warnings.must_equal [], "[#{cask}] Cask audit must be warning free" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
require "test_helper" | ||
|
||
describe "Repo layout" do | ||
project_root = Pathname.new(File.expand_path("#{File.dirname(__FILE__)}/../")) | ||
|
||
# TODO: a more clever way to do this would be to dispense with | ||
# the imperfect IGNORE lists and read the actual repo | ||
# contents by reading the output of "git ls-files" | ||
|
||
# dot dirs are always a project of Dir.entries | ||
# other files are items that the developer hopefully has gitignored | ||
IGNORE_FILES = %w[ | ||
. | ||
.. | ||
.DS_Store | ||
.bundle | ||
].freeze | ||
|
||
# the developer has hopefully gitignored these | ||
IGNORE_REGEXPS = [ | ||
%r{~$}, # emacs | ||
].freeze | ||
|
||
TOPLEVEL_DIRS = %w[ | ||
.git | ||
.github | ||
Casks | ||
ci | ||
Formula | ||
developer | ||
spec | ||
test | ||
].freeze | ||
|
||
TOPLEVEL_FILES = %w[ | ||
.gitignore | ||
.gitattributes | ||
.rspec | ||
.rubocop.yml | ||
.travis.yml | ||
CONTRIBUTING.md | ||
Gemfile | ||
Gemfile.lock | ||
LICENSE | ||
README.md | ||
Rakefile | ||
].freeze | ||
|
||
describe "toplevel dir" do | ||
it "finds some files at the top level" do | ||
entries = Dir.entries(project_root) | ||
entries.length.must_be :>, 0 | ||
end | ||
|
||
it "only finds expected files at the top level" do | ||
entries = Dir.entries(project_root) - IGNORE_FILES - TOPLEVEL_DIRS - TOPLEVEL_FILES | ||
IGNORE_REGEXPS.each do |regexp| | ||
entries.reject! { |elt| elt.match(regexp) } | ||
end | ||
entries.must_equal [] | ||
end | ||
end | ||
|
||
describe "Casks dir" do | ||
it "finds some files in the Casks dir" do | ||
entries = Dir.entries(project_root.join("Casks")) | ||
entries.length.must_be :>, 0 | ||
end | ||
|
||
it "only finds .rb files in the Casks dir" do | ||
entries = Dir.entries(project_root.join("Casks")) - IGNORE_FILES | ||
IGNORE_REGEXPS.each do |regexp| | ||
entries.reject! { |elt| elt.match(regexp) } | ||
end | ||
entries.reject! { |elt| elt.match(%r{\.rb$}) } | ||
entries.must_equal [] | ||
end | ||
end | ||
end |
Oops, something went wrong.