From c97aa4dcc145000d375d8525ab94a5cb5f4b927f Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 08:33:34 -0700 Subject: [PATCH 01/11] parallel travis tests --- .travis.yml | 9 ++++++-- test.sh | 62 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8ee9018184..017ff71448 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,13 @@ language: go os: linux - env: - - GOPROXY=https://proxy.golang.org + global: + - GOPROXY=https://proxy.golang.org + matrix: + - TESTSUITE_LINT=true + - TESTSUITE_BOILERPLATE=true + - TESTSUITE_UNIT=true + matrix: include: - go: 1.12.9 diff --git a/test.sh b/test.sh index e052ed6045..11ea3720f1 100755 --- a/test.sh +++ b/test.sh @@ -15,41 +15,49 @@ # limitations under the License. set -eu -o pipefail - +# TODO: fix exit code numbers +# TODO: make test should work locally as it was before exitcode=0 echo "= go mod ================================================================" go mod download 2>&1 | grep -v "go: finding" || true go mod tidy -v && echo ok || ((exitcode += 2)) -echo "= make lint =============================================================" -make -s lint-ci && echo ok || ((exitcode += 4)) - -echo "= boilerplate ===========================================================" -readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python) -readonly BDIR="./hack/boilerplate" -missing="$($PYTHON ${BDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BDIR} | egrep -v '/assets.go|/translations.go|/site/themes/|/site/node_modules|\./out|/hugo/' || true)" -if [[ -n "${missing}" ]]; then - echo "boilerplate missing: $missing" - echo "consider running: ${BDIR}/fix.sh" - ((exitcode += 4)) -else - echo "ok" +if [ ! -z "$TESTSUITE_LINT"] then + echo "= make lint =============================================================" + make -s lint-ci && echo ok || ((exitcode += 4)) fi -echo "= schema_check ==========================================================" -go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 8)) -echo "= go test ===============================================================" -cov_tmp="$(mktemp)" -readonly COVERAGE_PATH=./out/coverage.txt -echo "mode: count" >"${COVERAGE_PATH}" -pkgs=$(go list -f '{{ if .TestGoFiles }}{{.ImportPath}}{{end}}' ./cmd/... ./pkg/... | xargs) -go test \ - -tags "container_image_ostree_stub containers_image_openpgp" \ - -covermode=count \ - -coverprofile="${cov_tmp}" \ - ${pkgs} && echo ok || ((exitcode += 16)) -tail -n +2 "${cov_tmp}" >>"${COVERAGE_PATH}" +if [ ! -z "$TESTSUITE_BOILERPLATE"] then + echo "= boilerplate ===========================================================" + readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python) + readonly BDIR="./hack/boilerplate" + missing="$($PYTHON ${BDIR}/boilerplate.py --rootdir . --boilerplate-dir ${BDIR} | egrep -v '/assets.go|/translations.go|/site/themes/|/site/node_modules|\./out|/hugo/' || true)" + if [[ -n "${missing}" ]]; then + echo "boilerplate missing: $missing" + echo "consider running: ${BDIR}/fix.sh" + ((exitcode += 4)) + else + echo "ok" + fi + echo "= schema_check ==========================================================" + go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 8)) +fi + + +if [ ! -z "$TESTSUITE_UNIT"] then + echo "= go test ===============================================================" + cov_tmp="$(mktemp)" + readonly COVERAGE_PATH=./out/coverage.txt + echo "mode: count" >"${COVERAGE_PATH}" + pkgs=$(go list -f '{{ if .TestGoFiles }}{{.ImportPath}}{{end}}' ./cmd/... ./pkg/... | xargs) + go test \ + -tags "container_image_ostree_stub containers_image_openpgp" \ + -covermode=count \ + -coverprofile="${cov_tmp}" \ + ${pkgs} && echo ok || ((exitcode += 16)) + tail -n +2 "${cov_tmp}" >>"${COVERAGE_PATH}" +fi exit "${exitcode}" From f2cba872c49383b4c8aba6f4fdd7a2f9c8b09f5d Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 08:39:43 -0700 Subject: [PATCH 02/11] move duplicate language to reduce extra travis vm --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 017ff71448..21daaf48b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,3 @@ -language: go -os: linux env: global: - GOPROXY=https://proxy.golang.org @@ -10,6 +8,7 @@ env: matrix: include: + - os: linux - go: 1.12.9 - language: python before_install: pip install flake8 From a654a3e3aef8309440942f932a229a653bedf6a0 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 08:45:05 -0700 Subject: [PATCH 03/11] move language up --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 21daaf48b6..9ad3c7d095 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,8 @@ +os: linux +language: go +go: + - 1.12.9 + env: global: - GOPROXY=https://proxy.golang.org @@ -8,8 +13,6 @@ env: matrix: include: - - os: linux - - go: 1.12.9 - language: python before_install: pip install flake8 script: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics From daab6ca8c57584177007a63b9f2162bb16141269 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 09:14:53 -0700 Subject: [PATCH 04/11] use include in travis for multi vm --- .travis.yml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ad3c7d095..7caadc61f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,6 @@ go: env: global: - GOPROXY=https://proxy.golang.org - matrix: - - TESTSUITE_LINT=true - - TESTSUITE_BOILERPLATE=true - - TESTSUITE_UNIT=true matrix: include: @@ -17,14 +13,28 @@ matrix: before_install: pip install flake8 script: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics -before_install: - - sudo apt-get install -y libvirt-dev -install: - - echo "Don't run anything." -script: - - make test + - language: python + env: + - TESTSUITE_BOILERPLATE=true + script: make test + + - language: go + go: 1.12.9 + env: + - TESTSUITE_LINT=true + script: make test + + - language: go + go: 1.12.9 + env: + - TESTSUITE_UNIT=true + # before_install: + # - sudo apt-get install -y libvirt-dev + script: make test + after_success: - bash <(curl -s https://codecov.io/bash) + notifications: webhooks: https://www.travisbuddy.com/ on_success: never # travisbuddy don't comment on successful \ No newline at end of file From 9cb3f99a337f9ac8251f0c24d42cff2907b4620d Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 09:54:30 -0700 Subject: [PATCH 05/11] run make test locally --- test.sh | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/test.sh b/test.sh index 11ea3720f1..1cd105b384 100755 --- a/test.sh +++ b/test.sh @@ -14,22 +14,37 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -eu -o pipefail +set -e -o pipefail # TODO: fix exit code numbers # TODO: make test should work locally as it was before +if [[ -z "$TESTSUITE_LINT" && -z "$TESTSUITE_UNIT" && -z "$TESTSUITE_BOILERPLATE" ]] +then # if all of them are not set then it is a local run + TESTSUITE_LINT=true + TESTSUITE_UNIT=true + TESTSUITE_BOILETPLATE=true +fi + exitcode=0 -echo "= go mod ================================================================" -go mod download 2>&1 | grep -v "go: finding" || true -go mod tidy -v && echo ok || ((exitcode += 2)) +if [[ ! -z "$TESTSUITE_LINT" ]] +then + echo "= make lint =============================================================" + make -s lint-ci && echo ok || ((exitcode += 4)) + echo "= go mod ================================================================" + go mod download 2>&1 | grep -v "go: finding" || true + go mod tidy -v && echo ok || ((exitcode += 2)) +fi -if [ ! -z "$TESTSUITE_LINT"] then + +if [[ ! -z "$TESTSUITE_LINT" ]] +then echo "= make lint =============================================================" make -s lint-ci && echo ok || ((exitcode += 4)) fi -if [ ! -z "$TESTSUITE_BOILERPLATE"] then +if [[ ! -z "$TESTSUITE_BOILERPLATE" ]] +then echo "= boilerplate ===========================================================" readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python) readonly BDIR="./hack/boilerplate" @@ -46,7 +61,8 @@ if [ ! -z "$TESTSUITE_BOILERPLATE"] then fi -if [ ! -z "$TESTSUITE_UNIT"] then +if [[ ! -z "$TESTSUITE_UNIT" ]] +then echo "= go test ===============================================================" cov_tmp="$(mktemp)" readonly COVERAGE_PATH=./out/coverage.txt From 3aece1262af03c438dca3b3ed15fbd2bf0b766c1 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 10:17:42 -0700 Subject: [PATCH 06/11] install libvirt travis --- .travis.yml | 7 ++++--- test.sh | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7caadc61f7..18d9da84f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ go: env: global: - GOPROXY=https://proxy.golang.org - matrix: include: - language: python @@ -22,14 +21,16 @@ matrix: go: 1.12.9 env: - TESTSUITE_LINT=true + before_install: + - sudo apt-get install -y libvirt-dev script: make test - language: go go: 1.12.9 env: - TESTSUITE_UNIT=true - # before_install: - # - sudo apt-get install -y libvirt-dev + before_install: + - sudo apt-get install -y libvirt-dev script: make test after_success: diff --git a/test.sh b/test.sh index 1cd105b384..610ffb4c50 100755 --- a/test.sh +++ b/test.sh @@ -16,7 +16,6 @@ set -e -o pipefail # TODO: fix exit code numbers -# TODO: make test should work locally as it was before if [[ -z "$TESTSUITE_LINT" && -z "$TESTSUITE_UNIT" && -z "$TESTSUITE_BOILERPLATE" ]] then # if all of them are not set then it is a local run TESTSUITE_LINT=true From 9b99de5806ecf2ba2634038551a14791c56d589f Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 10:31:15 -0700 Subject: [PATCH 07/11] travis golang --- .travis.yml | 6 ++---- test.sh | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18d9da84f9..fb70815c87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,13 +8,11 @@ env: - GOPROXY=https://proxy.golang.org matrix: include: - - language: python - before_install: pip install flake8 - script: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - - language: python env: - TESTSUITE_BOILERPLATE=true + before_install: + - pip install flake8 && flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics script: make test - language: go diff --git a/test.sh b/test.sh index 610ffb4c50..5b4d8118e7 100755 --- a/test.sh +++ b/test.sh @@ -55,13 +55,14 @@ then else echo "ok" fi - echo "= schema_check ==========================================================" - go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 8)) fi if [[ ! -z "$TESTSUITE_UNIT" ]] then + echo "= schema_check ==========================================================" + go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 8)) + echo "= go test ===============================================================" cov_tmp="$(mktemp)" readonly COVERAGE_PATH=./out/coverage.txt From e2f91f0933fef4dc876621b7a39ac84edb7fcf6e Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 11:20:28 -0700 Subject: [PATCH 08/11] travis parallel refactor --- .travis.yml | 6 +++--- test.sh | 30 +++++++++--------------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index fb70815c87..6302d576be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ matrix: include: - language: python env: - - TESTSUITE_BOILERPLATE=true + - TESTSUITE=boilerplate before_install: - pip install flake8 && flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics script: make test @@ -18,7 +18,7 @@ matrix: - language: go go: 1.12.9 env: - - TESTSUITE_LINT=true + - TESTSUITE=lint before_install: - sudo apt-get install -y libvirt-dev script: make test @@ -26,7 +26,7 @@ matrix: - language: go go: 1.12.9 env: - - TESTSUITE_UNIT=true + - TESTSUITE=unittest before_install: - sudo apt-get install -y libvirt-dev script: make test diff --git a/test.sh b/test.sh index 5b4d8118e7..e989e296a4 100755 --- a/test.sh +++ b/test.sh @@ -14,18 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -e -o pipefail -# TODO: fix exit code numbers -if [[ -z "$TESTSUITE_LINT" && -z "$TESTSUITE_UNIT" && -z "$TESTSUITE_BOILERPLATE" ]] -then # if all of them are not set then it is a local run - TESTSUITE_LINT=true - TESTSUITE_UNIT=true - TESTSUITE_BOILETPLATE=true -fi +set -eu -o pipefail +TESTSUITE="${TESTSUITE:-all}" exitcode=0 -if [[ ! -z "$TESTSUITE_LINT" ]] +if [ "$TESTSUITE" = "lint" ] || [ "$TESTSUITE" = "all" ] then echo "= make lint =============================================================" make -s lint-ci && echo ok || ((exitcode += 4)) @@ -35,15 +29,9 @@ then fi -if [[ ! -z "$TESTSUITE_LINT" ]] -then - echo "= make lint =============================================================" - make -s lint-ci && echo ok || ((exitcode += 4)) -fi - -if [[ ! -z "$TESTSUITE_BOILERPLATE" ]] -then +if [ "$TESTSUITE" = "boilerplate" ] || [ "$TESTSUITE" = "all" ] +then echo "= boilerplate ===========================================================" readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python) readonly BDIR="./hack/boilerplate" @@ -51,17 +39,17 @@ then if [[ -n "${missing}" ]]; then echo "boilerplate missing: $missing" echo "consider running: ${BDIR}/fix.sh" - ((exitcode += 4)) + ((exitcode += 8)) else echo "ok" fi fi -if [[ ! -z "$TESTSUITE_UNIT" ]] +if [ "$TESTSUITE" = "unittest" ] || [ "$TESTSUITE" = "all" ] then echo "= schema_check ==========================================================" - go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 8)) + go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 16)) echo "= go test ===============================================================" cov_tmp="$(mktemp)" @@ -72,7 +60,7 @@ then -tags "container_image_ostree_stub containers_image_openpgp" \ -covermode=count \ -coverprofile="${cov_tmp}" \ - ${pkgs} && echo ok || ((exitcode += 16)) + ${pkgs} && echo ok || ((exitcode += 32)) tail -n +2 "${cov_tmp}" >>"${COVERAGE_PATH}" fi From c5121099cf8d4e8d1ccb2c586cae3846776c1b8a Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 11:29:21 -0700 Subject: [PATCH 09/11] give name to each test --- .travis.yml | 3 +++ test.sh | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6302d576be..cebb7d96de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ env: matrix: include: - language: python + name: Check Boilerplate env: - TESTSUITE=boilerplate before_install: @@ -16,6 +17,7 @@ matrix: script: make test - language: go + name: Code Lint go: 1.12.9 env: - TESTSUITE=lint @@ -24,6 +26,7 @@ matrix: script: make test - language: go + name: Unit Test go: 1.12.9 env: - TESTSUITE=unittest diff --git a/test.sh b/test.sh index e989e296a4..2c0abe720d 100755 --- a/test.sh +++ b/test.sh @@ -16,7 +16,7 @@ set -eu -o pipefail -TESTSUITE="${TESTSUITE:-all}" +TESTSUITE="${TESTSUITE:-all}" # if env variable not set run all the tests exitcode=0 if [ "$TESTSUITE" = "lint" ] || [ "$TESTSUITE" = "all" ] From ff26fb3ab7afbd45fac176c30ee6483c95718417 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 11:48:40 -0700 Subject: [PATCH 10/11] make codecov bot to comment on PRs --- .codecov.yml | 8 +++++++- .travis.yml | 3 --- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 69cb76019a..17faa8c54f 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1 +1,7 @@ -comment: false +comment: + layout: "reach, diff, flags, files" + behavior: default + require_changes: false # if true: only post the comment if coverage changes + require_base: no # [yes :: must have a base report to post] + require_head: yes # [yes :: must have a head report to post] + branches: null # branch names that can post comment \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index cebb7d96de..b92c54b6e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ os: linux language: go go: - 1.12.9 - env: global: - GOPROXY=https://proxy.golang.org @@ -33,10 +32,8 @@ matrix: before_install: - sudo apt-get install -y libvirt-dev script: make test - after_success: - bash <(curl -s https://codecov.io/bash) - notifications: webhooks: https://www.travisbuddy.com/ on_success: never # travisbuddy don't comment on successful \ No newline at end of file From 5d8bdde83a62b573f69db12b1dc9ed5ed7c9263b Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 25 Sep 2019 13:16:16 -0700 Subject: [PATCH 11/11] use [[ instead of [ --- test.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.sh b/test.sh index 2c0abe720d..c6173fb5b8 100755 --- a/test.sh +++ b/test.sh @@ -19,7 +19,7 @@ set -eu -o pipefail TESTSUITE="${TESTSUITE:-all}" # if env variable not set run all the tests exitcode=0 -if [ "$TESTSUITE" = "lint" ] || [ "$TESTSUITE" = "all" ] +if [[ "$TESTSUITE" = "lint" ]] || [[ "$TESTSUITE" = "all" ]] then echo "= make lint =============================================================" make -s lint-ci && echo ok || ((exitcode += 4)) @@ -30,7 +30,7 @@ fi -if [ "$TESTSUITE" = "boilerplate" ] || [ "$TESTSUITE" = "all" ] +if [[ "$TESTSUITE" = "boilerplate" ]] || [[ "$TESTSUITE" = "all" ]] then echo "= boilerplate ===========================================================" readonly PYTHON=$(type -P python || echo docker run --rm -it -v $(pwd):/minikube -w /minikube python python) @@ -46,7 +46,7 @@ then fi -if [ "$TESTSUITE" = "unittest" ] || [ "$TESTSUITE" = "all" ] +if [[ "$TESTSUITE" = "unittest" ]] || [[ "$TESTSUITE" = "all" ]] then echo "= schema_check ==========================================================" go run deploy/minikube/schema_check.go >/dev/null && echo ok || ((exitcode += 16))