Skip to content

Commit

Permalink
Clearer PHONYs
Browse files Browse the repository at this point in the history
Inspired by gitea README - this makes it a bit harder to forget
  • Loading branch information
bobheadxi committed May 17, 2018
1 parent 230f50c commit cb30c66
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -9,42 +7,51 @@ 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
make web-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)
Expand All @@ -53,19 +60,22 @@ 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)
make testdaemon
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) \
Expand All @@ -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) \
Expand All @@ -93,24 +104,29 @@ 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) .
docker push ubclaunchpad/inertia:$(RELEASE)

# 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)

0 comments on commit cb30c66

Please sign in to comment.