Skip to content

Commit 3491a6b

Browse files
committed
Build tarballs for each OS introduce SHA-512
1 parent 5ef09ca commit 3491a6b

File tree

2 files changed

+44
-73
lines changed

2 files changed

+44
-73
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/bin/
22
/test/bin/
3-
/*.tar.gz
3+
/*.tar.gz*
44
ci.env
55
pr.env
66
junit*.xml
77
debug.test
8+
/output/

Makefile

Lines changed: 42 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414

1515
# Build the node-problem-detector image.
1616

17-
.PHONY: all build-container build-tar build push-container push-tar push \
18-
clean vet fmt version \
19-
Dockerfile build-binaries docker-builder build-in-docker
17+
.PHONY: all \
18+
vet fmt version test e2e-test \
19+
build-binaries build-container build-tar build \
20+
docker-builder build-in-docker push-container push-tar push clean
2021

2122
all: build
2223

24+
# PLATFORMS is the set of OS_ARCH that NPD can build against.
25+
PLATFORMS=linux_amd64 windows_amd64
26+
2327
# VERSION is the version of the binary.
2428
VERSION?=$(shell if [ -d .git ]; then echo `git describe --tags --dirty`; else echo "UNKNOWN"; fi)
2529

@@ -48,8 +52,9 @@ endif
4852
# PARALLEL specifies the number of parallel test nodes to run for e2e tests.
4953
PARALLEL?=3
5054

55+
NPD_NAME_VERSION?=node-problem-detector-$(VERSION)
5156
# TARBALL is the name of release tar. Include binary version by default.
52-
TARBALL?=node-problem-detector-$(VERSION).tar.gz
57+
TARBALL=$(NPD_NAME_VERSION).tar.gz
5358

5459
# IMAGE is the image name of the node problem detector container image.
5560
IMAGE:=$(REGISTRY)/node-problem-detector:$(TAG)
@@ -87,7 +92,7 @@ endif
8792

8893
ifeq ($(ENABLE_JOURNALD), 1)
8994
# Enable journald build tag.
90-
LINUX_BUILD_TAGS := $(BUILD_TAGS) journald
95+
LINUX_BUILD_TAGS := journald $(BUILD_TAGS)
9196
# Enable cgo because sdjournal needs cgo to compile. The binary will be
9297
# dynamically linked if CGO_ENABLED is enabled. This is fine because fedora
9398
# already has necessary dynamic library. We can not use `-extldflags "-static"`
@@ -112,23 +117,16 @@ fmt:
112117
version:
113118
@echo $(VERSION)
114119

115-
WINDOWS_AMD64_BINARIES = bin/windows_amd64/node-problem-detector.exe bin/windows_amd64/health-checker.exe
116-
WINDOWS_AMD64_TEST_BINARIES = test/bin/windows_amd64/problem-maker.exe
117-
LINUX_AMD64_BINARIES = bin/linux_amd64/node-problem-detector bin/linux_amd64/health-checker
118-
LINUX_AMD64_TEST_BINARIES = test/bin/linux_amd64/problem-maker
120+
BINARIES = bin/node-problem-detector bin/health-checker test/bin/problem-maker
121+
BINARIES_LINUX_ONLY =
119122
ifeq ($(ENABLE_JOURNALD), 1)
120-
LINUX_AMD64_BINARIES += bin/linux_amd64/log-counter
123+
BINARIES_LINUX_ONLY += bin/log-counter
121124
endif
122125

123-
WINDOWS_BINARIES = $(WINDOWS_AMD64_BINARIES) $(WINDOWS_AMD64_TEST_BINARIES)
124-
LINUX_BINARIES = $(LINUX_AMD64_BINARIES) $(LINUX_AMD64_TEST_BINARIES)
125-
126-
windows-binaries: $(WINDOWS_BINARIES)
126+
ALL_BINARIES = $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), ./$(binary)) $(foreach binary, $(BINARIES) $(BINARIES_LINUX_ONLY), output/linux_amd64/$(binary)) $(foreach binary, $(BINARIES), output/windows_amd64/$(binary).exe)
127+
ALL_TARBALLS = $(foreach platform, $(PLATFORMS), $(NPD_NAME_VERSION)-$(platform).tar.gz)
127128

128-
bin/windows_amd64/%.exe: $(PKG_SOURCES)
129-
ifeq ($(ENABLE_JOURNALD), 1)
130-
echo "Journald on Windows is not supported, use make ENABLE_JOURNALD=0 [TARGET]"
131-
endif
129+
output/windows_amd64/bin/%.exe: $(PKG_SOURCES)
132130
GOOS=windows GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
133131
-mod vendor \
134132
-o $@ \
@@ -137,17 +135,14 @@ endif
137135
./cmd/$(subst -,,$*)
138136
touch $@
139137

140-
./test/bin/windows_amd64/%.exe: $(PKG_SOURCES)
141-
ifeq ($(ENABLE_JOURNALD), 1)
142-
echo "Journald on Windows is not supported, use make ENABLE_JOURNALD=0 [TARGET]"
143-
endif
138+
output/windows_amd64/test/bin/%.exe: $(PKG_SOURCES)
144139
GOOS=windows GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
145140
-mod vendor \
146141
-o $@ \
147142
-tags "$(WINDOWS_BUILD_TAGS)" \
148143
./test/e2e/$(subst -,,$*)
149144

150-
bin/linux_amd64/%: $(PKG_SOURCES)
145+
output/linux_amd64/bin/%: $(PKG_SOURCES)
151146
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
152147
-mod vendor \
153148
-o $@ \
@@ -156,53 +151,20 @@ bin/linux_amd64/%: $(PKG_SOURCES)
156151
./cmd/$(subst -,,$*)
157152
touch $@
158153

159-
./test/bin/linux_amd64/%: $(PKG_SOURCES)
154+
output/linux_amd64/test/bin/%: $(PKG_SOURCES)
160155
GOOS=linux GOARCH=amd64 CGO_ENABLED=$(CGO_ENABLED) GO111MODULE=on go build \
161156
-mod vendor \
162157
-o $@ \
163158
-tags "$(LINUX_BUILD_TAGS)" \
164159
./test/e2e/$(subst -,,$*)
165160

166-
ifneq ($(ENABLE_JOURNALD), 1)
167-
bin/linux_amd64/log-counter:
168-
echo "Warning: log-counter requires journald, skipping."
169-
endif
170-
171-
# In the future these targets should be deprecated.
172-
./bin/log-counter: $(PKG_SOURCES)
173-
ifeq ($(ENABLE_JOURNALD), 1)
174-
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
175-
-mod vendor \
176-
-o bin/log-counter \
177-
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
178-
-tags "$(LINUX_BUILD_TAGS)" \
179-
cmd/logcounter/log_counter.go
180-
else
181-
echo "Warning: log-counter requires journald, skipping."
182-
endif
183-
184-
./bin/node-problem-detector: $(PKG_SOURCES)
185-
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
186-
-mod vendor \
187-
-o bin/node-problem-detector \
188-
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
189-
-tags "$(LINUX_BUILD_TAGS)" \
190-
./cmd/nodeproblemdetector
161+
./bin/%: output/linux_amd64/bin/%
162+
mkdir -p bin/
163+
cp $< $@
191164

192-
./test/bin/problem-maker: $(PKG_SOURCES)
193-
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
194-
-mod vendor \
195-
-o test/bin/problem-maker \
196-
-tags "$(LINUX_BUILD_TAGS)" \
197-
./test/e2e/problemmaker/problem_maker.go
198-
199-
./bin/health-checker: $(PKG_SOURCES)
200-
CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GO111MODULE=on go build \
201-
-mod vendor \
202-
-o bin/health-checker \
203-
-ldflags '-X $(PKG)/pkg/version.version=$(VERSION)' \
204-
-tags "$(LINUX_BUILD_TAGS)" \
205-
cmd/healthchecker/health_checker.go
165+
./test/bin/%: output/linux_amd64/test/bin/%
166+
mkdir -p test/bin/
167+
cp $< $@
206168

207169
test: vet fmt
208170
GO111MODULE=on go test -mod vendor -timeout=1m -v -race -short -tags "$(HOST_PLATFORM_BUILD_TAGS)" ./...
@@ -217,16 +179,25 @@ e2e-test: vet fmt build-tar
217179
-boskos-project-type=$(BOSKOS_PROJECT_TYPE) -job-name=$(JOB_NAME) \
218180
-artifacts-dir=$(ARTIFACTS)
219181

220-
build-binaries: ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker $(WINDOWS_BINARIES) $(LINUX_BINARIES)
182+
$(NPD_NAME_VERSION)-%.tar.gz: $(ALL_BINARIES) test/e2e-install.sh
183+
mkdir -p output/$*/ output/$*/test/
184+
cp -r config/ output/$*/
185+
cp test/e2e-install.sh output/$*/test/e2e-install.sh
186+
(cd output/$*/ && tar -zcvf ../../$@ *)
187+
sha512sum $@ > $@.sha512
188+
189+
build-binaries: $(ALL_BINARIES)
221190

