diff --git a/.circleci/config.yml b/.circleci/config.yml index 9abe4c29..b56e7f5a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,7 +4,7 @@ version: 2 jobs: test: docker: - - image: circleci/golang:1.10 + - image: circleci/golang:1.11 working_directory: /go/src/github.com/prometheus/node_exporter steps: @@ -27,13 +27,14 @@ jobs: working_directory: /home/circleci/.go_workspace/src/github.com/prometheus/node_exporter environment: - DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.10-base + DOCKER_TEST_IMAGE_NAME: quay.io/prometheus/golang-builder:1.11-base REPO_PATH: github.com/prometheus/node_exporter steps: - checkout - run: make promu - - run: promu crossbuild -v --go 1.10 + - run: promu --config .promu-no-cgo.yml crossbuild -v --go 1.11 + - run: promu --config .promu-cgo.yml crossbuild -v --go 1.11 - persist_to_workspace: root: . paths: @@ -58,7 +59,7 @@ jobs: docker_hub_master: docker: - - image: circleci/golang:1.10 + - image: circleci/golang:1.11 working_directory: /go/src/github.com/prometheus/node_exporter steps: @@ -77,7 +78,7 @@ jobs: docker_hub_release_tags: docker: - - image: circleci/golang:1.10 + - image: circleci/golang:1.11 working_directory: /go/src/github.com/prometheus/node_exporter steps: diff --git a/.promu-cgo.yml b/.promu-cgo.yml new file mode 100644 index 00000000..adb6d198 --- /dev/null +++ b/.promu-cgo.yml @@ -0,0 +1,24 @@ +go: + cgo: true +repository: + path: github.com/prometheus/node_exporter +build: + binaries: + - name: node_exporter + flags: -a -tags 'netgo static_build' + ldflags: | + -X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}} + -X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}} + -X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}} + -X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}} + -X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}} +tarball: + files: + - LICENSE + - NOTICE +crossbuild: + platforms: + - darwin/amd64 + - darwin/386 + - netbsd/amd64 + - netbsd/386 diff --git a/.promu.yml b/.promu-no-cgo.yml similarity index 89% rename from .promu.yml rename to .promu-no-cgo.yml index a607eafd..2375a868 100644 --- a/.promu.yml +++ b/.promu-no-cgo.yml @@ -1,5 +1,3 @@ -go: - cgo: true repository: path: github.com/prometheus/node_exporter build: @@ -20,10 +18,6 @@ crossbuild: platforms: - linux/amd64 - linux/386 - - darwin/amd64 - - darwin/386 - - netbsd/amd64 - - netbsd/386 - linux/arm - linux/arm64 - linux/mips diff --git a/Makefile b/Makefile index 6cd5e0f6..835a4070 100644 --- a/Makefile +++ b/Makefile @@ -26,24 +26,41 @@ DOCKERFILE ?= Dockerfile STATICCHECK_IGNORE = ifeq ($(OS),Windows_NT) - OS_detected := Windows + OS_detected := Windows else - OS_detected := $(shell uname -s) + OS_detected := $(shell uname -s) endif ifeq ($(GOHOSTARCH),amd64) ifeq ($(OS_detected),$(filter $(OS_detected),Linux FreeBSD Darwin Windows)) - # Only supported on amd64 - test-flags := -race - endif + # Only supported on amd64 + test-flags := -race + endif endif ifeq ($(OS_detected), Linux) - test-e2e := test-e2e + test-e2e := test-e2e else - test-e2e := skip-test-e2e + test-e2e := skip-test-e2e endif +# Use CGO for non-Linux builds. +ifeq ($(GOOS), linux) + PROMU_CONF ?= .promu-no-cgo.yml +else + ifndef GOOS + ifeq ($(OS_detected), Linux) + PROMU_CONF ?= .promu-no-cgo.yml + else + PROMU_CONF ?= .promu-cgo.yml + endif + else + PROMU_CONF ?= .promu-cgo.yml + endif +endif + +PROMU := $(FIRST_GOPATH)/bin/promu --config $(PROMU_CONF) + e2e-out = collector/fixtures/e2e-output.txt ifeq ($(MACH), ppc64le) e2e-out = collector/fixtures/e2e-64k-page-output.txt