From 873f5783e7cd22f15c4aea34eda60eecde0bd0e4 Mon Sep 17 00:00:00 2001 From: Alex Goodman Date: Sat, 9 Nov 2019 14:49:42 -0500 Subject: [PATCH] fix/improve circle tests --- .circleci/config.yml | 65 ++++++++++++++-------------------- .github/workflows/pipeline.yml | 10 +++--- .goreleaser.yml | 1 + Makefile | 9 ++++- 4 files changed, 41 insertions(+), 44 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 74ad8fda..120a6058 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,70 +1,59 @@ -version: 2 +version: 2.1 jobs: - golang-1.11: + run-static-analyses: + parameters: + version: + type: string working_directory: /home/circleci/app docker: - - image: circleci/golang:1.11 + - image: circleci/golang:<< parameters.version >> environment: GO111MODULE: "on" steps: - checkout - restore_cache: keys: - - golang-1.11-{{ checksum "go.sum" }} - - run: make setup-ci + - golang-<< parameters.version >>-{{ checksum "go.sum" }} + - run: make ci-install-go-tools - save_cache: - key: golang-1.11-{{ checksum "go.sum" }} + key: golang-<< parameters.version >>-{{ checksum "go.sum" }} paths: - "/go/pkg/mod" - run: - name: run static analysis & tests - command: make ci + name: run static analysis + command: make ci-static-analyses - golang-1.12: + run-tests: + parameters: + version: + type: string working_directory: /home/circleci/app docker: - - image: circleci/golang:1.12 + - image: circleci/golang:<< parameters.version >> environment: GO111MODULE: "on" steps: - checkout - restore_cache: keys: - - golang-1.12-{{ checksum "go.sum" }} - - run: make setup-ci + - golang-<< parameters.version >>-{{ checksum "go.sum" }} + - run: make ci-install-go-tools - save_cache: - key: golang-1.12-{{ checksum "go.sum" }} + key: golang-<< parameters.version >>-{{ checksum "go.sum" }} paths: - "/go/pkg/mod" - run: - name: run static analysis & tests - command: make ci + name: run unit tests + command: make ci-unit-test - golang-1.13: - working_directory: /home/circleci/app - docker: - - image: circleci/golang:1.13 - environment: - GO111MODULE: "on" - steps: - - checkout - - restore_cache: - keys: - - golang-1.13-{{ checksum "go.sum" }} - - run: make setup-ci - - save_cache: - key: golang-1.13-{{ checksum "go.sum" }} - paths: - - "/go/pkg/mod" - - run: - name: run static analysis & tests - command: make ci workflows: - version: 2 commit: jobs: - - golang-1.11 - - golang-1.12 - - golang-1.13 + - run-static-analyses: + version: "1.13" + - run-tests: + version: "1.12" + - run-tests: + version: "1.13" diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 5899279d..373b3036 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -3,6 +3,8 @@ on: [ push, pull_request ] env: DOCKER_CLI_VERSION: "19.03.1" jobs: + # This will run on merge to master, and for PRs with folks that also are part of the GHA beta. + # Circle ci will also run for redundancy until GHA is out of beta, since circle checks will always run. unit-test: strategy: matrix: @@ -33,7 +35,7 @@ jobs: run: go get ./... - name: Test - run: make ci-test + run: make ci-unit-test build-artifacts: runs-on: ubuntu-latest @@ -60,10 +62,8 @@ jobs: if: steps.package-cache-go-dependencies.outputs.cache-hit != 'true' run: go get ./... - # todo: test gofmt - - - name: Lint - run: golangci-lint run -v + - name: Linting, formatting, and other static code analyses + run: make ci-static-analyses - name: Build snapshot artifacts uses: goreleaser/goreleaser-action@v1 diff --git a/.goreleaser.yml b/.goreleaser.yml index e00b40d2..92440a2c 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -39,6 +39,7 @@ dockers: binaries: - dive dockerfile: Dockerfile + # todo: on 1.0 remove 'v' prefix image_templates: - "wagoodman/dive:latest" - "wagoodman/dive:{{ .Tag }}" diff --git a/Makefile b/Makefile index bdc55519..0ace2e15 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,15 @@ all: clean build ## For CI -ci-test: +ci-unit-test: go test -cover -v -race ./... +ci-static-analyses: + grep -R 'const allowTestDataCapture = false' runtime/ui/viewmodel + go vet ./... + @! gofmt -s -l . 2>&1 | grep -vE '^\.git/' | grep -vE '^\.cache/' + golangci-lint run + ci-install-go-tools: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sudo sh -s -- -b /usr/local/bin/ latest @@ -34,6 +40,7 @@ ci-test-production-image: '${TEST_IMAGE}' \ --ci + ## For development run: build