From 4b456db5175dcbee543781787f47a8a085b7766d Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Wed, 6 Nov 2019 13:13:48 +0800 Subject: [PATCH] Update Makefile and add git pre-push hook (#1382) --- Makefile | 50 ++++++++++++++++++++------------------ githooks/README.md | 7 ++++++ githooks/pre-push | 6 +++++ hack/verify-govet.sh | 2 +- hack/verify-staticcheck.sh | 4 +-- 5 files changed, 41 insertions(+), 28 deletions(-) create mode 100644 githooks/README.md create mode 100755 githooks/pre-push diff --git a/Makefile b/Makefile index 80ef0d06..bbd806a9 100644 --- a/Makefile +++ b/Makefile @@ -11,36 +11,38 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -.PHONY: test -.DEFAULT_GOAL := build -IMAGE ?= fission/fission-bundle -VERSION ?= latest -ARCH ?= amd64 -OS ?= linux +.DEFAULT_GOAL := check -test: - go test -v $(go list ./... | grep -v /examples/ | grep -v /environments/) +check: test-run build clean -build: build-bundle build-client +# run basic check scripts +test-run: + hack/verify-gofmt.sh + hack/verify-govet.sh + hack/verify-staticcheck.sh + hack/runtests.sh + @rm -f coverage.txt -build-client: +# ensure the changes are buildable +build: + go build -o cmd/fission-bundle/fission-bundle ./cmd/fission-bundle/ go build -o cmd/fission-cli/fission ./cmd/fission-cli/ + go build -o cmd/fetcher/fetcher ./cmd/fetcher/ + go build -o cmd/fetcher/builder ./cmd/builder/ -build-bundle: - CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o cmd/fission-bundle/fission-bundle ./cmd/fission-bundle/ +# install CLI binary to $PATH +install: build + mv cmd/fission-cli/fission $(GOPATH)/bin -build-image: - docker build --rm --tag "$(IMAGE):$(VERSION)" cmd/fission-bundle/ - -install: - go install ./cmd/fission-cli/ - -image: build-bundle build-image - -image-push: image - docker push "$(IMAGE):$(VERSION)" +# build images (environment images are not included) +image: + docker build -t fission-bundle -f cmd/fission-bundle/Dockerfile.fission-bundle . + docker build -t fetcher -f cmd/fetcher/Dockerfile.fission-fetcher . + docker build -t builder -f cmd/builder/Dockerfile.fission-builder . clean: - @rm -f fission-bundle/fission-bundle - @rm -f fission/fission + @rm -f cmd/fission-bundle/fission-bundle + @rm -f cmd/fission-cli/fission + @rm -f cmd/fetcher/fetcher + @rm -f cmd/fetcher/builder diff --git a/githooks/README.md b/githooks/README.md new file mode 100644 index 00000000..c77b786d --- /dev/null +++ b/githooks/README.md @@ -0,0 +1,7 @@ +# Git hooks + +* pre-push: Check, build and test the changes. + +```bash +$ cp githooks/* .git/hooks/ +``` diff --git a/githooks/pre-push b/githooks/pre-push new file mode 100755 index 00000000..22f2a369 --- /dev/null +++ b/githooks/pre-push @@ -0,0 +1,6 @@ +#!/bin/bash + +ROOT=`realpath $(dirname $0)/../..` +pushd $ROOT +make +popd diff --git a/hack/verify-govet.sh b/hack/verify-govet.sh index eef824d5..83ffea00 100755 --- a/hack/verify-govet.sh +++ b/hack/verify-govet.sh @@ -4,4 +4,4 @@ set -o errexit set -o nounset set -o pipefail -go vet -v $(go list ./...| grep -v vendor) +go vet -v $(go list ./...| grep -v "vendor" | grep -v "examples" | grep -v "demos" | grep -v "test") diff --git a/hack/verify-staticcheck.sh b/hack/verify-staticcheck.sh index 8f257c4e..7b7f1109 100755 --- a/hack/verify-staticcheck.sh +++ b/hack/verify-staticcheck.sh @@ -4,6 +4,4 @@ set -o errexit set -o nounset set -o pipefail -ROOT=`realpath $(dirname $0)/..` - -go list ./...| grep -v vendor | grep -v "examples" | grep -v "demos" | xargs -I@ staticcheck @ +go list ./...| grep -v vendor | grep -v "examples" | grep -v "demos" | grep -v "test" | xargs -I@ staticcheck @