version: 2.1 executors: go: docker: - image: circleci/golang:1.12 environment: GO111MODULES: on goreleaser: docker: - image: goreleaser/goreleaser commands: gomod: steps: - restore_cache: keys: [gomod-] - run: name: Download dependencies command: go mod download - save_cache: key: gomod-{{ checksum "go.sum" }} paths: [/go/pkg/mod] jobs: test: executor: go steps: - checkout - gomod - run: name: Run tests command: go test -v ./... coverage: environment: CC_TEST_REPORTER_ID: 22c636ecdefebc15bb4f014f29fd593204cb51102d8b46d00a1c0c273d7a99e9 executor: go steps: - checkout - gomod - run: name: Setup Code Climate test-reporter command: | curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter chmod +x ./cc-test-reporter - run: name: Create test coverage report and send it to Code Climate command: | ./cc-test-reporter before-build go test -race -coverprofile=coverage.txt ./... ./cc-test-reporter after-build --coverage-input-type cover --exit-code $? - store_artifacts: path: ./coverage.txt destination: coverage.txt release-test: executor: goreleaser working_directory: /go/src/github.com/greenled/portainer-stack-utils steps: - checkout - setup_remote_docker - run: name: Create snapshot command: goreleaser --skip-publish --snapshot release: executor: goreleaser working_directory: /go/src/github.com/greenled/portainer-stack-utils steps: - checkout - setup_remote_docker - run: name: Create and publish release command: | docker login -u $CI_REGISTY_USER -p $CI_REGISTY_PASSWORD $CI_REGISTRY goreleaser workflows: ci: jobs: - test: filters: tags: only: /.*/ - coverage: filters: tags: only: /.*/ - release-test: filters: tags: only: /.*/ - release: requires: - test - coverage - release-test filters: branches: ignore: /.*/ tags: only: /^v.*/