зеркало из https://github.com/mislav/hub.git
Improve bootstrap, build and test scripts
Old `script/bootstrap` & `script/build` were unfriendly to Go newbies because they require the user having GOPATH set in their environment, and either `godep` installed or `hg` to be able to fetch godep. However, since dependencies are vendored, we don't have any real build dependencies except Go itself. - `script/bootstrap` now checks Go and installs Ruby test bundle - `script/build` skips compiling if binary is up to date - `script/test` runs both Go and Cucumber test suites
This commit is contained in:
Родитель
c05272dd93
Коммит
38db23dd62
|
@ -12,9 +12,7 @@ go:
|
||||||
install:
|
install:
|
||||||
- script/cached-bundle install --deployment --without development --jobs 3 --retry 3
|
- script/cached-bundle install --deployment --without development --jobs 3 --retry 3
|
||||||
script:
|
script:
|
||||||
- make
|
- script/test
|
||||||
- make hub
|
|
||||||
- script/ruby-test
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
env:
|
env:
|
||||||
|
|
26
Makefile
26
Makefile
|
@ -1,26 +0,0 @@
|
||||||
ifeq ($(TMPDIR),)
|
|
||||||
TMPDIR := /tmp
|
|
||||||
endif
|
|
||||||
|
|
||||||
TMP := $(TMPDIR)/go
|
|
||||||
SELF := $(TMP)/src/github.com/jingweno/gh
|
|
||||||
export GOPATH := $(TMP):$(PWD)/Godeps/_workspace
|
|
||||||
|
|
||||||
objects = main.go cmd/*.go commands/*.go git/*.go github/*.go utils/*.go
|
|
||||||
|
|
||||||
test: $(SELF)
|
|
||||||
go test -cover -v ./...
|
|
||||||
|
|
||||||
hub: $(SELF) $(objects)
|
|
||||||
go build -o $@
|
|
||||||
|
|
||||||
fmt:
|
|
||||||
go fmt ./...
|
|
||||||
|
|
||||||
$(SELF):
|
|
||||||
mkdir -p $(dir $@)
|
|
||||||
ln -snf "$(PWD)" $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f hub
|
|
||||||
rm -rf $(TMP)
|
|
|
@ -1,8 +1,22 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Usage: bootstrap
|
set -e
|
||||||
#
|
|
||||||
# Install all dependencies
|
|
||||||
#
|
|
||||||
# Author: Jingwen Owen Ou
|
|
||||||
|
|
||||||
go get github.com/kr/godep
|
STATUS=0
|
||||||
|
|
||||||
|
if ! go version; then
|
||||||
|
echo "You need to install Go 1.2 to build hub" >&2
|
||||||
|
STATUS=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
{ ruby --version
|
||||||
|
bundle install --path vendor/bundle -j 4
|
||||||
|
} || {
|
||||||
|
echo "You need Ruby 2.1 and Bundler to run hub tests" >&2
|
||||||
|
STATUS=1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ $STATUS -eq 0 ]; then
|
||||||
|
echo "Everything OK."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit $STATUS
|
||||||
|
|
47
script/build
47
script/build
|
@ -1,9 +1,44 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Usage: build
|
# Usage: script/build [test]
|
||||||
#
|
#
|
||||||
# Run go build with godep
|
# Sets up GOPATH and compiles hub. With `test`, runs tests instead.
|
||||||
#
|
|
||||||
# Author: Jingwen Owen Ou
|
|
||||||
|
|
||||||
script/bootstrap
|
set -e
|
||||||
godep go build -o gh
|
|
||||||
|
TMP_GOPATH="${TMPDIR:-/tmp}/go"
|
||||||
|
TMP_SELF="${TMP_GOPATH}/src/github.com/jingweno/gh"
|
||||||
|
|
||||||
|
export GOPATH="${TMP_GOPATH}:${PWD}/Godeps/_workspace:$GOPATH"
|
||||||
|
|
||||||
|
if [ ! -e "$TMP_SELF" ]; then
|
||||||
|
mkdir -p "${TMP_SELF%/*}"
|
||||||
|
ln -snf "$PWD" "$TMP_SELF"
|
||||||
|
fi
|
||||||
|
|
||||||
|
find_source_files() {
|
||||||
|
find . -maxdepth 2 -name '*.go' -not -name '*_test.go' "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
count_changed_files() {
|
||||||
|
printf %d $(find_source_files -newer "$1" | wc -l)
|
||||||
|
}
|
||||||
|
|
||||||
|
up_to_date() {
|
||||||
|
[ -e "$1" ] && [ "$(count_changed_files "$1")" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
"" )
|
||||||
|
up_to_date hub || go build -o hub
|
||||||
|
;;
|
||||||
|
test )
|
||||||
|
go test ./...
|
||||||
|
;;
|
||||||
|
-h | --help )
|
||||||
|
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
"$0" --help >&2
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# Usage: build
|
|
||||||
#
|
|
||||||
# Run go fmt with godep
|
|
||||||
#
|
|
||||||
# Author: Jingwen Owen Ou
|
|
||||||
|
|
||||||
godep go fmt ./...
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
exec go fmt ./...
|
|
@ -1,9 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# Usage: install
|
|
||||||
#
|
|
||||||
# Run go install with godep
|
|
||||||
#
|
|
||||||
# Author: Jingwen Owen Ou
|
|
||||||
|
|
||||||
script/bootstrap
|
|
||||||
godep go install
|
|
18
script/make
18
script/make
|
@ -1,18 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
# Usage: make
|
|
||||||
#
|
|
||||||
# Build gh without downloading any dependency
|
|
||||||
#
|
|
||||||
# Author: Jingwen Owen Ou
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
BUILD_DIR=`mktemp -d -t gh.XXXXXX`
|
|
||||||
GODEPPATH=`pwd`/Godeps/_workspace
|
|
||||||
GHSOURCE=$BUILD_DIR/src/github.com/jingweno/gh
|
|
||||||
|
|
||||||
export GOPATH=$BUILD_DIR:$GODEPPATH
|
|
||||||
|
|
||||||
mkdir -p $GHSOURCE
|
|
||||||
cp -R `pwd`/. $GHSOURCE
|
|
||||||
go build -o gh
|
|
32
script/test
32
script/test
|
@ -1,10 +1,28 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Usage: build
|
# Usage: script/test
|
||||||
#
|
#
|
||||||
# Run go test with godep
|
# Run Go and Cucumber test suites for hub.
|
||||||
#
|
|
||||||
# Author: Jingwen Owen Ou
|
|
||||||
|
|
||||||
go get code.google.com/p/go.tools/cmd/cover
|
set -e
|
||||||
script/fmt
|
|
||||||
godep go test -cover -v ./...
|
case "$1" in
|
||||||
|
"" )
|
||||||
|
;;
|
||||||
|
-h | --help )
|
||||||
|
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
"$0" --help >&2
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
|
STATUS=0
|
||||||
|
|
||||||
|
trap "exit 1" INT
|
||||||
|
|
||||||
|
script/build
|
||||||
|
script/build test || STATUS="$?"
|
||||||
|
script/ruby-test || STATUS="$?"
|
||||||
|
|
||||||
|
exit "$STATUS"
|
||||||
|
|
Загрузка…
Ссылка в новой задаче