Skip to content

Commit

Permalink
Baked required deps in docker image for CircleCI.
Browse files Browse the repository at this point in the history
This should fix #1483

Also it should massively improve our CI time.

Signed-off-by: Bartek Plotka <bwplotka@gmail.com>
  • Loading branch information
bwplotka committed Sep 2, 2019
1 parent 8c33353 commit 3196b5f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ version: 2
jobs:
test:
docker:
# Available from https://hub.docker.com/r/circleci/golang/
- image: circleci/golang:1.12.5
# Build by Thanos make docker-ci
- image: quay.io/thanos/thanos-ci:v0.1.0
working_directory: /go/src/github.com/thanos-io/thanos
environment:
GO111MODULE: 'on'
Expand Down Expand Up @@ -60,8 +60,8 @@ jobs:

publish_master:
docker:
# Available from https://hub.docker.com/r/circleci/golang/
- image: circleci/golang:1.12.5
# Build by Thanos make docker-ci
- image: quay.io/thanos/thanos-ci:v0.1.0
working_directory: /go/src/github.com/thanos-io/thanos
environment:
GOBIN: "/go/bin"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ data/
website/public/
website/docs-pre-processed/
!website/data

tmp/bin
5 changes: 5 additions & 0 deletions Dockerfile.thanos-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Available from https://hub.docker.com/r/circleci/golang/
FROM circleci/golang:1.12.5

# Match GOBIN path used by CircleCI in .circleci/config.yaml
COPY tmp/bin /go/bin
41 changes: 31 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ ME ?= $(shell whoami)

# Limited prom version, because testing was not possible. This should fix it: https://github.com/thanos-io/thanos/issues/758
PROM_VERSIONS ?= v2.4.3 v2.5.0 v2.8.1 v2.9.2
PROMS ?= $(GOBIN)/prometheus-v2.4.3 $(GOBIN)/prometheus-v2.5.0 $(GOBIN)/prometheus-v2.8.1 $(GOBIN)/prometheus-v2.9.2

ALERTMANAGER_VERSION ?= v0.15.2
ALERTMANAGER ?= $(GOBIN)/alertmanager-$(ALERTMANAGER_VERSION)
MINIO_SERVER_VERSION ?= RELEASE.2018-10-06T00-15-16Z

# fetch_go_bin_version downloads (go gets) the binary from specific version and installs it in $(GOBIN)/<bin>-<version>
Expand Down Expand Up @@ -178,7 +180,10 @@ tarballs-release: $(PROMU)
# test runs all Thanos golang tests against each supported version of Prometheus.
.PHONY: test
test: export GOCACHE= $(TMP_GOPATH)/gocache
test: check-git test-deps
test: check-git install-deps
@echo ">> install thanos GOOPTS=${GOOPTS}"
# Thanos binary is required by e2e tests.
@go install github.com/thanos-io/thanos/cmd/thanos
# Be careful on GOCACHE. Those tests are sometimes using built Thanos/Prometheus binaries directly. Don't cache those.
@rm -rf ${GOCACHE}
@echo ">> running all tests. Do export THANOS_SKIP_GCS_TESTS='true' or/and THANOS_SKIP_S3_AWS_TESTS='true' or/and THANOS_SKIP_AZURE_TESTS='true' and/or THANOS_SKIP_SWIFT_TESTS='true' and/or THANOS_SKIP_TENCENT_COS_TESTS='true' if you want to skip e2e tests against real store buckets"
Expand All @@ -202,15 +207,22 @@ test-local:
@echo ">> Skipping GCE tests"
$(MAKE) test-only-gcs

# test-deps installs dependency for e2e tets.
# It installs current Thanos, supported versions of Prometheus and alertmanager to test against in e2e.
.PHONY: test-deps
test-deps:
@echo ">> install thanos GOOPTS=${GOOPTS}"
@go install github.com/thanos-io/thanos/cmd/thanos
$(foreach ver,$(PROM_VERSIONS),$(call fetch_go_bin_version,github.com/prometheus/prometheus/cmd/prometheus,$(ver)))
$(call fetch_go_bin_version,github.com/prometheus/alertmanager/cmd/alertmanager,$(ALERTMANAGER_VERSION))
$(call fetch_go_bin_version,github.com/minio/minio,$(MINIO_SERVER_VERSION))
# install-deps installs dependency for e2e tets.
# It installs supported versions of Prometheus and alertmanager to test against in e2e.
.PHONY: install-deps
install-deps: $(ALERTMANAGER) $(MINO_SERVER) $(PROMS)

.PHONY: docker-ci
docker-ci: install-deps
# Copy all to tmp local dir as this is required by docker.
@rm -rf ./tmp/bin
@mkdir -p ./tmp/bin
@cp -r $(GOBIN) ./tmp/bin
@docker build -t thanos-ci -f Dockerfile.thanos-ci .
@echo ">> pushing thanos-ci image"
# To be run by Thanos maintainer.
@docker tag "thanos-ci" "quay.io/thanos/thanos-ci:v0.1.0"
@docker push "quay.io/thanos/thanos-ci:v0.1.0"

# tooling deps. TODO(bwplotka): Pin them all to certain version!
.PHONY: check-git
Expand Down Expand Up @@ -277,6 +289,15 @@ $(GOLANGCILINT):
$(MISSPELL):
$(call fetch_go_bin_version,github.com/client9/misspell/cmd/misspell,$(MISSPELL_VERSION))

$(ALERTMANAGER):
$(call fetch_go_bin_version,github.com/prometheus/alertmanager/cmd/alertmanager,$(ALERTMANAGER_VERSION))

$(MINO_SERVER):
$(call fetch_go_bin_version,github.com/minio/minio,$(MINIO_SERVER_VERSION))

$(PROMS):
$(foreach ver,$(PROM_VERSIONS),$(call fetch_go_bin_version,github.com/prometheus/prometheus/cmd/prometheus,$(ver)))

$(PROTOC):
@mkdir -p $(TMP_GOPATH)
@echo ">> fetching protoc@${PROTOC_VERSION}"
Expand Down

0 comments on commit 3196b5f

Please sign in to comment.