Files
kustomize/travis/pre-commit.sh
jregan a7df00c07a Starting v3 release for plugin developers.
[doc]: https://github.com/golang/go/wiki/Modules#releasing-modules-v2-or-higher

Per this Go modules [doc] a repo or branch that's
already tagged v2 or higher should increment the major
version (e.g. go to v3) when releasing their first Go
module-based packages.

At the moment, the kustomize repo has these top level
packages in the sigs.k8s.io/kustomize module:

 - `cmd` - holds main program for kustomize

	 Conceivably someone can depend on this
	 package for integration tests.

 - `internal` - intentionally unreleased subpackages

 - `k8sdeps` - an adapter wrapping k8s dependencies

	 This exists only for use in pre-Go-modules kustomize-into-kubectl
	 integration and won't live much longer (as everything involved is
	 switching to Go modules).

 - `pkg` - kustomize packages for export

	 This should shrink in later versions, since
	 the surface area is too large, containing
	 sub-packages that should be in 'internal'.

 - `plugin` - holds main programs for plugins

This PR changes the top level go.mod file from

```
module sigs.k8s.io/kustomize
```

to

```
module sigs.k8s.io/kustomize/v3
```

and adjusts all import statements to
reflect the change.
2019-06-23 15:05:59 -07:00

120 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
set -e
# Make sure, we run in the root of the repo and
# therefore run the tests on all packages
base_dir="$( cd "$(dirname "$0")/.." && pwd )"
cd "$base_dir" || {
echo "Cannot cd to '$base_dir'. Aborting." >&2
exit 1
}
rc=0
function runFunc {
local name=$1
local result="SUCCESS"
printf "============== begin %s\n" "$name"
$name
local code=$?
rc=$((rc || $code))
if [ $code -ne 0 ]; then
result="FAILURE"
fi
printf "============== end %s : %s code=%d\n\n\n" "$name" "$result" $code
}
function testGoLangCILint {
golangci-lint run ./...
}
function testGoTest {
go test -v ./...
}
# These tests require the helm program, and at the moment
# we're not asking travis to install helm.
function testNoTravisGoTest {
go test -v sigs.k8s.io/kustomize/v3/pkg/target \
-run TestChartInflatorPlugin -tags=notravis
go test -v sigs.k8s.io/kustomize/v3/plugin/someteam.example.com/v1/chartinflator/... \
-run TestChartInflator -tags=notravis
mdrip --mode test --label helmtest README.md ./examples/chart.md
go test -v sigs.k8s.io/kustomize/v3/plugin/someteam.example.com/v1/validator/... \
-run TestValidatorHappy -tags=notravis
go test -v sigs.k8s.io/kustomize/v3/plugin/someteam.example.com/v1/validator/... \
-run TestValidatorUnHappy -tags=notravis
}
function testExamples {
mdrip --mode test --label test README.md ./examples
}
function generateCode {
./plugin/generateBuiltins.sh $oldGoPath
}
# Use of GOPATH is optional if go modules are
# used. This script tries to work for people who
# don't have GOPATH set, and work for travis.
#
# Upon entry, travis has GOPATH set, and used it
# to install mdrip and the like.
#
# Use GOPATH to define XDG_CONFIG_HOME, then unset
# GOPATH so that go.mod is unambiguously honored.
echo "GOPATH=$GOPATH"
if [ -z ${GOPATH+x} ]; then
echo GOPATH is unset
tmp=$HOME/gopath
if [ -d "$tmp" ]; then
oldGoPath=$tmp
else
tmp=$HOME/go
if [ -d "$tmp" ]; then
oldGoPath=$tmp
fi
fi
else
oldGoPath=$GOPATH
unset GOPATH
fi
echo "oldGoPath=$oldGoPath"
export XDG_CONFIG_HOME=$oldGoPath/src/sigs.k8s.io
echo "XDG_CONFIG_HOME=$XDG_CONFIG_HOME"
if [ ! -d "$XDG_CONFIG_HOME" ]; then
echo "$XDG_CONFIG_HOME is not a directory."
exit 1
fi
# Until go v1.13, set this explicitly.
export GO111MODULE=on
echo "HOME=$HOME"
echo "GOPATH=$GOPATH"
echo "GO111MODULE=$GO111MODULE"
echo pwd=`pwd`
echo " "
echo "Working..."
runFunc generateCode
runFunc testGoLangCILint
runFunc testGoTest
if [ -z ${TRAVIS+x} ]; then
echo Not on travis, so running the notravis tests
runFunc testNoTravisGoTest
fi
PATH=$HOME/go/bin:$PATH
runFunc testExamples
if [ $rc -eq 0 ]; then
echo "SUCCESS!"
else
echo "FAILURE; exit code $rc"
fi
exit $rc