222191
build-container: build-binaries Dockerfile
223192
docker build -t $(IMAGE) --build-arg BASEIMAGE=$(BASEIMAGE) --build-arg LOGCOUNTER=$(LOGCOUNTER) .
224193

225-
build-tar: ./bin/node-problem-detector ./bin/log-counter ./bin/health-checker ./test/bin/problem-maker
226-
tar -zcvf $(TARBALL) bin/ config/ test/e2e-install.sh test/bin/problem-maker
194+
$(TARBALL): $(NPD_NAME_VERSION)-linux_amd64.tar.gz
195+
cp $(NPD_NAME_VERSION)-linux_amd64.tar.gz $(TARBALL)
227196
sha1sum $(TARBALL)
228197
md5sum $(TARBALL)
229198

199+
build-tar: $(TARBALL) $(ALL_TARBALLS)
200+
230201
build: build-container build-tar
231202

232203
docker-builder:
@@ -243,13 +214,12 @@ push-container: build-container
243214

244215
push-tar: build-tar
245216
gsutil cp $(TARBALL) $(UPLOAD_PATH)/node-problem-detector/
217+
gsutil cp node-problem-detector-$(VERSION)-*.tar.gz* $(UPLOAD_PATH)/node-problem-detector/
246218

247219
push: push-container push-tar
248220

249221
clean:
250-
rm -f bin/health-checker
251-
rm -f bin/log-counter
252-
rm -f bin/node-problem-detector
253-
rm -f $(WINDOWS_AMD64_BINARIES) $(LINUX_AMD64_BINARIES)
254-
rm -f test/bin/problem-maker
255-
rm -f node-problem-detector-*.tar.gz
222+
rm -rf bin/
223+
rm -rf test/bin/
224+
rm -f node-problem-detector-*.tar.gz*
225+
rm -rf output/

0 commit comments

Comments
 (0)