Adjust scripts to be go v1.14 compatible

This commit is contained in:
jregan
2020-04-22 18:34:15 -07:00
parent 59b1662b92
commit 53e7c87604
4 changed files with 35 additions and 26 deletions

View File

@@ -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; \

15
hack/shellHelpers.sh Normal file
View File

@@ -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
}

View File

@@ -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}."

View File

@@ -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