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

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

View File

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