-
Notifications
You must be signed in to change notification settings - Fork 42
/
Makefile
48 lines (37 loc) · 1.4 KB
/
Makefile
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
# Go parameters
GOCMD?=go
GO_VERSION=$(shell go list -m -f "{{.GoVersion}}")
PACKAGE_BASE=github.com/buildpacks/imgutil
all: test
install-goimports:
@echo "> Installing goimports..."
cd tools && $(GOCMD) install golang.org/x/tools/cmd/goimports
format: install-goimports
@echo "> Formating code..."
@goimports -l -w -local ${PACKAGE_BASE} .
install-golangci-lint:
@echo "> Installing golangci-lint..."
cd tools && $(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
lint: install-golangci-lint
@echo "> Linting code..."
@golangci-lint run -c golangci.yaml
tools/bcdhive_generator/.build: $(wildcard tools/bcdhive_generator/*)
ifneq ($(OS),Windows_NT)
@echo "> Building bcdhive-generator in Docker using current golang version"
docker build tools/bcdhive_generator --tag bcdhive-generator --build-arg go_version=$(GO_VERSION)
@touch tools/bcdhive_generator/.build
else
@echo "> Cannot generate on Windows"
endif
layer/bcdhive_generated.go: layer/windows_baselayer.go tools/bcdhive_generator/.build
ifneq ($(OS),Windows_NT)
$(GOCMD) generate ./...
else
@echo "> Cannot generate on Windows"
endif
test: layer/bcdhive_generated.go format lint
$(GOCMD) test -parallel=1 -count=1 -coverprofile=coverage.out -v ./...
codecov: test
$(GOCMD) tool cover -html=coverage.out
tidy:
$(GOCMD) mod tidy && cd tools && $(GOCMD) mod tidy -compat=1.17 && cd bcdhive_generator && $(GOCMD) mod tidy