From 0855ac052d9c46ff666204e9343a240165012cba Mon Sep 17 00:00:00 2001 From: "chloe (@cotarg)" Date: Mon, 7 Oct 2019 14:59:08 -0400 Subject: [PATCH 1/5] added circleci config --- .circleci/config.yml | 72 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..75198de --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,72 @@ +version: 2.1 + +references: + images: + go: &GOLANG_IMAGE circleci/golang:latest + +# reusable 'executor' object for jobs +executors: + go: + docker: + - image: *GOLANG_IMAGE + environment: + - TEST_RESULTS: /tmp/test-results # path to where test results are saved + +jobs: + go-fmt-and-vet: + executor: go + steps: + - checkout + + # Restore go module cache if there is one + - restore_cache: + keys: + - go-version-modcache-v1-{{ checksum "go.mod" }} + + - run: go mod download + + # Save go module cache if the go.mod file has changed + - save_cache: + key: go-version-modcache-v1-{{ checksum "go.mod" }} + paths: + - "/go/pkg/mod" + + # check go fmt output because it does not report non-zero when there are fmt changes + - run: + name: check go fmt + command: | + files=$(go fmt ./...) + if [ -n "$files" ]; then + echo "The following file(s) do not conform to go fmt:" + echo "$files" + exit 1 + fi + - run: go vet ./... + + go-test: + executor: go + steps: + - checkout + - run: mkdir -p $TEST_RESULTS + + - restore_cache: # restore cache from dev-build job + keys: + - go-version-modcache-v1-{{ checksum "go.mod" }} + + # run go tests with gotestsum + - run: | + PACKAGE_NAMES=$(go list ./...) + gotestsum --format=short-verbose --junitfile $TEST_RESULTS/gotestsum-report.xml -- $PACKAGE_NAMES + - store_test_results: + path: /tmp/test-results + - store_artifacts: + path: /tmp/test-results + +workflows: + version: 2 + test-and-build: + jobs: + - go-fmt-and-vet + - go-test: + requires: + - go-fmt-and-vet From eb5437e3e32c5f7c329926baf5aaa2de4a129fe9 Mon Sep 17 00:00:00 2001 From: "chloe (@cotarg)" Date: Tue, 8 Oct 2019 12:53:39 -0400 Subject: [PATCH 2/5] updated readme with circleci --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f3a15c..2ee50c5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Versioning Library for Go -[![Build Status](https://travis-ci.org/hashicorp/go-version.svg?branch=master)](https://travis-ci.org/hashicorp/go-version) +[![Build Status](https://circleci.com/gh/hashicorp/go-version/tree/master.svg?style=svg)](https://circleci.com/gh/hashicorp/go-version/tree/master) go-version is a library for parsing versions and version constraints, and verifying versions against a set of constraints. go-version From bf36132189d334f1d8d24e51bc6d2a4ec48e877a Mon Sep 17 00:00:00 2001 From: "chloe (@cotarg)" Date: Tue, 8 Oct 2019 12:54:11 -0400 Subject: [PATCH 3/5] remove travis --- .travis.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d37ad1a..0000000 --- a/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: go - -go: - - 1.3 - - 1.4 - - 1.9 - - "1.10" - - 1.11 - - 1.12 - - 1.13 - -script: - - go test From a85ee06d79cb1f4a23603df2bec6b480829de9c3 Mon Sep 17 00:00:00 2001 From: "chloe (@cotarg)" Date: Tue, 8 Oct 2019 14:41:04 -0400 Subject: [PATCH 4/5] updating config to consolidate jobs --- .circleci/config.yml | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 75198de..7289c6b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,6 +3,8 @@ version: 2.1 references: images: go: &GOLANG_IMAGE circleci/golang:latest + environments: + tmp: &TEST_RESULTS_PATH /tmp/test-results # path to where test results are saved # reusable 'executor' object for jobs executors: @@ -10,16 +12,16 @@ executors: docker: - image: *GOLANG_IMAGE environment: - - TEST_RESULTS: /tmp/test-results # path to where test results are saved + - TEST_RESULTS: *TEST_RESULTS_PATH jobs: - go-fmt-and-vet: + go-test: executor: go steps: - checkout + - run: mkdir -p $TEST_RESULTS - # Restore go module cache if there is one - - restore_cache: + - restore_cache: # restore cache from dev-build job keys: - go-version-modcache-v1-{{ checksum "go.mod" }} @@ -41,32 +43,18 @@ jobs: echo "$files" exit 1 fi - - run: go vet ./... - - go-test: - executor: go - steps: - - checkout - - run: mkdir -p $TEST_RESULTS - - - restore_cache: # restore cache from dev-build job - keys: - - go-version-modcache-v1-{{ checksum "go.mod" }} # run go tests with gotestsum - run: | PACKAGE_NAMES=$(go list ./...) gotestsum --format=short-verbose --junitfile $TEST_RESULTS/gotestsum-report.xml -- $PACKAGE_NAMES - store_test_results: - path: /tmp/test-results + path: *TEST_RESULTS_PATH - store_artifacts: - path: /tmp/test-results + path: *TEST_RESULTS_PATH workflows: version: 2 test-and-build: jobs: - - go-fmt-and-vet - - go-test: - requires: - - go-fmt-and-vet + - go-test From 5d3ebb9fa6c8c293d89837b5141f4ebfcee4a2f3 Mon Sep 17 00:00:00 2001 From: "chloe (@cotarg)" Date: Tue, 8 Oct 2019 15:06:23 -0400 Subject: [PATCH 5/5] remove gomod download --- .circleci/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7289c6b..11d5035 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -25,8 +25,6 @@ jobs: keys: - go-version-modcache-v1-{{ checksum "go.mod" }} - - run: go mod download - # Save go module cache if the go.mod file has changed - save_cache: key: go-version-modcache-v1-{{ checksum "go.mod" }}