-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
134 lines (104 loc) · 6.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
BINARY=/out/gopogh
GIT_TAG=`git describe --tags`
COMMIT_NO := $(shell git rev-parse HEAD 2> /dev/null || true)
BUILD ?= $(if $(shell git status --porcelain --untracked-files=no),"${COMMIT_NO}-dirty","${COMMIT_NO}")
LDFLAGS :=-X github.com/medyagh/gopogh/pkg/report.Build=${BUILD} -X github.com/medyagh/gopogh/pkg/report.version=${GIT_TAG}
MK_REPO=github.com/kubernetes/minikube/
DUMMY_COMMIT_NUM=0c07e808219403a7241ee5a0fc6a85a897594339
DUMMY_COMMIT2_NUM=0168d63fc8c165681b1cad1801eadd6bbe2c8a5c
BUILD_GOPOGH := CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -a -o
GOPOGH_CMD := github.com/medyagh/gopogh/cmd/gopogh
.PHONY: build
build: out/gopogh
.PHONY: out/gopogh
out/gopogh:
$(BUILD_GOPOGH) $@ $(GOPOGH_CMD)
.PHONY: out/gopogh-darwin-arm64
out/gopogh-darwin-arm64:
GOOS=darwin GOARCH=arm64 $(BUILD_GOPOGH) $@ $(GOPOGH_CMD)
.PHONY: out/gopogh-darwin-amd64
out/gopogh-darwin-amd64:
GOOS=darwin GOARCH=amd64 $(BUILD_GOPOGH) $@ $(GOPOGH_CMD)
.PHONY: out/gopogh-linux-amd64
out/gopogh-linux-amd64:
GOOS=linux GOARCH=amd64 $(BUILD_GOPOGH) $@ $(GOPOGH_CMD)
.PHONY: out/gopogh-linux-arm
out/gopogh-linux-arm:
GOOS=linux GOARCH=arm $(BUILD_GOPOGH) $@ $(GOPOGH_CMD)
.PHONY: out/gopogh-linux-arm64
out/gopogh-linux-arm64:
GOOS=linux GOARCH=arm64 $(BUILD_GOPOGH) $@ $(GOPOGH_CMD)
.PHONY: out/gopogh.exe
out/gopogh.exe:
GOOS=windows GOARCH=amd64 $(BUILD_GOPOGH) $@ $(GOPOGH_CMD)
GOPOGH_SERVER_CMD := github.com/medyagh/gopogh/cmd/gopogh-server
.PHONY: server
server: out/gopogh-server
.PHONY: out/gopogh-server
out/gopogh-server:
$(BUILD_GOPOGH) $@ $(GOPOGH_SERVER_CMD)
.PHONY: out/gopogh-server-darwin-arm64
out/gopogh-server-darwin-arm64:
GOOS=darwin GOARCH=arm64 $(BUILD_GOPOGH) $@ $(GOPOGH_SERVER_CMD)
.PHONY: out/gopogh-server-darwin-amd64
out/gopogh-server-darwin-amd64:
GOOS=darwin GOARCH=amd64 $(BUILD_GOPOGH) $@ $(GOPOGH_SERVER_CMD)
.PHONY: out/gopogh-server-linux-amd64
out/gopogh-server-linux-amd64:
GOOS=linux GOARCH=amd64 $(BUILD_GOPOGH) $@ $(GOPOGH_SERVER_CMD)
.PHONY: out/gopogh-server-linux-arm
out/gopogh-server-linux-arm:
GOOS=linux GOARCH=arm $(BUILD_GOPOGH) $@ $(GOPOGH_SERVER_CMD)
.PHONY: out/gopogh-server-linux-arm64
out/gopogh-server-linux-arm64:
GOOS=linux GOARCH=arm64 $(BUILD_GOPOGH) $@ $(GOPOGH_SERVER_CMD)
.PHONY: out/gopogh-server.exe
out/gopogh-server.exe:
GOOS=windows GOARCH=amd64 $(BUILD_GOPOGH) $@ $(GOPOGH_SERVER_CMD)
# gopogh requires a json input, uses go tool test2json to convert to json
generate_json:
go tool test2json -t < ./testdata/minikube-logs.txt > ./testdata/minikube-logs.json
.PHONY: test
test: clean build
.${BINARY} -name "KVM Linux" -repo "${MK_REPO}" -pr "6096" -in "testdata/minikube-logs.json" -out_html "./out/output.html" -out_summary out/output_summary.json -details "${DUMMY_COMMIT_NUM}"
.${BINARY} -name "KVM Linux" -repo "${MK_REPO}" -pr "6096" -in "testdata/Docker_Linux.json" -out_html "./out/output2.html" -out_summary out/output2_summary.json -details "${DUMMY_COMMIT_NUM}"
.${BINARY} -name "KVM Linux" -repo "${MK_REPO}" -pr "6096" -in "testdata/Docker_Linux.json" -out_html "./out/output2NoSummary.html" -details "${DUMMY_COMMIT_NUM}"
.PHONY: testdb
testdb: export DB_BACKEND=sqlite
testdb: export DB_PATH=out/testdb/output_db.db
testdb: clean build
.${BINARY} -name "KVM Linux" -repo "${MK_REPO}" -pr "6096" -in "testdata/minikube-logs.json" -out_html "./out/output.html" -out_summary out/output_summary.json -db_path out/testdb/output_sqlite_summary.db -details "${DUMMY_COMMIT_NUM}"
.${BINARY} -name "KVM Linux" -repo "${MK_REPO}" -pr "6096" -in "testdata/Docker_Linux.json" -out_html "./out/output2.html" -out_summary out/output2_summary.json -db_path out/testdb/output2_sqlite_summary.db -details "${DUMMY_COMMIT_NUM}"
.${BINARY} -name "KVM Linux" -repo "${MK_REPO}" -pr "6096" -in "testdata/Docker_Linux.json" -out_html "./out/output2NoDBPath.html" -details "${DUMMY_COMMIT_NUM}"
.${BINARY} -name "Docker MacOS" -repo "${MK_REPO}" -pr "16569" -in "testdata/testdb/Docker_macOS.json" -out_html "./out/docker_macOS_output.html" -details "${DUMMY_COMMIT2_NUM}"
.${BINARY} -name "KVM Linux containerd" -repo "${MK_REPO}" -pr "16569" -in "testdata/testdb/KVM_Linux_containerd.json" -out_html "./out/kvm_linux_containerd_output.html" -details "${DUMMY_COMMIT2_NUM}"
.${BINARY} -name "QEMU MacOS" -repo "${MK_REPO}" -pr "16569" -in "testdata/testdb/QEMU_macOS.json" -out_html "./out/qemu_macos_output.html" -details "${DUMMY_COMMIT2_NUM}"
.PHONY: testpgdb
testpgdb: export DB_BACKEND=postgres
testpgdb: export DB_PATH='host=k8s-minikube:us-west1:flake-rate user=postgres dbname=flakedbdev password=${DB_PASS}'
testpgdb: clean build
.${BINARY} -name "KVM Linux" -repo "${MK_REPO}" -pr "6096" -in "testdata/minikube-logs.json" -out_html "./out/output.html" -out_summary out/output_summary.json -details "${DUMMY_COMMIT_NUM}" -use_cloudsql
.${BINARY} -name "Docker MacOS" -repo "${MK_REPO}" -pr "16569" -in "testdata/testdb/Docker_macOS.json" -out_html "./out/docker_macOS_output.html" -details "${DUMMY_COMMIT2_NUM}" -use_cloudsql
.${BINARY} -name "KVM Linux containerd" -repo "${MK_REPO}" -pr "16569" -in "testdata/testdb/KVM_Linux_containerd.json" -out_html "./out/kvm_linux_containerd_output.html" -details "${DUMMY_COMMIT2_NUM}" -use_cloudsql
.${BINARY} -name "QEMU MacOS" -repo "${MK_REPO}" -pr "16569" -in "testdata/testdb/QEMU_macOS.json" -out_html "./out/qemu_macos_output.html" -details "${DUMMY_COMMIT2_NUM}" -use_cloudsql
.PHONY: cross
cross: out/gopogh-linux-amd64 out/gopogh-darwin-amd64 out/gopogh-darwin-arm64 out/gopogh.exe out/gopogh-linux-arm64 out/gopogh-linux-arm
.PHONY: lint
lint:
golangci-lint run --enable gofmt,goimports,gocritic,revive,gocyclo,misspell,nakedret,stylecheck,unconvert,unparam,dogsled
.PHONY: clean
clean:
rm -rf out
.PHONY: build-image
build-image:
docker build -t local/gopogh:latest .
.PHONY: test-in-docker
test-in-docker:
rm ./testdata/docker-test/testout.json || true
rm ./testdata/docker-test/testout.html || true
docker run -it -e NAME="${JOB_NAME} ${GITHUB_REF}" -e REPO="${GITHUB_REPOSITORY}" -e DETAILS="${GITHUB_SHA}" -v $(CURDIR)/testdata/docker-test:/data local/gopogh ./text2html.sh
.PHONY: azure_blob_connection_string
azure_blob_connection_string: ## set this env export AZURE_STORAGE_CONNECTION_STRING=$(az storage account show-connection-string -n $AZ_STORAGE -g $AZ_RG --query connectionString -o tsv)
az storage account show-connection-string -n ${AZ_STORAGE} -g ${AZ_RG} --query connectionString -o tsv
load-fake-db:
./hack/fakedb.sh $(RECORD_PATH)