mirror of https://github.com/knative/client.git
Use knative.dev/test-infra (#319)
This commit is contained in:
parent
71c39e822d
commit
9f203f2d4d
3
go.mod
3
go.mod
|
|
@ -20,7 +20,7 @@ require (
|
|||
github.com/knative/build v0.7.0 // indirect
|
||||
github.com/knative/pkg v0.0.0-20190617142447-13b093adc272
|
||||
github.com/knative/serving v0.6.0
|
||||
github.com/knative/test-infra v0.0.0-20190702025031-91d37e4abc30
|
||||
github.com/knative/test-infra v0.0.0-20190702025031-91d37e4abc30 // indirect
|
||||
github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||
|
|
@ -39,5 +39,6 @@ require (
|
|||
k8s.io/cli-runtime v0.0.0-20190325194458-f2b4781c3ae1
|
||||
k8s.io/client-go v0.0.0-20190226174127-78295b709ec6
|
||||
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 // indirect
|
||||
knative.dev/test-infra v0.0.0-20190730202142-17f2331e80ad
|
||||
sigs.k8s.io/yaml v1.1.0
|
||||
)
|
||||
|
|
|
|||
33
go.sum
33
go.sum
|
|
@ -157,21 +157,6 @@ github.com/knative/serving v0.5.2 h1:jsmeIN7B6oDHrK0jmtFRf7hWWr+KrjXVHuArK8jo5Nw
|
|||
github.com/knative/serving v0.5.2/go.mod h1:ljvMfwQy2qanaM/8xnBSK4Mz3Vv2NawC2fo5kFRJS1A=
|
||||
github.com/knative/serving v0.6.0 h1:2SOr1jAvrUPO1y0mJvpiTe3bJTSMd2tKXflmHCM0MAA=
|
||||
github.com/knative/serving v0.6.0/go.mod h1:ljvMfwQy2qanaM/8xnBSK4Mz3Vv2NawC2fo5kFRJS1A=
|
||||
github.com/knative/test-infra v0.0.0-20190404172656-4ce16d390c55 h1:2tpTEN6OydMWVmkKJC3iVNrYbA+iHNL9qjLXe7hocfE=
|
||||
github.com/knative/test-infra v0.0.0-20190404172656-4ce16d390c55/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
github.com/knative/test-infra v0.0.0-20190509163238-a721698dbe49 h1:TEv7xkUjVofC2lqiSNeYjOYhC3XosGAfr0HG8x/lpC0=
|
||||
github.com/knative/test-infra v0.0.0-20190509163238-a721698dbe49/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
github.com/knative/test-infra v0.0.0-20190516041915-e83cf0ab6b1d h1:o0QEmZJb46wFefSHgM8k3JtINpAH/KN5oe2bsFkDVOI=
|
||||
github.com/knative/test-infra v0.0.0-20190516041915-e83cf0ab6b1d/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
github.com/knative/test-infra v0.0.0-20190517181617-d1bb39bbca6e h1:Is4Ki1oQhYD3Twfdzpk2U/vI/5hSPh9277bI1AK+28o=
|
||||
github.com/knative/test-infra v0.0.0-20190517181617-d1bb39bbca6e/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
github.com/knative/test-infra v0.0.0-20190529123930-7d0c44fb03a9 h1:2kupVzyk+zet/S5bHMAQLxt1rQzqTsJd+vUXp7tIYcI=
|
||||
github.com/knative/test-infra v0.0.0-20190529123930-7d0c44fb03a9/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
github.com/knative/test-infra v0.0.0-20190531180034-a3c073a2fea1 h1:Y2QunZIzGuyvBNfWNpwK9/AAgu2P+Aa+k/3ykATGw30=
|
||||
github.com/knative/test-infra v0.0.0-20190531180034-a3c073a2fea1/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
github.com/knative/test-infra v0.0.0-20190624052103-517330119155 h1:ceTQvUNU19Vc13TlSNo6u0F0pHak9wcGJQ+gv0X4KlE=
|
||||
github.com/knative/test-infra v0.0.0-20190624052103-517330119155/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
github.com/knative/test-infra v0.0.0-20190702025031-91d37e4abc30 h1:giPqryO6DJHa/b4eHxhOOcr2KiEs3g6k6IVsPTMdKZM=
|
||||
github.com/knative/test-infra v0.0.0-20190702025031-91d37e4abc30/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||
|
|
@ -404,6 +389,24 @@ k8s.io/kube-openapi v0.0.0-20190510232812-a01b7d5d6c22 h1:f0BTap/vrgs21vVbJ1ySds
|
|||
k8s.io/kube-openapi v0.0.0-20190510232812-a01b7d5d6c22/go.mod h1:iU+ZGYsNlvU9XKUSso6SQfKTCCw7lFduMZy26Mgr2Fw=
|
||||
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 h1:5sW+fEHvlJI3Ngolx30CmubFulwH28DhKjGf70Xmtco=
|
||||
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4=
|
||||
knative.dev/test-infra v0.0.0-20190404172656-4ce16d390c55 h1:2tpTEN6OydMWVmkKJC3iVNrYbA+iHNL9qjLXe7hocfE=
|
||||
knative.dev/test-infra v0.0.0-20190404172656-4ce16d390c55/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
knative.dev/test-infra v0.0.0-20190509163238-a721698dbe49 h1:TEv7xkUjVofC2lqiSNeYjOYhC3XosGAfr0HG8x/lpC0=
|
||||
knative.dev/test-infra v0.0.0-20190509163238-a721698dbe49/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
knative.dev/test-infra v0.0.0-20190516041915-e83cf0ab6b1d h1:o0QEmZJb46wFefSHgM8k3JtINpAH/KN5oe2bsFkDVOI=
|
||||
knative.dev/test-infra v0.0.0-20190516041915-e83cf0ab6b1d/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
knative.dev/test-infra v0.0.0-20190517181617-d1bb39bbca6e h1:Is4Ki1oQhYD3Twfdzpk2U/vI/5hSPh9277bI1AK+28o=
|
||||
knative.dev/test-infra v0.0.0-20190517181617-d1bb39bbca6e/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
knative.dev/test-infra v0.0.0-20190529123930-7d0c44fb03a9 h1:2kupVzyk+zet/S5bHMAQLxt1rQzqTsJd+vUXp7tIYcI=
|
||||
knative.dev/test-infra v0.0.0-20190529123930-7d0c44fb03a9/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
knative.dev/test-infra v0.0.0-20190531180034-a3c073a2fea1 h1:Y2QunZIzGuyvBNfWNpwK9/AAgu2P+Aa+k/3ykATGw30=
|
||||
knative.dev/test-infra v0.0.0-20190531180034-a3c073a2fea1/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
knative.dev/test-infra v0.0.0-20190624052103-517330119155 h1:ceTQvUNU19Vc13TlSNo6u0F0pHak9wcGJQ+gv0X4KlE=
|
||||
knative.dev/test-infra v0.0.0-20190624052103-517330119155/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
knative.dev/test-infra v0.0.0-20190702025031-91d37e4abc30 h1:giPqryO6DJHa/b4eHxhOOcr2KiEs3g6k6IVsPTMdKZM=
|
||||
knative.dev/test-infra v0.0.0-20190702025031-91d37e4abc30/go.mod h1:l77IWBscEV5T4sYb64/9iwRCVY4UXEIqMcAppsblHW4=
|
||||
knative.dev/test-infra v0.0.0-20190730202142-17f2331e80ad h1:pXN0DA06tXwn4vgzIqJ13rf4U412rS+fRRww1JWJ+o4=
|
||||
knative.dev/test-infra v0.0.0-20190730202142-17f2331e80ad/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20181214233322-d43a45b8663b/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190426204423-ea680f03cc65/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
# Documentation about this script and how to use it can be found
|
||||
# at https://github.com/knative/test-infra/tree/master/ci
|
||||
|
||||
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/release.sh
|
||||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/release.sh
|
||||
source $(dirname $0)/build-flags.sh
|
||||
|
||||
function build_release() {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ set -o errexit
|
|||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/library.sh
|
||||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/library.sh
|
||||
|
||||
# Needed later
|
||||
go install golang.org/x/tools/cmd/goimports
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ package pkg
|
|||
import (
|
||||
"testing"
|
||||
|
||||
_ "github.com/knative/test-infra/scripts"
|
||||
_ "knative.dev/test-infra/scripts"
|
||||
)
|
||||
|
||||
func TestDummy(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
# project $PROJECT_ID, start Knative serving, run the tests and delete
|
||||
# the cluster.
|
||||
|
||||
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.sh
|
||||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/e2e-tests.sh
|
||||
|
||||
# Helper functions.
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
# $KNATIVE_VERSION with a valid release, e.g. 0.6.0, Knative serving
|
||||
# of this specified version will be installed in the Kubernetes cluster, and
|
||||
# all the tests will run against Knative serving of this specific version.
|
||||
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.sh
|
||||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/e2e-tests.sh
|
||||
|
||||
# Helper functions.
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ export DISABLE_MD_LINTING=1
|
|||
|
||||
export GO111MODULE=on
|
||||
export KNATIVE_VERSION=${KNATIVE_VERSION:-latest}
|
||||
source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/presubmit-tests.sh
|
||||
source $(dirname $0)/../vendor/knative.dev/test-infra/scripts/presubmit-tests.sh
|
||||
|
||||
# We use the default build, unit and integration test runners.
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ skipped.
|
|||
### Sample presubmit test script
|
||||
|
||||
```bash
|
||||
source vendor/github.com/knative/test-infra/scripts/presubmit-tests.sh
|
||||
source vendor/knative.dev/test-infra/scripts/presubmit-tests.sh
|
||||
|
||||
function post_build_tests() {
|
||||
echo "Cleaning up after build tests"
|
||||
|
|
@ -197,7 +197,7 @@ test cluster is created in a specific region, `us-west2`.
|
|||
# This test requires a cluster in LA
|
||||
E2E_CLUSTER_REGION=us-west2
|
||||
|
||||
source vendor/github.com/knative/test-infra/scripts/e2e-tests.sh
|
||||
source vendor/knative.dev/test-infra/scripts/e2e-tests.sh
|
||||
|
||||
function knative_setup() {
|
||||
start_latest_knative_serving
|
||||
|
|
@ -281,7 +281,7 @@ This is a helper script for Knative release scripts. To use it:
|
|||
### Sample release script
|
||||
|
||||
```bash
|
||||
source vendor/github.com/knative/test-infra/scripts/release.sh
|
||||
source vendor/knative.dev/test-infra/scripts/release.sh
|
||||
|
||||
function build_release() {
|
||||
# config/ contains the manifests
|
||||
|
|
@ -83,7 +83,7 @@ function go_test_e2e() {
|
|||
local go_options=""
|
||||
(( EMIT_METRICS )) && test_options="-emitmetrics"
|
||||
[[ ! " $@" == *" -tags="* ]] && go_options="-tags=e2e"
|
||||
report_go_test -v -count=1 ${go_options} $@ ${test_options}
|
||||
report_go_test -v -race -count=1 ${go_options} $@ ${test_options}
|
||||
}
|
||||
|
||||
# Dump info about the test cluster. If dump_extra_cluster_info() is defined, calls it too.
|
||||
|
|
@ -214,12 +214,15 @@ function create_test_cluster() {
|
|||
[[ -n "${GCP_PROJECT}" ]] && test_cmd_args+=" --gcp-project ${GCP_PROJECT}"
|
||||
[[ -n "${E2E_SCRIPT_CUSTOM_FLAGS[@]}" ]] && test_cmd_args+=" ${E2E_SCRIPT_CUSTOM_FLAGS[@]}"
|
||||
local extra_flags=()
|
||||
# If using boskos, save time and let it tear down the cluster
|
||||
(( ! IS_BOSKOS )) && extra_flags+=(--down)
|
||||
if (( IS_BOSKOS )); then # Add arbitrary duration, wait for Boskos projects acquisition before error out
|
||||
extra_flags+=(--boskos-wait-duration=20m)
|
||||
else # Only let kubetest tear down the cluster if not using Boskos, it's done by Janitor if using Boskos
|
||||
extra_flags+=(--down)
|
||||
fi
|
||||
|
||||
# Set a minimal kubernetes environment that satisfies kubetest
|
||||
# TODO(adrcunha): Remove once https://github.com/kubernetes/test-infra/issues/13029 is fixed.
|
||||
local kubedir="$(mktemp -d --tmpdir kubernetes.XXXXXXXXXX)"
|
||||
local kubedir="$(mktemp -d -t kubernetes.XXXXXXXXXX)"
|
||||
local test_wrapper="${kubedir}/e2e-test.sh"
|
||||
mkdir ${kubedir}/cluster
|
||||
ln -s "$(which kubectl)" ${kubedir}/cluster/kubectl.sh
|
||||
|
|
@ -257,7 +257,7 @@ function dump_app_logs() {
|
|||
for pod in $(get_app_pods "$1" "$2")
|
||||
do
|
||||
echo ">>> Pod: $pod"
|
||||
kubectl -n "$2" logs "$pod" -c "$1"
|
||||
kubectl -n "$2" logs "$pod" --all-containers
|
||||
done
|
||||
}
|
||||
|
||||
|
|
@ -299,28 +299,72 @@ function acquire_cluster_admin_role() {
|
|||
$2 ${geoflag} --project $(gcloud config get-value project)
|
||||
}
|
||||
|
||||
# Run a command through tee and capture its output.
|
||||
# Parameters: $1 - file where the output will be stored.
|
||||
# $2... - command to run.
|
||||
function capture_output() {
|
||||
local report="$1"
|
||||
shift
|
||||
"$@" 2>&1 | tee "${report}"
|
||||
local failed=( ${PIPESTATUS[@]} )
|
||||
[[ ${failed[0]} -eq 0 ]] && failed=${failed[1]} || failed=${failed[0]}
|
||||
return ${failed}
|
||||
}
|
||||
|
||||
# Create a JUnit XML for a test.
|
||||
# Parameters: $1 - check class name as an identifier (e.g. BuildTests)
|
||||
# $2 - check name as an identifier (e.g., GoBuild)
|
||||
# $3 - failure message (can contain newlines), optional (means success)
|
||||
function create_junit_xml() {
|
||||
local xml="$(mktemp ${ARTIFACTS}/junit_XXXXXXXX.xml)"
|
||||
local failure=""
|
||||
if [[ "$3" != "" ]]; then
|
||||
# Transform newlines into HTML code.
|
||||
# Also escape `<` and `>` as here: https://github.com/golang/go/blob/50bd1c4d4eb4fac8ddeb5f063c099daccfb71b26/src/encoding/json/encode.go#L48,
|
||||
# this is temporary solution for fixing https://github.com/knative/test-infra/issues/1204,
|
||||
# which should be obsolete once Test-infra 2.0 is in place
|
||||
local msg="$(echo -n "$3" | sed 's/$/\
/g' | sed 's/</\\u003c/' | sed 's/>/\\u003e/' | tr -d '\n')"
|
||||
failure="<failure message=\"Failed\" type=\"\">${msg}</failure>"
|
||||
fi
|
||||
cat << EOF > "${xml}"
|
||||
<testsuites>
|
||||
<testsuite tests="1" failures="1" time="0.000" name="$1">
|
||||
<testcase classname="" name="$2" time="0.0">
|
||||
${failure}
|
||||
</testcase>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
EOF
|
||||
}
|
||||
|
||||
# Runs a go test and generate a junit summary.
|
||||
# Parameters: $1... - parameters to go test
|
||||
function report_go_test() {
|
||||
# Run tests in verbose mode to capture details.
|
||||
# go doesn't like repeating -v, so remove if passed.
|
||||
local args=" $@ "
|
||||
local go_test="go test -race -v ${args/ -v / }"
|
||||
local go_test="go test -v ${args/ -v / }"
|
||||
# Just run regular go tests if not on Prow.
|
||||
echo "Running tests with '${go_test}'"
|
||||
local report=$(mktemp)
|
||||
${go_test} | tee ${report}
|
||||
local failed=( ${PIPESTATUS[@]} )
|
||||
[[ ${failed[0]} -eq 0 ]] && failed=${failed[1]} || failed=${failed[0]}
|
||||
local report="$(mktemp)"
|
||||
capture_output "${report}" ${go_test}
|
||||
local failed=$?
|
||||
echo "Finished run, return code is ${failed}"
|
||||
# Install go-junit-report if necessary.
|
||||
run_go_tool github.com/jstemmer/go-junit-report go-junit-report --help > /dev/null 2>&1
|
||||
local xml=$(mktemp ${ARTIFACTS}/junit_XXXXXXXX.xml)
|
||||
cat ${report} \
|
||||
| go-junit-report \
|
||||
| sed -e "s#\"github.com/knative/${REPO_NAME}/#\"#g" \
|
||||
| sed -e "s#\"\(github\.com/knative\|knative\.dev\)/${REPO_NAME}/#\"#g" \
|
||||
> ${xml}
|
||||
echo "XML report written to ${xml}"
|
||||
if [[ -n "$(grep '<testsuites></testsuites>' ${xml})" ]]; then
|
||||
# XML report is empty, something's wrong; use the output as failure reason
|
||||
create_junit_xml _go_tests "GoTests" "$(cat ${report})"
|
||||
fi
|
||||
# Capture and report any race condition errors
|
||||
local race_errors="$(sed -n '/^WARNING: DATA RACE$/,/^==================$/p' ${report})"
|
||||
create_junit_xml _go_tests "DataRaceAnalysis" "${race_errors}"
|
||||
if (( ! IS_PROW )); then
|
||||
# Keep the suffix, so files are related.
|
||||
local logfile=${xml/junit_/go_test_}
|
||||
|
|
@ -376,7 +420,7 @@ function update_licenses() {
|
|||
cd ${REPO_ROOT_DIR} || return 1
|
||||
local dst=$1
|
||||
shift
|
||||
run_go_tool github.com/knative/test-infra/tools/dep-collector dep-collector $@ > ./${dst}
|
||||
run_go_tool knative.dev/test-infra/tools/dep-collector dep-collector $@ > ./${dst}
|
||||
}
|
||||
|
||||
# Run dep-collector to check for forbidden liceses.
|
||||
|
|
@ -386,7 +430,7 @@ function check_licenses() {
|
|||
rm -fr ${GOPATH}/src/github.com/google/licenseclassifier
|
||||
go get -u github.com/google/licenseclassifier
|
||||
# Check that we don't have any forbidden licenses in our images.
|
||||
run_go_tool github.com/knative/test-infra/tools/dep-collector dep-collector -check $@
|
||||
run_go_tool knative.dev/test-infra/tools/dep-collector dep-collector -check $@
|
||||
}
|
||||
|
||||
# Run the given linter on the given files, checking it exists first.
|
||||
|
|
@ -467,7 +511,7 @@ function remove_broken_symlinks() {
|
|||
target="${target##* -> }"
|
||||
[[ ${target} == /* ]] || target="./${target}"
|
||||
target="$(cd `dirname ${link}` && cd ${target%/*} && echo $PWD/${target##*/})"
|
||||
if [[ ${target} != *github.com/knative/* ]]; then
|
||||
if [[ ${target} != *github.com/knative/* && ${target} != *knative.dev/* ]]; then
|
||||
unlink ${link}
|
||||
continue
|
||||
fi
|
||||
|
|
@ -517,7 +561,7 @@ function get_latest_knative_yaml_source() {
|
|||
# These MUST come last.
|
||||
|
||||
readonly _TEST_INFRA_SCRIPTS_DIR="$(dirname $(get_canonical_path ${BASH_SOURCE[0]}))"
|
||||
readonly REPO_NAME_FORMATTED="Knative $(capitalize ${REPO_NAME//-/})"
|
||||
readonly REPO_NAME_FORMATTED="Knative $(capitalize ${REPO_NAME//-/ })"
|
||||
|
||||
# Public latest nightly or release yaml files.
|
||||
readonly KNATIVE_SERVING_RELEASE="$(get_latest_knative_yaml_source "serving" "serving")"
|
||||
|
|
@ -85,29 +85,6 @@ function results_banner() {
|
|||
header "$1 tests ${result}"
|
||||
}
|
||||
|
||||
# Create a JUnit XML for a test.
|
||||
# Parameters: $1 - check class name as an identifier (e.g. BuildTests)
|
||||
# $2 - check name as an identifier (e.g., GoBuild)
|
||||
# $3 - failure message (can contain newlines), optional (means success)
|
||||
function create_junit_xml() {
|
||||
local xml="$(mktemp ${ARTIFACTS}/junit_XXXXXXXX.xml)"
|
||||
local failure=""
|
||||
if [[ "$3" != "" ]]; then
|
||||
# Transform newlines into HTML code.
|
||||
local msg="$(echo -n "$3" | sed 's/$/\
/g' | tr -d '\n')"
|
||||
failure="<failure message=\"Failed\" type=\"\">${msg}</failure>"
|
||||
fi
|
||||
cat << EOF > "${xml}"
|
||||
<testsuites>
|
||||
<testsuite tests="1" failures="1" time="0.000" name="$1">
|
||||
<testcase classname="" name="$2" time="0.0">
|
||||
${failure}
|
||||
</testcase>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
EOF
|
||||
}
|
||||
|
||||
# Run build tests. If there's no `build_tests` function, run the default
|
||||
# build test runner.
|
||||
function run_build_tests() {
|
||||
|
|
@ -134,6 +111,19 @@ function run_build_tests() {
|
|||
return ${failed}
|
||||
}
|
||||
|
||||
# Run a build test and report its output as the failure if it fails.
|
||||
# Parameters: $1 - report name.
|
||||
# $2... - command (test) to run.
|
||||
function report_build_test() {
|
||||
local report="$(mktemp)"
|
||||
local report_name="$1"
|
||||
shift
|
||||
local errors=""
|
||||
capture_output "${report}" "$@" || errors="$(cat ${report})"
|
||||
create_junit_xml _build_tests "${report_name}" "${errors}"
|
||||
[[ -z "${errors}" ]]
|
||||
}
|
||||
|
||||
# Perform markdown build tests if necessary, unless disabled.
|
||||
function markdown_build_tests() {
|
||||
(( DISABLE_MD_LINTING && DISABLE_MD_LINK_CHECK )) && return 0
|
||||
|
|
@ -146,11 +136,11 @@ function markdown_build_tests() {
|
|||
local failed=0
|
||||
if (( ! DISABLE_MD_LINTING )); then
|
||||
subheader "Linting the markdown files"
|
||||
lint_markdown ${mdfiles} || failed=1
|
||||
report_build_test Markdown_Lint lint_markdown ${mdfiles} || failed=1
|
||||
fi
|
||||
if (( ! DISABLE_MD_LINK_CHECK )); then
|
||||
subheader "Checking links in the markdown files"
|
||||
check_links_in_markdown ${mdfiles} || failed=1
|
||||
report_build_test Markdown_Link check_links_in_markdown ${mdfiles} || failed=1
|
||||
fi
|
||||
return ${failed}
|
||||
}
|
||||
|
|
@ -171,29 +161,34 @@ function default_build_test_runner() {
|
|||
[[ -z "${go_pkg_dirs}" ]] && return ${failed}
|
||||
# Ensure all the code builds
|
||||
subheader "Checking that go code builds"
|
||||
local report=$(mktemp)
|
||||
local errors=""
|
||||
go build -v ./... 2>&1 | tee ${report}
|
||||
local build_failed=( ${PIPESTATUS[@]} )
|
||||
if [[ ${build_failed[0]} -ne 0 ]]; then
|
||||
local report="$(mktemp)"
|
||||
local errors_go1=""
|
||||
local errors_go2=""
|
||||
if ! capture_output "${report}" go build -v ./... ; then
|
||||
failed=1
|
||||
# Consider an error message everything that's not a package name.
|
||||
errors="$(grep -v '^github.com/' "${report}" | sort | uniq)"
|
||||
errors_go1="$(grep -v '^\(github\.com\|knative\.dev\)/' "${report}" | sort | uniq)"
|
||||
fi
|
||||
create_junit_xml _build_tests Build_Go "${errors}"
|
||||
# Get all build tags in go code (ignore /vendor)
|
||||
local tags="$(grep -r '// +build' . \
|
||||
| grep -v '^./vendor/' | cut -f3 -d' ' | sort | uniq | tr '\n' ' ')"
|
||||
if [[ -n "${tags}" ]]; then
|
||||
go test -run=^$ -tags="${tags}" ./... || failed=1
|
||||
errors=""
|
||||
if ! capture_output "${report}" go test -run=^$ -tags="${tags}" ./... ; then
|
||||
failed=1
|
||||
# Consider an error message everything that's not a successful test result.
|
||||
errors_go2="$(grep -v '^\(ok\|\?\)\s\+\(github\.com\|knative\.dev\)/' "${report}")"
|
||||
fi
|
||||
fi
|
||||
local errors_go="$(echo -e "${errors_go1}\n${errors_go2}" | uniq)"
|
||||
create_junit_xml _build_tests Build_Go "${errors_go}"
|
||||
if [[ -f ./hack/verify-codegen.sh ]]; then
|
||||
subheader "Checking autogenerated code is up-to-date"
|
||||
./hack/verify-codegen.sh || failed=1
|
||||
report_build_test Verify_CodeGen ./hack/verify-codegen.sh || failed=1
|
||||
fi
|
||||
# Check that we don't have any forbidden licenses in our images.
|
||||
subheader "Checking for forbidden licenses"
|
||||
check_licenses ${go_pkg_dirs} || failed=1
|
||||
report_build_test Check_Licenses check_licenses ${go_pkg_dirs} || failed=1
|
||||
return ${failed}
|
||||
}
|
||||
|
||||
|
|
@ -229,7 +224,7 @@ function run_unit_tests() {
|
|||
|
||||
# Default unit test runner that runs all go tests in the repo.
|
||||
function default_unit_test_runner() {
|
||||
report_go_test ./...
|
||||
report_go_test -race ./...
|
||||
}
|
||||
|
||||
# Run integration tests. If there's no `integration_tests` function, run the
|
||||
|
|
@ -19,12 +19,15 @@
|
|||
|
||||
source $(dirname ${BASH_SOURCE})/library.sh
|
||||
|
||||
# Organization name in GitHub; defaults to Knative.
|
||||
readonly ORG_NAME="${ORG_NAME:-knative}"
|
||||
|
||||
# GitHub upstream.
|
||||
readonly KNATIVE_UPSTREAM="https://github.com/knative/${REPO_NAME}"
|
||||
readonly REPO_UPSTREAM="https://github.com/${ORG_NAME}/${REPO_NAME}"
|
||||
|
||||
# GCRs for Knative releases.
|
||||
readonly NIGHTLY_GCR="gcr.io/knative-nightly/github.com/knative/${REPO_NAME}"
|
||||
readonly RELEASE_GCR="gcr.io/knative-releases/github.com/knative/${REPO_NAME}"
|
||||
readonly NIGHTLY_GCR="gcr.io/knative-nightly/github.com/${ORG_NAME}/${REPO_NAME}"
|
||||
readonly RELEASE_GCR="gcr.io/knative-releases/github.com/${ORG_NAME}/${REPO_NAME}"
|
||||
|
||||
# Georeplicate images to {us,eu,asia}.gcr.io
|
||||
readonly GEO_REPLICATION=(us eu asia)
|
||||
|
|
@ -108,7 +111,7 @@ function hub_tool() {
|
|||
# Shortcut to "git push" that handles authentication.
|
||||
# Parameters: $1..$n - arguments to "git push <repo>".
|
||||
function git_push() {
|
||||
local repo_url="${KNATIVE_UPSTREAM}"
|
||||
local repo_url="${REPO_UPSTREAM}"
|
||||
[[ -n "${GITHUB_TOKEN}}" ]] && repo_url="${repo_url/:\/\//:\/\/${GITHUB_TOKEN}@}"
|
||||
git push ${repo_url} $@
|
||||
}
|
||||
|
|
@ -144,15 +147,15 @@ function setup_upstream() {
|
|||
local upstream="$(git config --get remote.upstream.url)"
|
||||
echo "Remote upstream URL is '${upstream}'"
|
||||
if [[ -z "${upstream}" ]]; then
|
||||
echo "Setting remote upstream URL to '${KNATIVE_UPSTREAM}'"
|
||||
git remote add upstream ${KNATIVE_UPSTREAM}
|
||||
echo "Setting remote upstream URL to '${REPO_UPSTREAM}'"
|
||||
git remote add upstream ${REPO_UPSTREAM}
|
||||
fi
|
||||
}
|
||||
|
||||
# Fetch the release branch, so we can check it out.
|
||||
function setup_branch() {
|
||||
[[ -z "${RELEASE_BRANCH}" ]] && return
|
||||
git fetch ${KNATIVE_UPSTREAM} ${RELEASE_BRANCH}:upstream/${RELEASE_BRANCH}
|
||||
git fetch ${REPO_UPSTREAM} ${RELEASE_BRANCH}:upstream/${RELEASE_BRANCH}
|
||||
}
|
||||
|
||||
# Setup version, branch and release notes for a auto release.
|
||||
|
|
@ -555,10 +558,17 @@ function publish_to_github() {
|
|||
git_push tag ${TAG}
|
||||
|
||||
[[ -n "${RELEASE_BRANCH}" ]] && commitish="--commitish=${RELEASE_BRANCH}"
|
||||
hub_tool release create \
|
||||
--prerelease \
|
||||
${attachments[@]} \
|
||||
--file=${description} \
|
||||
${commitish} \
|
||||
${TAG}
|
||||
for i in {2..0}; do
|
||||
hub_tool release create \
|
||||
--prerelease \
|
||||
${attachments[@]} \
|
||||
--file=${description} \
|
||||
${commitish} \
|
||||
${TAG} && return 0
|
||||
if [[ "${i}" -gt 0 ]]; then
|
||||
echo "Error publishing the release, retrying in 15s..."
|
||||
sleep 15
|
||||
fi
|
||||
done
|
||||
abort "Cannot publish release to GitHub"
|
||||
}
|
||||
|
|
@ -84,8 +84,6 @@ github.com/knative/serving/pkg/apis/networking
|
|||
github.com/knative/serving/pkg/apis/networking/v1alpha1
|
||||
github.com/knative/serving/pkg/apis/config
|
||||
github.com/knative/serving/pkg/apis/autoscaling/v1alpha1
|
||||
# github.com/knative/test-infra v0.0.0-20190702025031-91d37e4abc30
|
||||
github.com/knative/test-infra/scripts
|
||||
# github.com/magiconair/properties v1.8.0
|
||||
github.com/magiconair/properties
|
||||
# github.com/mattbaird/jsonpatch v0.0.0-20171005235357-81af80346b1a
|
||||
|
|
@ -395,5 +393,7 @@ k8s.io/client-go/listers/storage/v1alpha1
|
|||
k8s.io/client-go/listers/storage/v1beta1
|
||||
# k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208
|
||||
k8s.io/kube-openapi/pkg/util/proto
|
||||
# knative.dev/test-infra v0.0.0-20190730202142-17f2331e80ad
|
||||
knative.dev/test-infra/scripts
|
||||
# sigs.k8s.io/yaml v1.1.0
|
||||
sigs.k8s.io/yaml
|
||||
|
|
|
|||
Loading…
Reference in New Issue