This repository was archived by the owner on Jan 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
65 lines (50 loc) · 2.59 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
REPORTS_DIR = build/reports
all: go-update go-generate go-all-tests go-build-bin go-multiple-os-distributions
go-all-tests: go-lint go-unit-tests
clean:
rm -Rf "${REPORTS_DIR}"
go-dependencies:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/onsi/ginkgo/v2/ginkgo@latest
go install go.uber.org/mock/mockgen@latest
go-update: go-dependencies
go mod tidy && go get -t -v -u ./...
go-generate:
go generate ./...
$(MAKE) go-update
go-lint:
golangci-lint run
go-unit-tests:
ginkgo -race --cover --coverprofile="ginkgo-coverage-unit.out" --junit-report="junit-report.xml" ./...
mkdir -p "${REPORTS_DIR}"
cp "junit-report.xml" "${REPORTS_DIR}/junit-report.xml"
grep -v ".mock.go" "ginkgo-coverage-unit.out" >"${REPORTS_DIR}/ginkgo-coverage-unit.out"
go tool cover -func "${REPORTS_DIR}/ginkgo-coverage-unit.out" -o "${REPORTS_DIR}/coverage-unit.out"
go tool cover -html "${REPORTS_DIR}/ginkgo-coverage-unit.out" -o "${REPORTS_DIR}/coverage-unit.html"
go-prebuild:
echo "make target dir for build: ${targetDir}"
rm -Rf "${targetDir}" 2>/dev/null
mkdir -p "${targetDir}"
go-build:
$(MAKE) go-prebuild targetDir="${targetDir}"
echo "build version='${version}' to target dir: ${targetDir}"
GOOS="${targetOS}" GOARCH="${targetARCH}" go build -trimpath -pgo auto -ldflags "-w -extldflags '-static' -X 'github.com/dev.itbasis.sdkm/internal/version.Version=${version}'" -tags musl -o "${targetDir}/sdkm" "./cmd/main.go"
$(MAKE) copy-docs targetDir="${targetDir}"
copy-docs:
cp ./README.adoc ./CHANGELOG.adoc "${targetDir}/"
cp -R ./changelog "${targetDir}/"
go-build-bin:
$(eval targetOS=$(uname -s | tr '[:upper:]' '[:lower:]'))
$(eval targetARCH=$(uname -m))
$(MAKE) go-build targetDir="bin" targetOS="${targetOS}" targetARCH="${targetARCH}"
go-multiple-os-distributions:
$(MAKE) go-make-distribution targetDir="build/darwin-amd64" targetOS="darwin" targetARCH="amd64"
$(MAKE) go-make-distribution targetDir="build/darwin-arm64" targetOS="darwin" targetARCH="arm64"
$(MAKE) go-make-distribution targetDir="build/linux-ppc64" targetOS="linux" targetARCH="ppc64"
$(MAKE) go-make-distribution targetDir="build/linux-arm64" targetOS="linux" targetARCH="arm64"
#$(MAKE) go-make-distribution targetDir="build/windows-amd64" targetOS="windows" targetARCH="amd64"
#$(MAKE) go-make-distribution targetDir="build/windows-arm64" targetOS="windows" targetARCH="arm64"
go-make-distribution:
mkdir -p "distributions"
$(MAKE) go-build targetDir="${targetDir}" targetOS="${targetOS}" targetARCH="${targetARCH}"
tar -zcf "distributions/${targetOS}-${targetARCH}.tar.gz" -C "${targetDir}/" .