From 2a7b4f98da6d108dc01f1b7d146b3e58fdb2d8c1 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 4 Aug 2020 18:35:47 +0000 Subject: [PATCH 01/14] feat: run integration tests in ci --- .circleci/config.yml | 30 +++++++++++++++++++++++++++++- Makefile | 8 ++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5b4f77ba0de..f407850a7e0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,4 @@ -version: 2 +version: 2.1 jobs: build: docker: @@ -33,3 +33,31 @@ jobs: - store_test_results: path: /tmp/test-results + + integration: + + parameters: + integ: + type: string + + machine: + image: ubuntu-1064:201903-01 + + environment: + TEST_RESULTS: /tmp/test-results # path to where test results will be saved + INTEGRATION: << parameters.integ >> + + steps: + - checkout + - run: mkdir -p $TEST_RESULTS + - run: make $INTEGRATION + +workflows: + version: 2.1 + build_and_test: + jobs: + - build + - integration: + matrix: + parameters: + integ: [cassandra] diff --git a/Makefile b/Makefile index 3c130add118..57f09584245 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,14 @@ test-with-coverage: .PHONY: ci ci: precommit check-clean-work-tree test-with-coverage test-386 +.PHONY: cassandra +cassandra: + set -e; \ + docker run --name cassandra-integ --rm -p 9042:9042 cassandra:3; \ + (cd instrumentation/github.com/gocql/gocql && \ + INTEGRATION=gocql go test); \ + docker stop cassandra-integ; \ + .PHONY: check-clean-work-tree check-clean-work-tree: @if ! git diff --quiet; then \ From fd7f84b6f6214c6389c372a86c2d55b362d1af37 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 4 Aug 2020 18:39:09 +0000 Subject: [PATCH 02/14] fix: update machine image --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f407850a7e0..9b024953eb7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,7 +41,7 @@ jobs: type: string machine: - image: ubuntu-1064:201903-01 + image: ubuntu-1604:202004-01 environment: TEST_RESULTS: /tmp/test-results # path to where test results will be saved From 10fb9f8f783a0fbbb138067c324675177be5694e Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 4 Aug 2020 18:41:54 +0000 Subject: [PATCH 03/14] fix: wait for cassandra to be ready --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 57f09584245..bad8e0e665c 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,8 @@ ci: precommit check-clean-work-tree test-with-coverage test-386 .PHONY: cassandra cassandra: set -e; \ - docker run --name cassandra-integ --rm -p 9042:9042 cassandra:3; \ + docker run --name cassandra-integ --rm -p 9042:9042 -d cassandra:3; \ + curl -sSL https://s3.amazonaws.com/circle-downloads/wait-for-cassandra.sh | sh; \ (cd instrumentation/github.com/gocql/gocql && \ INTEGRATION=gocql go test); \ docker stop cassandra-integ; \ From 37c77f22fcc8074bf538ff9a4c9f0bcf0f7118f3 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 4 Aug 2020 19:15:47 +0000 Subject: [PATCH 04/14] fix: add wait for cassandra --- Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bad8e0e665c..18d9b09c003 100644 --- a/Makefile +++ b/Makefile @@ -57,11 +57,17 @@ ci: precommit check-clean-work-tree test-with-coverage test-386 .PHONY: cassandra cassandra: set -e; \ - docker run --name cassandra-integ --rm -p 9042:9042 -d cassandra:3; \ - curl -sSL https://s3.amazonaws.com/circle-downloads/wait-for-cassandra.sh | sh; \ + docker run --name cass-integ --rm -p 9042:9042 -d cassandra:3; \ + for i in 1 2 3 4; do \ + if docker exec cass-integ nodetool status | grep "^UN"; then \ + break; \ + fi; \ + echo "cassandra not yet read..."; \ + sleep 10; \ + done; \ (cd instrumentation/github.com/gocql/gocql && \ INTEGRATION=gocql go test); \ - docker stop cassandra-integ; \ + docker stop cass-integ; \ .PHONY: check-clean-work-tree check-clean-work-tree: From f63d534a1d923a6b8155988a72b5b932ed1b825c Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 4 Aug 2020 19:39:41 +0000 Subject: [PATCH 05/14] feat: add mongo test --- .circleci/config.yml | 2 +- Makefile | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9b024953eb7..6f0cd3bd0c9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -60,4 +60,4 @@ workflows: - integration: matrix: parameters: - integ: [cassandra] + integ: [gocql, mongo-driver] diff --git a/Makefile b/Makefile index 18d9b09c003..e0dc139e440 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ test-with-coverage: .PHONY: ci ci: precommit check-clean-work-tree test-with-coverage test-386 -.PHONY: cassandra +.PHONY: test-gocql cassandra: set -e; \ docker run --name cass-integ --rm -p 9042:9042 -d cassandra:3; \ @@ -62,13 +62,28 @@ cassandra: if docker exec cass-integ nodetool status | grep "^UN"; then \ break; \ fi; \ - echo "cassandra not yet read..."; \ + echo "cassandra not yet ready..."; \ sleep 10; \ done; \ (cd instrumentation/github.com/gocql/gocql && \ INTEGRATION=gocql go test); \ docker stop cass-integ; \ +.PHONY: test-mongo-driver +test-mongo-driver: + set -e; \ + docker run --name mongo-integ --rm -p 27017:27017 -d mongo; \ + for i in 1 2 3 4; do \ + if docker logs --tail mongo-integ | grep "waiting for connections on port 27017"; then \ + break; \ + fi; \ + echo "mongo not yet ready..."; \ + sleep 10; \ + done; \ + (cd instrumentation/go.mongodb.org/mongo-driver && \ + INTEGRATION=mongo-driver go test); \ + docker stop mongo-integ; \ + .PHONY: check-clean-work-tree check-clean-work-tree: @if ! git diff --quiet; then \ From bce85e09750b92251b4998db91d1222e9f842e23 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 4 Aug 2020 19:45:55 +0000 Subject: [PATCH 06/14] chore: refactor check for env var to a helper --- .../github.com/gocql/gocql/gocql_test.go | 7 ++--- .../go.mongodb.org/mongo-driver/mongo_test.go | 8 ++--- internal/util/testutil.go | 31 +++++++++++++++++++ 3 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 internal/util/testutil.go diff --git a/instrumentation/github.com/gocql/gocql/gocql_test.go b/instrumentation/github.com/gocql/gocql/gocql_test.go index 5e8d15771db..4c837e5f75e 100644 --- a/instrumentation/github.com/gocql/gocql/gocql_test.go +++ b/instrumentation/github.com/gocql/gocql/gocql_test.go @@ -35,6 +35,8 @@ import ( "github.com/stretchr/testify/assert" mocktracer "go.opentelemetry.io/contrib/internal/trace" + "go.opentelemetry.io/contrib/internal/util" + "go.opentelemetry.io/otel/api/kv" "go.opentelemetry.io/otel/api/metric" export "go.opentelemetry.io/otel/sdk/export/metric" @@ -519,10 +521,7 @@ func afterEach() { } func TestMain(m *testing.M) { - if _, present := os.LookupEnv("INTEGRATION"); !present { - fmt.Println("--- SKIP: to enable integration test, set the INTEGRATION environment variable") - os.Exit(0) - } + util.IntegrationShouldRun("gocql") beforeAll() os.Exit(m.Run()) } diff --git a/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go b/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go index f9850022ef6..0557e0fe67d 100644 --- a/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go +++ b/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go @@ -16,12 +16,12 @@ package mongo import ( "context" - "fmt" "os" "testing" "time" mocktracer "go.opentelemetry.io/contrib/internal/trace" + "go.opentelemetry.io/contrib/internal/util" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/mongo" @@ -31,11 +31,7 @@ import ( ) func TestMain(m *testing.M) { - _, ok := os.LookupEnv("INTEGRATION") - if !ok { - fmt.Println("--- SKIP: to enable integration test, set the INTEGRATION environment variable") - os.Exit(0) - } + util.IntegrationShouldRun("mongo-driver") os.Exit(m.Run()) } diff --git a/internal/util/testutil.go b/internal/util/testutil.go new file mode 100644 index 00000000000..2754f5cb9a1 --- /dev/null +++ b/internal/util/testutil.go @@ -0,0 +1,31 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package util + +import ( + "fmt" + "os" +) + +func IntegrationShouldRun(name string) { + if val, ok := os.LookupEnv("INTEGRATION"); !ok || val != name { + fmt.Println( + "--- SKIP: to enable integration test, set the INTEGRATION environment variable", + "to", + fmt.Sprintf("\"%s\"", name), + ) + os.Exit(0) + } +} From 3d3a4640225e948be7e7cbe7d5366f5d4257224a Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 4 Aug 2020 21:28:16 +0000 Subject: [PATCH 07/14] feat: create wait script for resources --- .circleci/config.yml | 14 ++++++- .circleci/wait.sh | 42 +++++++++++++++++++ Makefile | 24 ++++------- .../github.com/gocql/gocql/gocql_test.go | 2 +- .../go.mongodb.org/mongo-driver/mongo_test.go | 2 +- 5 files changed, 63 insertions(+), 21 deletions(-) create mode 100755 .circleci/wait.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 6f0cd3bd0c9..0e5fcadc1eb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,8 +49,18 @@ jobs: steps: - checkout + - run: mkdir -p $TEST_RESULTS - - run: make $INTEGRATION + + - run: + name: "Integration test $INTEGRATION" + command: | + make $INTEGRATION + find . -name 'coverage.html' > "${TEST_RESULTS}/coverage.lst" + tar -n -cf - -T "${TEST_RESULTS}/coverage.lst" | tar -C "${TEST_RESULTS}" -xvf - + + - store_test_results: + path: /tmp/test-results workflows: version: 2.1 @@ -60,4 +70,4 @@ workflows: - integration: matrix: parameters: - integ: [gocql, mongo-driver] + integ: [test-gocql, test-mongo-driver] diff --git a/.circleci/wait.sh b/.circleci/wait.sh new file mode 100755 index 00000000000..a1cfd67ee66 --- /dev/null +++ b/.circleci/wait.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +wait_for_cassandra () { + for i in 1 2 3 4 5; do + if docker exec $1 nodetool status | grep "^UN"; then + exit 0 + fi + echo "Cassandra not yet available" + sleep 10 + done + echo "Timeout waiting for cassandra to initialize" + exit 1 +} + +wait_for_mongo () { + for i in 1 2 3 4 5; do + if docker exec $1 mongo; then + exit 0 + fi + echo "Mongo not yet available..." + sleep 10 + done + echo "Timeout waiting for mongo to initialize" + exit 1 +} + +if [ -z "$CMD" ]; then + echo "CMD is undefined. exiting..." + exit 1 +elif [ -z "$IMG_NAME" ]; then + echo "IMG_NAME is undefined. exiting..." + exit 1 +fi + +if [ "$CMD" == "cassandra" ]; then + wait_for_cassandra $IMG_NAME +elif [ "$CMD" == "mongo" ]; then + wait_for_mongo $IMG_NAME +else + echo "unknown CMD" + exit 1 +fi diff --git a/Makefile b/Makefile index e0dc139e440..ddac2641c0d 100644 --- a/Makefile +++ b/Makefile @@ -55,33 +55,23 @@ test-with-coverage: ci: precommit check-clean-work-tree test-with-coverage test-386 .PHONY: test-gocql -cassandra: +test-gocql: set -e; \ docker run --name cass-integ --rm -p 9042:9042 -d cassandra:3; \ - for i in 1 2 3 4; do \ - if docker exec cass-integ nodetool status | grep "^UN"; then \ - break; \ - fi; \ - echo "cassandra not yet ready..."; \ - sleep 10; \ - done; \ + CMD=cassandra IMG_NAME=cass-integ ./.circleci/wait.sh (cd instrumentation/github.com/gocql/gocql && \ - INTEGRATION=gocql go test); \ + $(GOTEST_WITH_COVERAGE) . && \ + go tool cover -html=coverage.txt -o coverage.html); \ docker stop cass-integ; \ .PHONY: test-mongo-driver test-mongo-driver: set -e; \ docker run --name mongo-integ --rm -p 27017:27017 -d mongo; \ - for i in 1 2 3 4; do \ - if docker logs --tail mongo-integ | grep "waiting for connections on port 27017"; then \ - break; \ - fi; \ - echo "mongo not yet ready..."; \ - sleep 10; \ - done; \ + CMD=mongo IMG_NAME=mongo-integ ./.circleci/wait.sh (cd instrumentation/go.mongodb.org/mongo-driver && \ - INTEGRATION=mongo-driver go test); \ + $(GOTEST_WITH_COVERAGE) . && \ + go tool cover -html=coverage.txt -o coverage.html); \ docker stop mongo-integ; \ .PHONY: check-clean-work-tree diff --git a/instrumentation/github.com/gocql/gocql/gocql_test.go b/instrumentation/github.com/gocql/gocql/gocql_test.go index 4c837e5f75e..6a069e89179 100644 --- a/instrumentation/github.com/gocql/gocql/gocql_test.go +++ b/instrumentation/github.com/gocql/gocql/gocql_test.go @@ -521,7 +521,7 @@ func afterEach() { } func TestMain(m *testing.M) { - util.IntegrationShouldRun("gocql") + util.IntegrationShouldRun("test-gocql") beforeAll() os.Exit(m.Run()) } diff --git a/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go b/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go index 0557e0fe67d..2e29ccdc32e 100644 --- a/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go +++ b/instrumentation/go.mongodb.org/mongo-driver/mongo_test.go @@ -31,7 +31,7 @@ import ( ) func TestMain(m *testing.M) { - util.IntegrationShouldRun("mongo-driver") + util.IntegrationShouldRun("test-mongo-driver") os.Exit(m.Run()) } From 67b8fe9c254e9c8dd918160cf48796c539c28191 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 4 Aug 2020 21:59:02 +0000 Subject: [PATCH 08/14] chore: add more description to config --- .circleci/config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e5fcadc1eb..1e558244e84 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,15 +37,16 @@ jobs: integration: parameters: - integ: + target: type: string + description: "The makefile target that will run the tests for the integration." machine: image: ubuntu-1604:202004-01 environment: TEST_RESULTS: /tmp/test-results # path to where test results will be saved - INTEGRATION: << parameters.integ >> + INTEGRATION: << parameters.target >> steps: - checkout @@ -70,4 +71,4 @@ workflows: - integration: matrix: parameters: - integ: [test-gocql, test-mongo-driver] + target: [test-gocql, test-mongo-driver] From b9df045fa4de460650e377ff6f762449e4d16c47 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Tue, 4 Aug 2020 22:18:51 +0000 Subject: [PATCH 09/14] fix: create separate workflow for integration tests --- .circleci/config.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1e558244e84..790b77f5794 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,6 +68,8 @@ workflows: build_and_test: jobs: - build + integration_test: + jobs: - integration: matrix: parameters: From 3d4ca564ce60b0ca22889d5cd881fc75f9a49333 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Wed, 5 Aug 2020 16:05:04 +0000 Subject: [PATCH 10/14] feat: add restore cache and artifact upload --- .circleci/config.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 790b77f5794..e2c38737a7c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,6 +52,10 @@ jobs: - checkout - run: mkdir -p $TEST_RESULTS + + - restore_cache: # restores saved cache if no changes are detected since last run + keys: + - go-pkg-mod-{{ checksum "go.sum" }} - run: name: "Integration test $INTEGRATION" @@ -60,6 +64,15 @@ jobs: find . -name 'coverage.html' > "${TEST_RESULTS}/coverage.lst" tar -n -cf - -T "${TEST_RESULTS}/coverage.lst" | tar -C "${TEST_RESULTS}" -xvf - + - save_cache: + key: go-pkg-mod-{{ checksum "go.sum" }} + paths: + - "/go/pkg/mod" + + - store_artifacts: + path: /tmp/test-results + destination: opentelemetry-go-contrib-test-output + - store_test_results: path: /tmp/test-results From 90546dac44b98756564054ec6380f5dab5aadd41 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Wed, 5 Aug 2020 22:50:00 +0000 Subject: [PATCH 11/14] fix: address pr feedback by wrapping variables in quotes --- .circleci/wait.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.circleci/wait.sh b/.circleci/wait.sh index a1cfd67ee66..aa586b3f769 100755 --- a/.circleci/wait.sh +++ b/.circleci/wait.sh @@ -1,8 +1,22 @@ #!/bin/bash +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + wait_for_cassandra () { - for i in 1 2 3 4 5; do - if docker exec $1 nodetool status | grep "^UN"; then + for ((i = 0; i < 5; ++i)); do + if docker exec "$1" nodetool status | grep "^UN"; then exit 0 fi echo "Cassandra not yet available" @@ -13,8 +27,8 @@ wait_for_cassandra () { } wait_for_mongo () { - for i in 1 2 3 4 5; do - if docker exec $1 mongo; then + for ((i = 0; i < 5; ++i)); do + if docker exec "$1" mongo; then exit 0 fi echo "Mongo not yet available..." @@ -33,9 +47,9 @@ elif [ -z "$IMG_NAME" ]; then fi if [ "$CMD" == "cassandra" ]; then - wait_for_cassandra $IMG_NAME + wait_for_cassandra "$IMG_NAME" elif [ "$CMD" == "mongo" ]; then - wait_for_mongo $IMG_NAME + wait_for_mongo "$IMG_NAME" else echo "unknown CMD" exit 1 From 5e367170c6f1073742fe351ce14750fc49a34892 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Wed, 5 Aug 2020 23:53:21 +0000 Subject: [PATCH 12/14] feat: skip integration tests if no changes have been made to module --- .circleci/should_build.sh | 37 +++++++++++++++++++++++++++++++++++++ Makefile | 32 ++++++++++++++++++-------------- 2 files changed, 55 insertions(+), 14 deletions(-) create mode 100755 .circleci/should_build.sh diff --git a/.circleci/should_build.sh b/.circleci/should_build.sh new file mode 100755 index 00000000000..1dce3107d02 --- /dev/null +++ b/.circleci/should_build.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# Copyright The OpenTelemetry Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Returns 0 (true) when the current diff contains files in the provided +# target directory. TARGET should be a unique package name in the directory +# structure. For example, for the gocql integration, set TARGET=gocql so that +# a diff in any of the files in the instrumentation/gocql/gocql directory +# will be picked up by the grep. Diffs are compared against the master branch. + +TARGET=$1 + +if [ -z "$TARGET" ]; then + echo "TARGET is undefined" + exit 1 +fi + +if git diff --name-only origin/master HEAD | grep -q "$TARGET"; then + exit 0 +else + exit 1 +fi + + + diff --git a/Makefile b/Makefile index ddac2641c0d..34d34c565cf 100644 --- a/Makefile +++ b/Makefile @@ -56,23 +56,27 @@ ci: precommit check-clean-work-tree test-with-coverage test-386 .PHONY: test-gocql test-gocql: - set -e; \ - docker run --name cass-integ --rm -p 9042:9042 -d cassandra:3; \ - CMD=cassandra IMG_NAME=cass-integ ./.circleci/wait.sh - (cd instrumentation/github.com/gocql/gocql && \ - $(GOTEST_WITH_COVERAGE) . && \ - go tool cover -html=coverage.txt -o coverage.html); \ - docker stop cass-integ; \ + @if ./.circleci/should_build.sh gocql; then \ + set -e; \ + docker run --name cass-integ --rm -p 9042:9042 -d cassandra:3; \ + CMD=cassandra IMG_NAME=cass-integ ./.circleci/wait.sh; \ + (cd instrumentation/github.com/gocql/gocql && \ + $(GOTEST_WITH_COVERAGE) . && \ + go tool cover -html=coverage.txt -o coverage.html); \ + docker stop cass-integ; \ + fi .PHONY: test-mongo-driver test-mongo-driver: - set -e; \ - docker run --name mongo-integ --rm -p 27017:27017 -d mongo; \ - CMD=mongo IMG_NAME=mongo-integ ./.circleci/wait.sh - (cd instrumentation/go.mongodb.org/mongo-driver && \ - $(GOTEST_WITH_COVERAGE) . && \ - go tool cover -html=coverage.txt -o coverage.html); \ - docker stop mongo-integ; \ + @if ./.circleci/should_build.sh mongo-driver; then \ + set -e; \ + docker run --name mongo-integ --rm -p 27017:27017 -d mongo; \ + CMD=mongo IMG_NAME=mongo-integ ./.circleci/wait.sh; \ + (cd instrumentation/go.mongodb.org/mongo-driver && \ + $(GOTEST_WITH_COVERAGE) . && \ + go tool cover -html=coverage.txt -o coverage.html); \ + docker stop mongo-integ; \ + fi .PHONY: check-clean-work-tree check-clean-work-tree: From 9bab12cd5fbbdeb99963ca50c2c0b20d6e818486 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Thu, 6 Aug 2020 00:41:21 +0000 Subject: [PATCH 13/14] fix: remove cache restoration now that tests are skipped --- .circleci/config.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e2c38737a7c..e7641b41f55 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -52,10 +52,6 @@ jobs: - checkout - run: mkdir -p $TEST_RESULTS - - - restore_cache: # restores saved cache if no changes are detected since last run - keys: - - go-pkg-mod-{{ checksum "go.sum" }} - run: name: "Integration test $INTEGRATION" @@ -63,11 +59,6 @@ jobs: make $INTEGRATION find . -name 'coverage.html' > "${TEST_RESULTS}/coverage.lst" tar -n -cf - -T "${TEST_RESULTS}/coverage.lst" | tar -C "${TEST_RESULTS}" -xvf - - - - save_cache: - key: go-pkg-mod-{{ checksum "go.sum" }} - paths: - - "/go/pkg/mod" - store_artifacts: path: /tmp/test-results From 961589e5ebc811a68d5ef18b3c6c62e795028329 Mon Sep 17 00:00:00 2001 From: reggiemcdonald Date: Thu, 6 Aug 2020 00:47:36 +0000 Subject: [PATCH 14/14] chore: added echo for when tests are skipped --- .circleci/should_build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/should_build.sh b/.circleci/should_build.sh index 1dce3107d02..1dadd0df45d 100755 --- a/.circleci/should_build.sh +++ b/.circleci/should_build.sh @@ -30,6 +30,7 @@ fi if git diff --name-only origin/master HEAD | grep -q "$TARGET"; then exit 0 else + echo "no changes found for $TARGET. skipping tests..." exit 1 fi