-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
64 lines (54 loc) · 1.71 KB
/
Makefile
File metadata and controls
64 lines (54 loc) · 1.71 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
# cSpell:ignore trimpath coverprofile
CI = $(shell env | grep ^CI=)
VERSION = 0.0.0
SUFFIX =
TOOL_VERSION = $(shell grep '^golang ' .tool-versions | sed 's/golang //')
MOD_VERSION = $(shell grep '^go ' go.mod | sed 's/go //')
clean:
@find build -type f ! -name .gitignore -exec rm {} +
@find build -type d -mindepth 1 -exec rmdir {} +
build: clean
go build \
-trimpath \
-ldflags "-s -w -X github.com/codereaper/lane/cmd.versionString=$(VERSION)" \
-o build/bin/
cp LICENSE build/bin/LICENSE.txt
update-docs: build
@mkdir -p docs/generated
build/bin/lane documentation -o docs/generated
package: build
cd build/bin && tar -cJvf ../lane-$(VERSION)$(SUFFIX).tar.xz *
cd build && sha512sum lane-$(VERSION)$(SUFFIX).tar.xz > lane-$(VERSION)$(SUFFIX).tar.xz.sha512sum
tidy: clean
go fmt
go mod tidy
ifeq ($(strip $(CI)),)
@git diff --quiet --exit-code || echo 'Warning: Workplace is dirty'
else
@git diff --quiet --exit-code || (echo 'Error: Workplace is dirty'; exit 1)
endif
unit-tests:
go test -timeout 10s -p 1 -coverprofile=build/coverage.out ./internal/...
ifeq ($(strip $(GITHUB_STEP_SUMMARY)),)
go tool cover -html=build/coverage.out -o build/coverage.html
go tool cover -func=build/coverage.out
else
{ \
echo '## Code Coverage'; \
echo '|File|Method|Coverage|'; \
echo '|---|---|--:|'; \
go tool cover -func=build/coverage.out | awk -F'\t+' 'BEGIN {OFS=" | "} {print "| " $$1, $$2, $$3 " |"}'; \
} | tee -a $(GITHUB_STEP_SUMMARY)
endif
smoke-test:
ifneq (,$(wildcard credentials.json))
go run ./... translations list -c credentials.json
endif
@exit 0
verify-version:
ifneq ($(TOOL_VERSION),$(MOD_VERSION))
@echo 'Mismatched go versions'
@exit 1
endif
@exit 0
test: verify-version tidy unit-tests smoke-test