From cb30c6646a746d4d53200c73a3447958cf8d47de Mon Sep 17 00:00:00 2001 From: Robert Lin Date: Wed, 16 May 2018 22:36:46 -0700 Subject: [PATCH] Clearer PHONYs Inspired by gitea README - this makes it a bit harder to forget --- Makefile | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 94965eb2..2ddd8ff4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,3 @@ -.PHONY: ls inertia inertia-tagged clean test test-v test-all test-integration test-integration-fast testenv testdaemon daemon bootstrap web-deps web-run web-build - TAG = `git describe --tags` SSH_PORT = 22 VPS_VERSION = latest @@ -9,10 +7,12 @@ RELEASE = canary all: deps bootstrap inertia # List all commands +.PHONY: ls ls: @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs # Sets up all dependencies +.PHONY: deps deps: go get -u github.com/jteeuwen/go-bindata/... dep ensure @@ -20,31 +20,38 @@ deps: bash test/deps.sh # Install Inertia with release version +.PHONY: inertia inertia: go install -ldflags "-X main.Version=$(RELEASE)" # Install Inertia with git tag as release version +.PHONY: inertia-tagged inertia-tagged: go install -ldflags "-X main.Version=$(TAG)" # Remove Inertia binaries +.PHONY: clean clean: rm -f ./inertia find . -type f -name inertia.\* -exec rm {} \; +.PHONY: lint lint: PATH=$(PATH):./bin bash -c './bin/gometalinter --vendor --deadline=60s ./...' # Run unit test suite +.PHONY: test test: go test ./... -short -ldflags "-X main.Version=test" --cover # Run unit test suite verbosely +.PHONY: test-v test-v: go test ./... -short -ldflags "-X main.Version=test" -v --cover # Run unit and integration tests - creates fresh test VPS and test daemon beforehand # Also attempts to run linter +.PHONY: test-all test-all: make lint make testenv VPS_OS=$(VPS_OS) VPS_VERSION=$(VPS_VERSION) @@ -53,6 +60,7 @@ test-all: go test ./... -ldflags "-X main.Version=test" --cover # Run integration tests verbosely - creates fresh test VPS and test daemon beforehand +.PHONY: test-integration test-integration: go clean -testcache make testenv VPS_OS=$(VPS_OS) VPS_VERSION=$(VPS_VERSION) @@ -60,12 +68,14 @@ test-integration: go test ./... -v -run 'Integration' -ldflags "-X main.Version=test" --cover # Run integration tests verbosely without recreating test VPS +.PHONY: test-integration-fast test-integration-fast: go clean -testcache make testdaemon go test ./... -v -run 'Integration' -ldflags "-X main.Version=test" --cover # Create test VPS +.PHONY: testenv testenv: docker stop testvps || true && docker rm testvps || true docker build -f ./test/vps/Dockerfile.$(VPS_OS) \ @@ -76,6 +86,7 @@ testenv: # Create test daemon and scp the image to the test VPS for use. # Requires Inertia version to be "test" +.PHONY: testdaemon testdaemon: rm -f ./inertia-daemon-image docker build --build-arg INERTIA_VERSION=$(TAG) \ @@ -93,6 +104,7 @@ testdaemon: # Creates a daemon release and pushes it to Docker Hub repository. # Requires access to the UBC Launch Pad Docker Hub. +.PHONY: daemon daemon: docker build --build-arg INERTIA_VERSION=$(RELEASE) \ -t ubclaunchpad/inertia:$(RELEASE) . @@ -100,17 +112,21 @@ daemon: # Recompiles assets. Use whenever a script in client/bootstrap is # modified. +.PHONY: bootstrap bootstrap: go-bindata -o client/bootstrap.go -pkg client client/bootstrap/... # Install Inertia Web dependencies. Use PACKAGE to install something. +.PHONY: web-deps web-deps: (cd ./daemon/web; npm install $(PACKAGE)) # Run local development instance of Inertia Web. +.PHONY: web-run web-run: (cd ./daemon/web; npm start) # Build and minify Inertia Web. +.PHONY: web-build web-build: (cd ./daemon/web; npm install --production; npm run build)