-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (77 loc) · 2.42 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
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
87
88
89
GO ?= go
GOFMT ?= gofmt "-s"
GO_VERSION=$(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)
PACKAGES ?= $(shell $(GO) list ./...)
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)
GOFILES := $(shell find . -name "*.go")
TESTFOLDER := $(shell $(GO) list ./... | grep -E 'utils$$')
DOCKER ?= docker
TEST_FILES := $(shell find . -name '*_test.go')
.PHONY: test
test:
@echo "Starting test process..."
@mkdir -p coverage # Ensure the coverage directory exists
@packages=$$(go list ./...); \
for pkg in $${packages}; do \
echo "Running tests in $${pkg}"; \
$(GO) test -v $(TESTTAGS) -covermode=count -coverprofile="coverage/$${pkg##*/}.out" "$${pkg}"; \
done
@echo "Combining coverage profiles..."
gocovmerge coverage/*.out > coverage/merged.out
@echo "Finished test process."
.PHONY: fmt
fmt:
$(GOFMT) -w $(GOFILES)
.PHONY: fmt-check
fmt-check:
@diff=$$($(GOFMT) -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;
.PHONY: lint
lint:
$(shell golangci-lint run ./...)
.PHONY: clean
clean:
@find . -name 'profile.out' -exec rm -f {} +
$(shell rm -rf bin)
$(shell rm tmp.out)
$(shell rm -rf utils/*temp*)
$(shell rm -rf output)
$(shell rm coverage.out)
$(shell rm sbom-utilities)
$(shell rm -rf build)
$(shell rm *-bomber-results.*)
$(shell rm package.json)
$(shell rm package-lock.json)
$(shell rm -rf node_modules)
$(shell rm -rf coverage)
.PHONY: build
build:
$(GO) build -o bin/sbom-utils
.PHONY: docker
docker:
$(DOCKER) build --build-arg ARCH=arm64 --tag sbom-utilities-pipe:dev .
.PHONY: docker-amd64
docker-amd64:
$(DOCKER) buildx build --build-arg ARCH=amd64 --platform linux/amd64 --tag sbom-utilities-pipe:dev .
.PHONY: docker-run
docker-run:
$(DOCKER) run --rm -it --workdir /tmp -v $(PWD)/examples:/tmp/examples -v $(PWD)/build:/tmp/build --env-file variables.list sbom-utilities-pipe:dev
.PHONY: docker-debug
docker-debug:
$(DOCKER) run --rm -it --workdir /tmp -v $(PWD)/examples:/tmp/examples -v $(PWD)/build:/tmp/build --env-file variables.list --entrypoint bash sbom-utilities-pipe:dev
.PHONY: docker-lint
docker-lint:
$(DOCKER) run --rm -it \
-v "$(shell pwd)":/build \
--workdir /build \
hadolint/hadolint:v2.12.0-alpine hadolint Dockerfile*
.PHONY: markdown-lint
markdown-lint:
$(DOCKER) run --rm -it \
-v "$(shell pwd)":/build \
--workdir /build \
markdownlint/markdownlint:0.13.0 *.md