Skip to content

Commit

Permalink
Update makefile and CI scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson committed Jan 16, 2020
1 parent bdd1842 commit b649191
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 162 deletions.
32 changes: 19 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ defaults:
go-1_12: &go-1_12
docker:
- image: 'quay.io/influxdb/telegraf-ci:1.12.14'
environment:
GO111MODULE: 'on'
go-1_13: &go-1_13
docker:
- image: 'quay.io/influxdb/telegraf-ci:1.13.5'
Expand All @@ -18,53 +20,57 @@ jobs:
steps:
- checkout
- restore_cache:
key: vendor-{{ checksum "Gopkg.lock" }}
key: go-mod-v1-{{ checksum "go.sum" }}
- run: 'make deps'
- run: 'dep check'
- run: 'make tidy'
- save_cache:
name: 'vendored deps'
key: vendor-{{ checksum "Gopkg.lock" }}
name: 'go module cache'
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- './vendor'
- '/go/pkg/mod'
- persist_to_workspace:
root: '/go/src'
root: '/go'
paths:
- '*'

test-go-1.12:
<<: [ *defaults, *go-1_12 ]
steps:
- attach_workspace:
at: '/go/src'
at: '/go'
- run: 'make'
- run: 'make check'
- run: 'make test'
test-go-1.12-386:
<<: [ *defaults, *go-1_12 ]
steps:
- attach_workspace:
at: '/go/src'
at: '/go'
- run: 'GOARCH=386 make'
- run: 'GOARCH=386 make check'
- run: 'GOARCH=386 make test'
test-go-1.13:
<<: [ *defaults, *go-1_13 ]
steps:
- attach_workspace:
at: '/go/src'
at: '/go'
- run: 'make'
- run: 'make check'
- run: 'make test'
test-go-1.13-386:
<<: [ *defaults, *go-1_13 ]
steps:
- attach_workspace:
at: '/go/src'
at: '/go'
- run: 'GOARCH=386 make'
- run: 'GOARCH=386 make check'
- run: 'GOARCH=386 make test'

package:
<<: [ *defaults, *go-1_13 ]
steps:
- attach_workspace:
at: '/go/src'
at: '/go'
- run: 'make package'
- store_artifacts:
path: './build'
Expand All @@ -73,7 +79,7 @@ jobs:
<<: [ *defaults, *go-1_13 ]
steps:
- attach_workspace:
at: '/go/src'
at: '/go'
- run: 'make package-release'
- store_artifacts:
path: './build'
Expand All @@ -82,7 +88,7 @@ jobs:
<<: [ *defaults, *go-1_13 ]
steps:
- attach_workspace:
at: '/go/src'
at: '/go'
- run: 'make package-nightly'
- store_artifacts:
path: './build'
Expand Down
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ all:

.PHONY: deps
deps:
dep ensure -vendor-only
go mod download

.PHONY: telegraf
telegraf:
Expand Down Expand Up @@ -83,8 +83,18 @@ vet:
exit 1; \
fi

.PHONY: tidy
tidy:
go mod verify
go mod tidy
@if ! git diff --quiet go.mod go.sum; then \
echo "please run go mod tidy and check in changes"; \
exit 1; \
fi

.PHONY: check
check: fmtcheck vet
@$(MAKE) --no-print-directory tidy

.PHONY: test-all
test-all: fmtcheck vet
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ Ansible role: https://github.com/rossmcdonald/telegraf

### From Source:

Telegraf requires golang version 1.12 or newer, the Makefile requires GNU make.
Telegraf requires Go version 1.12 or newer, the Makefile requires GNU make.

1. [Install Go](https://golang.org/doc/install) >=1.12 (1.13 recommended)
2. [Install dep](https://golang.github.io/dep/docs/installation.html) ==v0.5.0
3. Download Telegraf source:
2. Clone the Telegraf repository:
```
go get -d github.com/influxdata/telegraf
cd ~/src
git clone https://github.com/influxdata/telegraf.git
```
4. Run make from the source directory
3. Run `make` from the source directory
```
cd "$HOME/go/src/github.com/influxdata/telegraf"
cd ~/src/telegraf
make
```

Expand Down
26 changes: 9 additions & 17 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,32 @@
version: "{build}"

cache:
- C:\Cache
- C:\gopath\pkg\dep\sources -> Gopkg.lock
- C:\gopath\pkg\mod -> go.sum
- C:\Users\appveyor\AppData\Local\Temp\chocolatey\ -> appveyor.yml

clone_folder: C:\gopath\src\github.com\influxdata\telegraf

environment:
GOVERSION: 1.13.5
GOPATH: C:\gopath

platform: x64

install:
- IF NOT EXIST "C:\Cache" mkdir C:\Cache
- IF NOT EXIST "C:\Cache\go1.13.5.msi" curl -o "C:\Cache\go1.13.5.msi" https://storage.googleapis.com/golang/go1.13.5.windows-amd64.msi
- IF NOT EXIST "C:\Cache\gnuwin32-bin.zip" curl -o "C:\Cache\gnuwin32-bin.zip" https://dl.influxdata.com/telegraf/ci/make-3.81-bin.zip
- IF NOT EXIST "C:\Cache\gnuwin32-dep.zip" curl -o "C:\Cache\gnuwin32-dep.zip" https://dl.influxdata.com/telegraf/ci/make-3.81-dep.zip
- IF EXIST "C:\Go" rmdir /S /Q C:\Go
- msiexec.exe /i "C:\Cache\go1.13.5.msi" /quiet
- 7z x "C:\Cache\gnuwin32-bin.zip" -oC:\GnuWin32 -y
- 7z x "C:\Cache\gnuwin32-dep.zip" -oC:\GnuWin32 -y
- go get -d github.com/golang/dep
- cd "%GOPATH%\src\github.com\golang\dep"
- git checkout -q v0.5.0
- go install -ldflags="-X main.version=v0.5.0" ./cmd/dep
- choco install golang --version "%GOVERSION%"
- choco install make
- cd "%GOPATH%\src\github.com\influxdata\telegraf"
- git config --system core.longpaths true
- go version
- go env

build_script:
- cmd: C:\GnuWin32\bin\make
- make deps
- make telegraf

test_script:
- cmd: C:\GnuWin32\bin\make check
- cmd: C:\GnuWin32\bin\make test-windows
- make check
- make test-windows

artifacts:
- path: telegraf.exe
Loading

0 comments on commit b649191

Please sign in to comment.