gopherss/Makefile

74 lines
1.9 KiB
Makefile
Raw Normal View History

2020-10-17 13:30:30 +00:00
.DEFAULT_GOAL := default
2020-10-17 19:57:26 +00:00
IMAGE ?= docker.cluster.fun/averagemarcus/gopherss:latest
2020-10-17 21:12:32 +00:00
PLATFORMS ?= linux/amd64
2020-10-17 19:57:26 +00:00
export DOCKER_CLI_EXPERIMENTAL=enabled
2020-10-17 13:30:30 +00:00
.PHONY: test # Run all tests, linting and format checks
test: lint check-format run-tests
.PHONY: lint # Perform lint checks against code
lint:
2020-10-17 19:57:26 +00:00
@go vet && golint -set_exit_status ./...
2020-10-17 13:30:30 +00:00
.PHONY: check-format # Checks code formatting and returns a non-zero exit code if formatting errors found
check-format:
2020-10-17 19:57:26 +00:00
@gofmt -e -l .
2020-10-17 13:30:30 +00:00
.PHONY: format # Performs automatic format fixes on all code
format:
2020-10-17 19:57:26 +00:00
@gofmt -s -w .
2020-10-17 13:30:30 +00:00
.PHONY: run-tests # Runs all tests
run-tests:
2020-10-17 19:57:26 +00:00
@go test
2020-10-17 13:30:30 +00:00
.PHONY: fetch-deps # Fetch all project dependencies
fetch-deps:
2020-10-17 19:57:26 +00:00
@go mod tidy
2020-10-17 13:30:30 +00:00
.PHONY: build # Build the project
build: lint check-format fetch-deps
2020-10-17 19:57:26 +00:00
@go build -o gopherss .
2020-10-17 13:30:30 +00:00
.PHONY: docker-build # Build the docker image
docker-build:
2020-10-17 19:57:26 +00:00
@docker buildx create --use --name=crossplat --node=crossplat && \
docker buildx build \
--output "type=docker,push=false" \
--tag $(IMAGE) \
.
2020-10-17 13:30:30 +00:00
.PHONY: docker-publish # Push the docker image to the remote registry
docker-publish:
2020-10-17 19:57:26 +00:00
@docker buildx create --use --name=crossplat --node=crossplat && \
docker buildx build \
--platform $(PLATFORMS) \
--output "type=image,push=true" \
--tag $(IMAGE) \
.
2020-10-17 13:30:30 +00:00
.PHONY: run # Run the application
run:
2020-10-17 19:57:26 +00:00
@go run .
2020-10-17 13:30:30 +00:00
.PHONY: ci # Perform CI specific tasks to perform on a pull request
ci:
@echo "⚠️ 'ci' unimplemented"
.PHONY: release # Release the latest version of the application
release:
2020-11-10 18:36:48 +00:00
@kubectl --namespace rss set image deployment rss web=docker.cluster.fun/averagemarcus/gopherss:$(SHA)
2020-10-17 13:30:30 +00:00
.PHONY: help # Show this list of commands
help:
2020-10-17 19:57:26 +00:00
@echo "gopherss"
2020-10-17 13:30:30 +00:00
@echo "Usage: make [target]"
@echo ""
@echo "target description" | expand -t20
@echo "-----------------------------------"
@grep '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \2/' | expand -t20
default: test build