From 3666f5c50efd08aae965f257210ad9a3bfe01810 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 19 Sep 2022 15:49:39 -0500 Subject: [PATCH 1/6] remove circle config directory --- .circleci/config.yml | 60 -------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 2219511..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,60 +0,0 @@ -version: 2.1 - -references: - images: - go: &GOLANG_IMAGE docker.mirror.hashicorp.services/circleci/golang:1.15.3 - environments: - tmp: &TEST_RESULTS_PATH /tmp/test-results # path to where test results are saved - -# reusable 'executor' object for jobs -executors: - go: - docker: - - image: *GOLANG_IMAGE - environment: - - TEST_RESULTS: *TEST_RESULTS_PATH - -jobs: - 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 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 tests with gotestsum - - run: | - PACKAGE_NAMES=$(go list ./...) - gotestsum --format=short-verbose --junitfile $TEST_RESULTS/gotestsum-report.xml -- $PACKAGE_NAMES - - store_test_results: - path: *TEST_RESULTS_PATH - - store_artifacts: - path: *TEST_RESULTS_PATH - -workflows: - version: 2 - test-and-build: - jobs: - - go-test From f38981328bc77ec6d2b033a08f35d7cbb33977ac Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 19 Sep 2022 15:51:38 -0500 Subject: [PATCH 2/6] migrate to gha --- .github/workflows/go-tests.yml | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/go-tests.yml diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml new file mode 100644 index 0000000..5f03cde --- /dev/null +++ b/.github/workflows/go-tests.yml @@ -0,0 +1,66 @@ +name: go-tests + +on: [push] + +env: + TEST_RESULTS: /tmp/test-results + +jobs: + + go-tests: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [1.19] + + steps: + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Create test directory + run: | + mkdir -p ${{env.TEST_RESULTS}} + + - name: Download go modules + run: go mod download + + - name: Cache / restore go modules + uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + # Check go fmt output because it does not report non-zero when there are fmt changes + - name: Run gofmt + run: | + go fmt ./... + files=$(go fmt ./...) + if [ -n "$files" ]; then + echo "The following file(s) do not conform to go fmt:" + echo "$files" + exit 1 + fi + + - name: Install gotestsum + run: go install gotest.tools/gotestsum@v1.8.2 + + - name: Run go tests + run: | + PACKAGE_NAMES=$(go list ./...) + gotestsum --format=short-verbose --junitfile $TEST_RESULTS/gotestsum-report.xml -- $PACKAGE_NAMES + + # Save coverage report parts + - name: Upload and save artifacts + uses: actions/upload-artifact@v3 + with: + name: Test Results + path: ${{env.TEST_RESULTS}} \ No newline at end of file From 10a0ac4c2c00998fb06a4fb916379a976c70cbef Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 20 Sep 2022 10:15:38 -0500 Subject: [PATCH 3/6] PR feedback --- .github/workflows/go-tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 5f03cde..3c71599 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [1.19] + go-version: [ 1.15.3, 1.19 ] steps: - name: Setup go @@ -24,7 +24,7 @@ jobs: - name: Create test directory run: | - mkdir -p ${{env.TEST_RESULTS}} + mkdir -p ${{ env.TEST_RESULTS }} - name: Download go modules run: go mod download @@ -33,7 +33,6 @@ jobs: uses: actions/cache@v3 with: path: | - ~/.cache/go-build ~/go/pkg/mod key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | @@ -63,4 +62,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: Test Results - path: ${{env.TEST_RESULTS}} \ No newline at end of file + path: ${{ env.TEST_RESULTS }} \ No newline at end of file From e033ba8f629b744a7f351b0c3b09e3f3e16f578f Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 20 Sep 2022 11:19:35 -0500 Subject: [PATCH 4/6] fix install gotestsum for 1.15.3 --- .github/workflows/go-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 3c71599..5101332 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -50,7 +50,10 @@ jobs: fi - name: Install gotestsum - run: go install gotest.tools/gotestsum@v1.8.2 + run: + if [ ${{ matrix.go-version }} == 1.15.3 ]; then + go get gotest.tools/gotestsum@v1.8.2; else + go install gotest.tools/gotestsum@v1.8.2 - name: Run go tests run: | From daeb99ec1efbd51625b36c79cc5193ec6ca75c10 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 20 Sep 2022 11:21:02 -0500 Subject: [PATCH 5/6] whoops forgot to wrap statement --- .github/workflows/go-tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 5101332..00ddc3e 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -48,12 +48,14 @@ jobs: echo "$files" exit 1 fi - + + # Install gotestsum with go get for 1.15.3; otherwise default to go install - name: Install gotestsum - run: + run: | if [ ${{ matrix.go-version }} == 1.15.3 ]; then go get gotest.tools/gotestsum@v1.8.2; else go install gotest.tools/gotestsum@v1.8.2 + fi - name: Run go tests run: | From 07809e1ac38bd41e9c0b7a7f08445f60f24a7d49 Mon Sep 17 00:00:00 2001 From: claire labry Date: Tue, 27 Sep 2022 09:54:23 -0500 Subject: [PATCH 6/6] Update .github/workflows/go-tests.yml Co-authored-by: Sam Salisbury --- .github/workflows/go-tests.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 00ddc3e..ade0415 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -52,10 +52,14 @@ jobs: # Install gotestsum with go get for 1.15.3; otherwise default to go install - name: Install gotestsum run: | - if [ ${{ matrix.go-version }} == 1.15.3 ]; then - go get gotest.tools/gotestsum@v1.8.2; else - go install gotest.tools/gotestsum@v1.8.2 - fi + GTS="gotest.tools/gotestsum@v1.8.2" + # We use the same error message prefix in either failure case, so just define it once here. + ERROR="Failed to install $GTS" + # First try to 'go install', if that fails try 'go get'... + go install "$GTS" || go get "$GTS" || { echo "$ERROR: both 'go install' and 'go get' failed"; exit 1; } + # Check that the gotestsum command was actually installed in the path... + command -v gotestsum > /dev/null 2>&1 || { echo "$ERROR: gotestsum command not installed"; exit 1; } + echo "OK: Command 'gotestsum' installed ($GTS)" - name: Run go tests run: |