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

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