提交 98f153f3 编写于 作者: M Mislav Marohnić

Merge branch 'simplify-build'

......@@ -5,43 +5,46 @@ GEM
childprocess (>= 0.3.6)
cucumber (>= 1.1.1)
rspec-expectations (>= 2.7.0)
builder (3.2.2)
childprocess (0.5.3)
builder (3.2.3)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
cucumber (1.3.15)
cucumber (1.3.20)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.12)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.1)
diff-lcs (1.2.5)
ffi (1.9.3)
ffi (1.9.3-java)
multi_test (>= 0.1.2)
diff-lcs (1.3)
ffi (1.9.25)
ffi (1.9.25-java)
gherkin (2.12.2)
multi_json (~> 1.3)
gherkin (2.12.2-java)
multi_json (~> 1.3)
hpricot (0.8.4)
multi_json (1.10.1)
multi_test (0.1.1)
hpricot (0.8.4-java)
multi_json (1.13.1)
multi_test (0.1.2)
mustache (0.99.4)
rack (1.4.1)
rack-protection (1.2.0)
mustermann (1.0.2)
rack (2.0.5)
rack-protection (2.0.3)
rack
rdiscount (1.6.8)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
rdiscount (>= 1.5.8)
rspec-expectations (3.0.2)
rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-support (3.0.2)
sinatra (1.3.2)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
tilt (1.3.3)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
sinatra (2.0.3)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.3)
tilt (~> 2.0)
tilt (2.0.8)
PLATFORMS
java
......@@ -54,4 +57,4 @@ DEPENDENCIES
sinatra
BUNDLED WITH
1.11.2
1.16.0
SOURCES = $(shell script/build files)
SOURCES_FMT = $(shell script/build files | cut -d/ -f1-2 | sort -u)
MIN_COVERAGE = 89.4
......@@ -35,15 +34,11 @@ HELP_ALL = share/man/man1/hub.1 $(HELP_CMD) $(HELP_EXT)
TEXT_WIDTH = 87
.PHONY: clean test test-all man-pages fmt install
all: bin/hub
bin/hub: $(SOURCES)
script/build -o $@
test:
script/build test
go test ./...
test-all: bin/cucumber
ifdef CI
......@@ -56,8 +51,7 @@ bin/ronn bin/cucumber:
script/bootstrap
fmt:
go fmt $(filter %.go,$(SOURCES_FMT))
go fmt $(filter-out %.go,$(SOURCES_FMT))
go fmt ./...
man-pages: $(HELP_ALL:=.ronn) $(HELP_ALL) $(HELP_ALL:=.txt)
......@@ -78,3 +72,5 @@ install: bin/hub man-pages
clean:
git clean -fdx bin share/man
.PHONY: clean test test-all man-pages fmt install
......@@ -33,13 +33,6 @@ git version 1.7.6
hub version 2.2.3
```
If you want to get access to new `hub` features earlier and help with its
development by reporting bugs, you can install the prerelease version:
``` sh
$ brew install --devel hub
```
#### Windows
`hub` can be installed through [Chocolatey](https://chocolatey.org/) or
......@@ -78,11 +71,11 @@ in your executable path.
#### Source
To install hub from source:
With your [GOPATH](https://github.com/golang/go/wiki/GOPATH) already set up:
``` sh
$ git clone https://github.com/github/hub.git
$ cd hub
$ go get github.com/github/hub
$ cd "$GOPATH"/src/github.com/github/hub
$ make install prefix=/usr/local
```
......@@ -92,23 +85,6 @@ Prerequisites for compilation are:
* [Go 1.8+](http://golang.org/doc/install)
* Ruby 1.9+ with Bundler - for generating man pages
If you don't have `make`, Ruby, or want to skip man pages (for example, if you
are on Windows), you can build only the `hub` binary:
``` sh
$ ./script/build
```
You can now move `bin/hub` to somewhere in your PATH.
Finally, if you've done Go development before and your `$GOPATH/bin` directory
is already in your PATH, this is an alternative installation method that fetches
hub into your GOPATH and builds it automatically:
``` sh
$ go get github.com/github/hub
```
Aliasing
--------
......
......@@ -3,27 +3,12 @@ require 'fileutils'
require 'forwardable'
require 'tmpdir'
# Ruby 2.2.0 compat
Cucumber::Ast::Step.class_eval do
undef_method :text_length
def text_length(name=name())
self.class::INDENT + self.class::INDENT +
keyword.unpack('U*').length +
name.unpack('U*').length
end
end
system_git = `which git 2>/dev/null`.chomp
lib_dir = File.expand_path('../../../lib', __FILE__)
bin_dir = File.expand_path('../fakebin', __FILE__)
hub_dir = Dir.mktmpdir('hub_build')
raise 'hub build failed' unless system("./script/build -o #{hub_dir}/hub")
Before do
# don't want hub to run in bundle
unset_bundler_env_vars
# have bin/hub load code from the current project
set_env 'RUBYLIB', lib_dir
# speed up load time by skipping RubyGems
set_env 'RUBYOPT', '--disable-gems' if RUBY_VERSION > '1.9'
# put fakebin on the PATH
......@@ -31,7 +16,7 @@ Before do
# clear out GIT if it happens to be set
set_env 'GIT', nil
# exclude this project's git directory from use in testing
set_env 'GIT_CEILING_DIRECTORIES', File.dirname(lib_dir)
set_env 'GIT_CEILING_DIRECTORIES', File.expand_path('../../..', __FILE__)
# sabotage git commands that might try to access a remote host
set_env 'GIT_PROXY_COMMAND', 'echo'
# avoids reading from current user's "~/.gitconfig"
......@@ -71,13 +56,7 @@ Before do
FileUtils.mkdir_p ENV['HOME']
# increase process exit timeout from the default of 3 seconds
@aruba_timeout_seconds = 5
if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
@aruba_io_wait_seconds = 0.1
else
@aruba_io_wait_seconds = 0.02
end
@aruba_timeout_seconds = 10
end
After do
......
......@@ -16,8 +16,6 @@ if [ -n "$TRAVIS" ] && [ ! -x ~/bin/tmux ]; then
curl -fsSL "https://${AMAZON_S3_BUCKET}.s3.amazonaws.com/${cache_name}.tgz" | tar -xz -C ~
fi
script/build check || STATUS=1
{ ruby --version
if [ -n "$TRAVIS" ]; then
script/cached-bundle install --deployment --jobs=3 --retry=3 --path bundle
......
#!/usr/bin/env bash
# vi:ft=sh:
# Usage: script/build [-o <EXE>]
# script/build test
#
# Sets up GOPATH and compiles hub to <EXE> (default: `bin/hub`).
#
# With `test`, runs tests instead.
# Usage: script/build [-o <BIN>]
# script/build files
set -e
windows=
[[ $OS == Windows* ]] && windows=1
setup_gopath() {
TMPDIR="${LOCALAPPDATA:-$TMPDIR}"
TMPDIR=${TMPDIR:-/tmp}
TMP_GOPATH="${TMPDIR%/}/go"
TMP_SELF="${TMP_GOPATH}/src/github.com/github/hub"
if [ -n "$windows" ]; then
export GOPATH="${TMP_GOPATH//\//\\}"
else
export GOPATH="$TMP_GOPATH"
fi
mkdir -p "${TMP_SELF%/*}"
ln -snf "$PWD" "$TMP_SELF" 2>/dev/null || {
rm -rf "$TMP_SELF"
mkdir "$TMP_SELF"
cp -R "$PWD"/* "${TMP_SELF}/"
}
}
find_source_files() {
find . -maxdepth 2 -name '*.go' '!' -name '*_test.go' "$@"
}
find_packages() {
find_source_files | cut -d/ -f2 | sort -u | grep -v '.go$' | sed 's!^!github.com/github/hub/!'
}
check_go_version() {
local version="$(go version)"
local minor="$(grep -o 'go1.[[:digit:]]\+' <<<"$version" | head -1)"
[ -z "$version" ] || echo "$version"
if [[ -z "$version" || -n "$minor" && "${minor##*.}" -lt 8 ]]; then
echo "You need to install Go 1.8 or higher to build hub" >&2
return 1
fi
}
build_hub() {
check_go_version >/dev/null
setup_gopath
mkdir -p "$(dirname "$1")"
go build -ldflags "-X github.com/github/hub/version.Version=`./script/version`" -o "$1"
}
test_hub() {
setup_gopath
find_packages | xargs go test
}
[ $# -gt 0 ] || set -- -o "bin/hub${windows:+.exe}"
case "$1" in
-o )
shift
if [ -z "$1" ]; then
echo "error: argument needed for \`-o'" >&2
exit 1
fi
build_hub "$1"
;;
test )
test_hub
build_hub "${2?}"
;;
files )
find_source_files
;;
check )
check_go_version
;;
-h | --help )
sed -ne '/^#/!q;s/.\{1,2\}//;1,2d;p' < "$0"
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
exit
;;
* )
......
......@@ -45,9 +45,29 @@ generate() {
awk '/^total:/ { print $(NF) }' "${HUB_COVERAGE%.out}.func"
}
case "${1?}" in
prepare | generate )
"$1"
summarize() {
local total_coverage
local min_coverage="${1?}"
total_coverage="$(generate)"
echo "Code coverage: $total_coverage"
local result="$(bc <<<"${total_coverage%\%} < $min_coverage")"
if [ "$result" -eq 1 ]; then
echo "Error: coverage dropped below the minimum treshold of ${min_coverage}%!"
if [ -n "$CI" ]; then
html_result="${HUB_COVERAGE%.out}.html"
html_result="${html_result#$PWD/}"
printf 'Please run `script/test --coverage` locally and open `%s` to analyze the results.\n' "$html_result"
fi
return 1
fi
}
cmd="${1?}"
shift 1
case "$cmd" in
prepare | generate | summarize )
"$cmd" "$@"
;;
* )
exit 1
......
......@@ -33,25 +33,11 @@ trap "exit 1" INT
[ -z "$HUB_COVERAGE" ] || script/coverage prepare
script/build
script/build test || STATUS="$?"
go test ./... || STATUS="$?"
script/ruby-test "$@" || STATUS="$?"
[ -z "$HUB_COVERAGE" ] || script/coverage summarize "$min_coverage" || STATUS=1
if [ -n "$HUB_COVERAGE" ]; then
total_coverage="$(script/coverage generate)"
echo "Code coverage: $total_coverage"
result="$(bc <<<"${total_coverage%\%} < $min_coverage")"
if [ "$result" -eq 1 ]; then
echo "Error: coverage dropped below the minimum treshold of ${min_coverage}%!"
if [ -n "$CI" ]; then
html_result="${HUB_COVERAGE%.out}.html"
html_result="${html_result#$PWD/}"
printf 'Please run `script/test --coverage` locally and open `%s` to analyze the results.\n' "$html_result"
fi
STATUS=1
fi
fi
if [ -n "$CI" ]; then
if [ -n "$CI" ] && [[ "$(go version)" != *" go1.8."* ]]; then
make fmt >/dev/null
if ! git diff -U1 --exit-code; then
STATUS=1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册