Skip to content

Commit f9c0f6f

Browse files
SuperQbwplotka
authored andcommitted
Split build/publish in CircleCI (thanos-io#399)
* Split the test, build, and publish steps with CircleCI workflows. * Fixup `promu` target so it can be used outside of make. * Update git ignore list for promu use. * Update promu crossbuild list to avoid 32-bit builds. * Siplify publish step with workflow filter. Signed-off-by: Ben Kochie <superq@gmail.com>
1 parent b67aa3a commit f9c0f6f

File tree

4 files changed

+75
-15
lines changed

4 files changed

+75
-15
lines changed

.circleci/config.yml

+50-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# NOTE: Current plan gives 1500 build minutes per month.
22
version: 2
33
jobs:
4-
build:
4+
test:
55
docker:
66
# Available from https://hub.docker.com/r/circleci/golang/
77
- image: circleci/golang:1.10
@@ -32,15 +32,53 @@ jobs:
3232
echo "Skipping AWS tests."
3333
3434
make test
35+
36+
build:
37+
machine: true
38+
working_directory: /home/circleci/.go_workspace/src/github.com/improbable-eng/thanos
39+
steps:
40+
- checkout
41+
- run: make promu
42+
- run: make crossbuild
43+
- persist_to_workspace:
44+
root: .
45+
paths:
46+
- .build
47+
48+
publish_master:
49+
docker:
50+
# Available from https://hub.docker.com/r/circleci/golang/
51+
- image: circleci/golang:1.10
52+
working_directory: /go/src/github.com/improbable-eng/thanos
53+
steps:
54+
- checkout
55+
- setup_remote_docker:
56+
version: 17.07.0-ce
57+
- attach_workspace:
58+
at: .
59+
- run: ln -s .build/linux-amd64/thanos thanos
3560
- run: make docker
36-
- run:
37-
name: Run tests on generated Docker image
38-
command: |
39-
docker run thanos --help
40-
- deploy:
41-
name: Push Docker image
42-
command: |
43-
if [ "${CIRCLE_BRANCH}" == "master" ]; then
44-
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
45-
make docker-push
46-
fi
61+
- run: docker run thanos --help
62+
- run: docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}"
63+
- run: make docker-push
64+
65+
66+
workflows:
67+
version: 2
68+
thanos:
69+
jobs:
70+
- test:
71+
filters:
72+
tags:
73+
only: /.*/
74+
- build:
75+
filters:
76+
tags:
77+
only: /.*/
78+
- publish_master:
79+
requires:
80+
- test
81+
- build
82+
filters:
83+
branches:
84+
only: master

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ kube/.minikube
88

99
# Ignore e2e working dirs.
1010
data/
11+
12+
# Ignore promu artifacts.
13+
/.build
14+
/.release
15+
/.tarballs

.promu.yml

+6
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ build:
1111
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}}
1212
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
1313
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
14+
crossbuild:
15+
platforms:
16+
- linux/amd64
17+
- darwin/amd64
18+
- linux/arm64
19+
- windows/amd64

Makefile

+14-3
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,28 @@ errcheck:
3636
@echo ">> errchecking the code"
3737
@errcheck -verbose -exclude .errcheck_excludes.txt ./...
3838

39-
build: deps $(PROMU)
39+
build: deps promu
4040
@echo ">> building binaries"
4141
@$(PROMU) build --prefix $(PREFIX)
4242

43+
.PHONY: crossbuild
44+
crossbuild: deps promu
45+
@echo ">> crossbuilding all binaries"
46+
$(PROMU) crossbuild -v
47+
48+
.PHONY: tarball
49+
tarball: promu
50+
@echo ">> building release tarball"
51+
$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
52+
4353
$(GOIMPORTS):
4454
@echo ">> fetching goimports"
4555
@go get -u golang.org/x/tools/cmd/goimports
4656

47-
$(PROMU):
57+
.PHONY: promu
58+
promu:
4859
@echo ">> fetching promu"
49-
@go get -u github.com/prometheus/promu
60+
GOOS= GOARCH= go get -u github.com/prometheus/promu
5061

5162
$(DEP):
5263
@echo ">> fetching dep"

0 commit comments

Comments
 (0)