telegraf/.circleci/config.yml

709 lines
18 KiB
YAML

version: 2.1
orbs:
win: circleci/windows@2.4.0
aws-cli: circleci/aws-cli@1.4.0
executors:
go-1_17:
working_directory: '/go/src/github.com/influxdata/telegraf'
resource_class: large
docker:
- image: 'quay.io/influxdb/telegraf-ci:1.17.5'
environment:
GOFLAGS: -p=4
mac:
working_directory: '~/go/src/github.com/influxdata/telegraf'
resource_class: medium
macos:
xcode: 13.2.0
environment:
HOMEBREW_NO_AUTO_UPDATE: 1
GOFLAGS: -p=4
commands:
generate-config:
parameters:
os:
type: string
default: "linux"
steps:
- checkout
- attach_workspace:
at: '/build'
- run: ./scripts/generate_config.sh << parameters.os >>
- store_artifacts:
path: './new-config'
destination: 'new-config'
check-changed-files-or-halt:
steps:
- run: ./scripts/check-file-changes.sh
test-go:
parameters:
os:
type: string
default: "linux"
arch:
type: string
default: "amd64"
gotestsum:
type: string
default: "gotestsum"
cache_version:
type: string
default: "v3"
steps:
- checkout
- check-changed-files-or-halt
- when:
condition:
equal: [ linux, << parameters.os >> ]
steps:
- restore_cache:
key: linux-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
- attach_workspace:
at: '/go'
- when:
condition:
equal: [ darwin, << parameters.os >> ]
steps:
- restore_cache:
key: darwin-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
- run: 'sh ./scripts/installgo_mac.sh'
- when:
condition:
equal: [ windows, << parameters.os >> ]
steps:
- run: rm -rf /c/Go
- restore_cache:
key: windows-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
- run: 'sh ./scripts/installgo_windows.sh'
- run: mkdir -p test-results
- run: ./scripts/install_gotestsum.sh << parameters.os >> << parameters.gotestsum >>
- run: |
PACKAGE_NAMES=$(go list ./... | circleci tests split --split-by=timings --timings-type=classname)
GOARCH=<< parameters.arch >> ./<< parameters.gotestsum >> --junitfile test-results/gotestsum-report.xml -- -short $PACKAGE_NAMES
- store_test_results:
path: test-results
- when:
condition:
equal: [ linux, << parameters.os >> ]
steps:
- save_cache:
name: 'Saving cache'
key: linux-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
paths:
- '~/go/src/github.com/influxdata/telegraf/gotestsum'
- when:
condition:
equal: [ darwin, << parameters.os >> ]
steps:
- save_cache:
name: 'Saving cache'
key: darwin-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
paths:
- '/go/src/github.com/influxdata/telegraf/gotestsum'
- '/usr/local/Cellar/go'
- '/usr/local/bin/go'
- '/usr/local/bin/gofmt'
- when:
condition:
equal: [ windows, << parameters.os >> ]
steps:
- save_cache:
name: 'Saving cache'
key: windows-go-<< parameters.cache_version >>-{{ checksum "go.sum" }}
paths:
- 'C:\Go'
- 'C:\Users\circleci\project\gotestsum.exe'
package-build:
parameters:
type:
type: string
default: ""
nightly:
type: boolean
default: false
steps:
- checkout
- check-changed-files-or-halt
- attach_workspace:
at: '/go'
- when:
condition:
equal: [ windows, << parameters.type >> ]
steps:
- run: make versioninfo
- when:
condition: << parameters.nightly >>
steps:
- run: 'NIGHTLY=1 make package include_packages="$(make << parameters.type >>)"'
- unless:
condition:
or:
- << parameters.nightly >>
steps:
- run: 'make package include_packages="$(make << parameters.type >>)"'
- store_artifacts:
path: './build/dist'
destination: 'build/dist'
- persist_to_workspace:
root: './build'
paths:
- 'dist'
jobs:
test-go-linux:
executor: go-1_17
parallelism: 4
steps:
- checkout
- restore_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
- check-changed-files-or-halt
- run: 'make deps'
- run: 'make tidy'
- run: 'make check'
- run: 'make check-deps'
- test-go
- save_cache:
name: 'go module cache'
key: go-mod-v1-{{ checksum "go.sum" }}
paths:
- '/go/pkg/mod'
- persist_to_workspace:
root: '/go'
paths:
- '*'
test-go-linux-386:
executor: go-1_17
parallelism: 4
steps:
- checkout
- restore_cache:
key: go-mod-v1-{{ checksum "go.sum" }}
- check-changed-files-or-halt
- run: 'GOARCH=386 make deps'
- run: 'GOARCH=386 make tidy'
- run: 'GOARCH=386 make check'
- test-go:
arch: "386"
test-go-mac:
executor: mac
steps:
- test-go:
os: darwin
parallelism: 4
test-go-windows:
executor:
name: win/default
shell: bash.exe
steps:
- test-go:
os: windows
gotestsum: "gotestsum.exe"
parallelism: 4
windows-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: windows
nightly: << parameters.nightly >>
darwin-amd64-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: darwin-amd64
nightly: << parameters.nightly >>
darwin-arm64-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: darwin-arm64
nightly: << parameters.nightly >>
i386-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: i386
nightly: << parameters.nightly >>
ppc64le-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: ppc64le
nightly: << parameters.nightly >>
riscv64-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: riscv64
nightly: << parameters.nightly >>
s390x-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: s390x
nightly: << parameters.nightly >>
armel-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: armel
nightly: << parameters.nightly >>
amd64-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: amd64
nightly: << parameters.nightly >>
arm64-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: arm64
nightly: << parameters.nightly >>
mipsel-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: mipsel
nightly: << parameters.nightly >>
mips-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: mips
nightly: << parameters.nightly >>
static-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: static
nightly: << parameters.nightly >>
armhf-package:
parameters:
nightly:
type: boolean
default: false
executor: go-1_17
steps:
- package-build:
type: armhf
nightly: << parameters.nightly >>
nightly:
executor: go-1_17
steps:
- attach_workspace:
at: '/build'
- run:
command: |
aws s3 sync /build/dist s3://dl.influxdata.com/telegraf/nightlies/ \
--exclude "*" \
--include "*.tar.gz" \
--include "*.deb" \
--include "*.rpm" \
--include "*.zip" \
--acl public-read
package-sign-windows:
executor:
name: win/default
shell: powershell.exe
steps:
- checkout
- check-changed-files-or-halt
- attach_workspace:
at: '/build'
- run:
name: "Sign Windows Executables"
shell: powershell.exe
command: |
./scripts/windows-signing.ps1
- persist_to_workspace:
root: './build'
paths:
- 'dist'
package-sign-mac:
executor: mac
working_directory: /Users/distiller/project
environment:
FL_OUTPUT_DIR: output
FASTLANE_LANE: test
shell: /bin/bash --login -o pipefail
steps:
- checkout
- check-changed-files-or-halt
- attach_workspace:
at: '.'
- run:
command: |
sh ./scripts/mac-signing.sh
- persist_to_workspace:
root: './build'
paths:
- 'dist'
package-consolidate:
docker:
- image: alpine
steps:
- attach_workspace:
at: '.'
- store_artifacts:
path: './dist'
destination: 'build/dist'
- run:
command: |
echo "This job contains all the final artifacts."
share-artifacts:
executor: aws-cli/default
steps:
- checkout
- check-changed-files-or-halt
- run:
command: |
PR=${CIRCLE_PULL_REQUEST##*/}
printf -v payload '{ "pullRequestNumber": "%s" }' "$PR"
curl -X POST "https://182c7jdgog.execute-api.us-east-1.amazonaws.com/prod/shareArtifacts" --data "$payload"
generate-config:
executor: go-1_17
steps:
- generate-config
generate-config-win:
executor:
name: win/default
shell: bash.exe
steps:
- generate-config:
os: windows
workflows:
version: 2
check:
jobs:
- 'test-go-linux':
filters:
tags:
only: /.*/
- 'test-go-linux-386':
filters:
tags:
only: /.*/
- 'test-go-mac':
filters:
tags: # only runs on tags if you specify this filter
only: /.*/
- 'test-go-windows':
filters:
tags:
only: /.*/
- 'windows-package':
requires:
- 'test-go-windows'
filters:
tags:
only: /.*/
- 'darwin-amd64-package':
requires:
- 'test-go-mac'
filters:
tags:
only: /.*/
- 'darwin-arm64-package':
requires:
- 'test-go-mac'
filters:
tags:
only: /.*/
- 'i386-package':
requires:
- 'test-go-linux-386'
filters:
tags:
only: /.*/
- 'ppc64le-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 'riscv64-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 's390x-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 'armel-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 'amd64-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 'arm64-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 'armhf-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 'static-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 'mipsel-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 'mips-package':
requires:
- 'test-go-linux'
filters:
tags:
only: /.*/
- 'generate-config':
requires:
- 'amd64-package'
filters:
branches:
only:
- master
- 'generate-config-win':
requires:
- 'windows-package'
filters:
branches:
only:
- master
- 'share-artifacts':
requires:
- 'i386-package'
- 'ppc64le-package'
- 'riscv64-package'
- 's390x-package'
- 'armel-package'
- 'amd64-package'
- 'mipsel-package'
- 'mips-package'
- 'darwin-amd64-package'
- 'darwin-arm64-package'
- 'windows-package'
- 'static-package'
- 'arm64-package'
- 'armhf-package'
filters:
branches:
ignore:
- master
- release.*
tags:
ignore: /.*/
- 'package-sign-windows':
requires:
- 'windows-package'
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- 'package-sign-mac':
requires:
- 'darwin-amd64-package'
- 'darwin-arm64-package'
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- 'package-consolidate':
requires:
- 'i386-package'
- 'ppc64le-package'
- 's390x-package'
- 'armel-package'
- 'amd64-package'
- 'mipsel-package'
- 'mips-package'
- 'static-package'
- 'arm64-package'
- 'armhf-package'
- 'riscv64-package'
- 'package-sign-mac'
- 'package-sign-windows'
filters:
tags:
only: /.*/
branches:
ignore: /.*/
nightly:
jobs:
- 'test-go-linux'
- 'test-go-linux-386'
- 'test-go-mac'
- 'test-go-windows'
- 'windows-package':
name: 'windows-package-nightly'
nightly: true
requires:
- 'test-go-windows'
- 'darwin-amd64-package':
name: 'darwin-amd64-package-nightly'
nightly: true
requires:
- 'test-go-mac'
- 'darwin-arm64-package':
name: 'darwin-arm64-package-nightly'
nightly: true
requires:
- 'test-go-mac'
- 'i386-package':
name: 'i386-package-nightly'
nightly: true
requires:
- 'test-go-linux-386'
- 'ppc64le-package':
name: 'ppc64le-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 'riscv64-package':
name: 'riscv64-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 's390x-package':
name: 's390x-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 'armel-package':
name: 'armel-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 'amd64-package':
name: 'amd64-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 'arm64-package':
name: 'arm64-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 'armhf-package':
name: 'armhf-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 'static-package':
name: 'static-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 'mipsel-package':
name: 'mipsel-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- 'mips-package':
name: 'mips-package-nightly'
nightly: true
requires:
- 'test-go-linux'
- nightly:
requires:
- 'i386-package-nightly'
- 'ppc64le-package-nightly'
- 'riscv64-package-nightly'
- 's390x-package-nightly'
- 'armel-package-nightly'
- 'amd64-package-nightly'
- 'mipsel-package-nightly'
- 'mips-package-nightly'
- 'darwin-amd64-package-nightly'
- 'darwin-arm64-package-nightly'
- 'windows-package-nightly'
- 'static-package-nightly'
- 'arm64-package-nightly'
- 'armhf-package-nightly'
triggers:
- schedule:
cron: "0 7 * * *"
filters:
branches:
only:
- master