This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
forked from codeclimate/test-reporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
197 lines (156 loc) · 5.19 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
.PHONY: test-docker build-docker build-linux-cgo release test-excoveralls
AWS ?= $(shell which aws)
SHA_SUM ?= $(shell which shasum)
GPG ?= $(shell which gpg)
TAR ?= $(shell which tar)
DOCKER_RUN ?= $(shell which docker) run --rm
PANDOC ?= $(shell which pandoc)
MAN_FILES = $(wildcard man/*.md)
MAN_PAGES = $(patsubst man/%.md,man/%,$(MAN_FILES))
PROJECT = github.com/codeclimate/test-reporter
VERSION ?= $(shell cat VERSIONING/VERSION)
BUILD_VERSION = $(shell git log -1 --pretty=format:'%H')
BUILD_TIME = $(shell date +%FT%T%z)
LDFLAGS = -ldflags "-X $(PROJECT)/version.Version=${VERSION} -X $(PROJECT)/version.BuildVersion=${BUILD_VERSION} -X $(PROJECT)/version.BuildTime=${BUILD_TIME}"
ARTIFACTS_OUTPUT = artifacts.tar.gz
define upload_artifacts
$(AWS) s3 cp \
--acl public-read \
--recursive \
--exclude "*" \
--include "test-reporter-$(1)-*" \
artifacts/bin/ s3://codeclimate/test-reporter/;
endef
define gen_signed_checksum
cd artifacts/bin && \
$(SHA_SUM) -a 256 test-reporter-$(VERSION)-$(1) > test-reporter-$(VERSION)-$(1).sha256 && \
$(GPG) --local-user $(GPG_CODECLIMATE_FINGERPRINT) --output test-reporter-$(VERSION)-$(1).sha256.sig --detach-sig test-reporter-$(VERSION)-$(1).sha256
endef
man/%: man/%.md
$(PANDOC) -s -t man $< -o $@
all: test-docker build-all $(MAN_PAGES)
test:
go test $(shell go list ./... | grep -v /vendor/)
benchmark:
go test -bench . $(shell go list ./... | grep -v /vendor/)
build:
if [ -z "${BUILD_TAGS}" ]; then \
go build -v ${LDFLAGS} -o $(PREFIX)bin/test-reporter$(BINARY_SUFFIX); \
else \
go build -v ${LDFLAGS} -tags ${BUILD_TAGS} -o $(PREFIX)bin/test-reporter$(BINARY_SUFFIX); \
fi
build-linux:
$(MAKE) build \
PREFIX=artifacts/ \
BINARY_SUFFIX=-$(VERSION)-linux-amd64 \
CGO_ENABLED=0
build-linux-arm64:
$(MAKE) build \
PREFIX=artifacts/ \
BINARY_SUFFIX=-$(VERSION)-linux-arm64 \
CGO_ENABLED=0 \
GOARCH=arm64
build-linux-cgo:
$(MAKE) build \
PREFIX=artifacts/ \
BINARY_SUFFIX=-$(VERSION)-netcgo-linux-amd64 \
CGO_ENABLED=1 \
BUILD_TAGS="netcgo"
build-linux-all:
$(MAKE) build-linux
$(MAKE) build-linux-arm64
$(MAKE) build-linux-cgo
build-darwin:
$(MAKE) build \
PREFIX=artifacts/ \
BINARY_SUFFIX=-$(VERSION)-darwin-amd64
build-docker: BINARY_SUFFIX ?= -$(VERSION)-$$GOOS-$$GOARCH
build-docker:
$(DOCKER_RUN) \
--env PREFIX=/artifacts/ \
--env BINARY_SUFFIX=${BINARY_SUFFIX} \
--env GOARCH \
--env GOOS \
--env GOPATH=/ \
--env CGO_ENABLED \
--volume "$(PWD)"/artifacts:/artifacts \
--volume "$(PWD)":"/src/$(PROJECT)":ro \
--workdir "/src/$(PROJECT)" \
golang:1.15 make build BUILD_TAGS=${BUILD_TAGS}
build-docker-linux:
$(MAKE) build-docker GOOS=linux GOARCH=amd64 CGO_ENABLED=0
build-docker-linux-arm64:
$(MAKE) build-docker GOOS=linux GOARCH=arm64 CGO_ENABLED=0
build-docker-linux-cgo:
$(MAKE) build-docker GOOS=linux GOARCH=amd64 CGO_ENABLED=1 \
BUILD_TAGS="netcgo" BINARY_SUFFIX=-$(VERSION)-netcgo-linux-amd64
test-docker:
$(DOCKER_RUN) \
--env GOPATH=/ \
--volume "$(PWD)":"/src/$(PROJECT)":ro \
--workdir "/src/$(PROJECT)" \
golang:1.15 make test
benchmark-docker:
$(DOCKER_RUN) \
--env GOPATH=/ \
--volume "$(PWD)":"/src/$(PROJECT)":ro \
--workdir "/src/$(PROJECT)" \
golang:1.15 make benchmark
test-simplecov:
docker build -f integration-tests/simplecov/Dockerfile .
test-lcov:
docker build -f integration-tests/lcov/Dockerfile .
test-covpy:
docker build -f integration-tests/coverage_py/Dockerfile .
test-gcov:
docker build -f integration-tests/gcov/Dockerfile .
test-gocov:
docker build -f integration-tests/gocov/Dockerfile .
test-clover:
docker build -f integration-tests/clover/Dockerfile .
test-cobertura:
docker build -f integration-tests/cobertura/Dockerfile .
test-excoveralls:
docker build -f integration-tests/excoveralls/Dockerfile .
test-dotcover:
docker build -f integration-tests/dotcover/Dockerfile .
publish-head:
$(call upload_artifacts,head)
publish-latest:
$(call upload_artifacts,latest)
publish-version:
$(call upload_artifacts,$(VERSION))
gen-linux-checksum:
$(call gen_signed_checksum,linux-amd64)
gen-linux-arm64-checksum:
$(call gen_signed_checksum,linux-arm64)
gen-linux-cgo-checksum:
$(call gen_signed_checksum,netcgo-linux-amd64)
gen-darwin-checksum:
$(call gen_signed_checksum,darwin-amd64)
clean:
sudo $(RM) -r ./artifacts
$(RM) $(MAN_PAGES)
tag:
$(TAR) -c -f ${ARTIFACTS_OUTPUT} ./artifacts/bin/test-reporter-${VERSION}-* && \
hub release create -a ${ARTIFACTS_OUTPUT} -m "v${VERSION}" ${VERSION}
# Must be run in a OS X machine. OS X binary is build natively.
manual-release:
$(MAKE) build-docker-linux
$(MAKE) build-docker-linux-arm64
$(MAKE) build-docker-linux-cgo
$(MAKE) build-darwin
$(MAKE) gen-linux-checksum
$(MAKE) gen-linux-arm64-checksum
$(MAKE) gen-linux-cgo-checksum
$(MAKE) gen-darwin-checksum
$(MAKE) build-docker-linux VERSION=latest
$(MAKE) build-docker-linux-arm64 VERSION=latest
$(MAKE) build-docker-linux-cgo VERSION=latest
$(MAKE) build-darwin VERSION=latest
$(MAKE) gen-linux-checksum VERSION=latest
$(MAKE) gen-linux-arm64-checksum VERSION=latest
$(MAKE) gen-linux-cgo-checksum VERSION=latest
$(MAKE) gen-darwin-checksum VERSION=latest
$(MAKE) publish-version
$(MAKE) publish-latest