diff --git a/Makefile b/Makefile index 677a7c460..186f2d2a2 100644 --- a/Makefile +++ b/Makefile @@ -218,10 +218,6 @@ test-unit-cmd-all: test-go-mod: ./travis/check-go-mod.sh -.PHONY: -test-examples-kustomize-against-HEAD: $(MYGOBIN)/kustomize $(MYGOBIN)/mdrip - ./hack/testExamplesAgainstKustomize.sh HEAD - .PHONY: test-examples-e2e-kustomize: $(MYGOBIN)/mdrip $(MYGOBIN)/kind ( \ @@ -232,13 +228,17 @@ test-examples-e2e-kustomize: $(MYGOBIN)/mdrip $(MYGOBIN)/kind ./hack/testExamplesE2EAgainstKustomize.sh .; \ ) +.PHONY: +test-examples-kustomize-against-HEAD: $(MYGOBIN)/kustomize $(MYGOBIN)/mdrip + ./hack/testExamplesAgainstKustomize.sh HEAD + .PHONY: test-examples-kustomize-against-latest: $(MYGOBIN)/mdrip ( \ set -e; \ /bin/rm -f $(MYGOBIN)/kustomize; \ echo "Installing kustomize from latest."; \ - GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/v3; \ + GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/v3@v3.5.4; \ ./hack/testExamplesAgainstKustomize.sh latest; \ echo "Reinstalling kustomize from HEAD."; \ cd kustomize; go install .; \ @@ -289,6 +289,10 @@ $(MYGOBIN)/helmV3: rm -rf $$d \ ) +# Default version of helm is v2 for the time being. +$(MYGOBIN)/helm: $(MYGOBIN)/helmV2 + ln -s $(MYGOBIN)/helmV2 $(MYGOBIN)/helm + $(MYGOBIN)/kind: ( \ set -e; \ diff --git a/hack/shellHelpers.sh b/hack/shellHelpers.sh new file mode 100644 index 000000000..8bb622a89 --- /dev/null +++ b/hack/shellHelpers.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Copyright 2019 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +# TODO: Make the code ignorant of the CI environment "brand name". +# We used to run CI tests on travis, and disabled certain tests +# when running there. Now we run on Prow, so look for that. +# https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md +# Might be useful to eschew using the brand name of the CI environment +# (replace "travis" with "RemoteCI" or something - not just switch to "prow"). + +function onLinuxAndNotOnRemoteCI { + [[ ("linux" == "$(go env GOOS)") && (-z ${PROW_JOB_ID+x}) ]] && return + false +} diff --git a/hack/testExamplesAgainstKustomize.sh b/hack/testExamplesAgainstKustomize.sh index eb186cc40..da1e147d2 100755 --- a/hack/testExamplesAgainstKustomize.sh +++ b/hack/testExamplesAgainstKustomize.sh @@ -9,10 +9,8 @@ set -o pipefail version=$1 -function onLinuxAndNotOnTravis { - [[ ("linux" == "$(go env GOOS)") && (-z ${TRAVIS+x}) ]] && return - false -} +# All hack scripts should run from top level. +. hack/shellHelpers.sh # TODO: change the label? # We test against the latest release, and HEAD, and presumably @@ -22,13 +20,12 @@ mdrip --mode test \ --label testAgainstLatestRelease examples # TODO: make work for non-linux -if onLinuxAndNotOnTravis; then - echo "On linux, and not on travis, so running the notravis example tests." +if onLinuxAndNotOnRemoteCI; then + echo "On linux, and not on remote CI. Running expensive tests." # Requires helm. make $(go env GOPATH)/bin/helm - mdrip --mode test \ - --label helmtest examples/chart.md + mdrip --mode test --label helmtest examples/chart.md fi echo "Example tests passed against ${version}." diff --git a/hack/testUnitKustomizePlugins.sh b/hack/testUnitKustomizePlugins.sh index 354fa652b..da1103040 100755 --- a/hack/testUnitKustomizePlugins.sh +++ b/hack/testUnitKustomizePlugins.sh @@ -14,27 +14,19 @@ set -o pipefail rcAccumulator=0 -function onLinuxAndNotOnTravis { - # TODO: Make the code ignorant of the CI environment "brand name". - # We used to run CI tests on travis, and disabled certain tests - # when running there. Now we run on Prow, so look for that. - # https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md - # Should eschew using the brand name of the CI environment - # (replace "travis" with "CI_env" or something - not just switch to "prow"). - [[ ("linux" == "$(go env GOOS)") && (-z ${$PROW_JOB_ID+x}) ]] && return - false -} +# All hack scripts should run from top level. +. hack/shellHelpers.sh function runTest { local file=$1 local code=0 if grep -q "// +build notravis" "$file"; then - if onLinuxAndNotOnTravis; then + if onLinuxAndNotOnRemoteCI; then go test -v -tags=notravis $file code=$? else # TODO: make work for non-linux - echo "Not on linux or on travis; skipping $file" + echo "Not on linux or on remote CI; skipping $file" fi else go test -v $file @@ -55,10 +47,11 @@ function scanDir { popd >& /dev/null } -if onLinuxAndNotOnTravis; then +if onLinuxAndNotOnRemoteCI; then # Some of these tests have special deps. make $(go env GOPATH)/bin/helmV2 make $(go env GOPATH)/bin/helmV3 + make $(go env GOPATH)/bin/helm make $(go env GOPATH)/bin/kubeval fi