-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (66 loc) · 2.04 KB
/
Copy pathMakefile
File metadata and controls
86 lines (66 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := all
.DELETE_ON_ERROR:
.SUFFIXES:
DOCKER_CMD ?= docker
DOCKER_ARGS ?= --rm --user "$$(id -u)" -v "$${PWD}:/src" --workdir /src
# Project parameters
BINARY_NAME ?= floodgate
VERSION ?= $(shell git describe --tags --always --dirty --match=v* || (echo "command failed $$?"; exit 1))
IMAGE_NAME ?= docker.io/projectsyn/$(BINARY_NAME):$(VERSION)
# Antora variables
ANTORA_CMD ?= $(DOCKER_CMD) run $(DOCKER_ARGS) --volume "$${PWD}":/antora vshn/antora:1.3
ANTORA_OPTS ?= --cache-dir=.cache/antora
VALE_CMD ?= $(DOCKER_CMD) run $(DOCKER_ARGS) --volume "$${PWD}"/docs/modules:/pages vshn/vale:2.1.1
VALE_ARGS ?= --minAlertLevel=error --config=/pages/ROOT/pages/.vale.ini /pages
# Linting parameters
YAML_FILES ?= $(shell find . -type f -name '*.yaml' -or -name '*.yml')
YAMLLINT_ARGS ?= --no-warnings
YAMLLINT_CONFIG ?= .yamllint.yml
YAMLLINT_IMAGE ?= docker.io/cytopia/yamllint:latest
YAMLLINT_DOCKER ?= $(DOCKER_CMD) run $(DOCKER_ARGS) $(YAMLLINT_IMAGE)
# Go parameters
GOCMD ?= go
GOBUILD ?= $(GOCMD) build
GOCLEAN ?= $(GOCMD) clean
GOTEST ?= $(GOCMD) test
.PHONY: all
all: lint test build
.PHONY: generate
generate:
go generate ./...
.PHONY: build
build: generate
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -v \
-o $(BINARY_NAME) \
-ldflags "-X main.Version=$(VERSION) -X 'main.BuildDate=$(shell date)'" \
main.go
@echo built '$(VERSION)'
.PHONY: test
test: generate
$(GOTEST) -v -cover ./...
.PHONY: run
run: generate
go run main.go
.PHONY: clean
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
.PHONY: docker
docker:
DOCKER_BUILDKIT=1 docker build -t $(IMAGE_NAME) .
@echo built image $(IMAGE_NAME)
.PHONY: docs
docs: generate $(web_dir)/index.html
$(web_dir)/index.html: playbook.yml $(pages)
$(ANTORA_CMD) $(ANTORA_OPTS) $<
.PHONY: lint
lint: lint_yaml lint_adoc
.PHONY: lint_yaml
lint_yaml: $(YAML_FILES)
$(YAMLLINT_DOCKER) -f parsable -c $(YAMLLINT_CONFIG) $(YAMLLINT_ARGS) -- $?
.PHONY: lint_adoc
lint_adoc:
$(VALE_CMD) $(VALE_ARGS)