Update build (#1081)

* Update build

* Only use CGO when building non-Linux.
* Update build to Go 1.11
* Use tab indenting consistently.

Signed-off-by: Ben Kochie <superq@gmail.com>
This commit is contained in:
Ben Kochie 2018-09-25 16:02:42 +02:00 committed by GitHub
parent 0fdc089187
commit c7dfb82dac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 18 deletions

View File

@ -4,7 +4,7 @@ version: 2
jobs: jobs:
test: test:
docker: docker:
- image: circleci/golang:1.10 - image: circleci/golang:1.11
working_directory: /go/src/github.com/prometheus/node_exporter working_directory: /go/src/github.com/prometheus/node_exporter
steps: steps:
@ -27,13 +27,14 @@ jobs:
working_directory: /home/circleci/.go_workspace/src/github.com/prometheus/node_exporter working_directory: /home/circleci/.go_workspace/src/github.com/prometheus/node_exporter
environment: 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 REPO_PATH: github.com/prometheus/node_exporter
steps: steps:
- checkout - checkout
- run: make promu - 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: - persist_to_workspace:
root: . root: .
paths: paths:
@ -58,7 +59,7 @@ jobs:
docker_hub_master: docker_hub_master:
docker: docker:
- image: circleci/golang:1.10 - image: circleci/golang:1.11
working_directory: /go/src/github.com/prometheus/node_exporter working_directory: /go/src/github.com/prometheus/node_exporter
steps: steps:
@ -77,7 +78,7 @@ jobs:
docker_hub_release_tags: docker_hub_release_tags:
docker: docker:
- image: circleci/golang:1.10 - image: circleci/golang:1.11
working_directory: /go/src/github.com/prometheus/node_exporter working_directory: /go/src/github.com/prometheus/node_exporter
steps: steps:

24
.promu-cgo.yml Normal file
View File

@ -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

View File

@ -1,5 +1,3 @@
go:
cgo: true
repository: repository:
path: github.com/prometheus/node_exporter path: github.com/prometheus/node_exporter
build: build:
@ -20,10 +18,6 @@ crossbuild:
platforms: platforms:
- linux/amd64 - linux/amd64
- linux/386 - linux/386
- darwin/amd64
- darwin/386
- netbsd/amd64
- netbsd/386
- linux/arm - linux/arm
- linux/arm64 - linux/arm64
- linux/mips - linux/mips

View File

@ -44,6 +44,23 @@ else
test-e2e := skip-test-e2e test-e2e := skip-test-e2e
endif 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 e2e-out = collector/fixtures/e2e-output.txt
ifeq ($(MACH), ppc64le) ifeq ($(MACH), ppc64le)
e2e-out = collector/fixtures/e2e-64k-page-output.txt e2e-out = collector/fixtures/e2e-64k-page-output.txt