mirror of https://github.com/knative/caching.git
Auto-update dependencies (#58)
Produced via: `dep ensure -update github.com/knative/test-infra knative.dev/pkg` /assign @mattmoor
This commit is contained in:
parent
5c6bfd657c
commit
2032732871
|
@ -262,14 +262,14 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:5197df8038ae4c7d05c2edda32a77d7f16faa635df3c560f01fb73fa42682f69"
|
||||
digest = "1:f91a467423c58e30754cb830f66a04fa3e6f28fe567e3e68e04aa61f3e51f377"
|
||||
name = "github.com/knative/test-infra"
|
||||
packages = [
|
||||
"scripts",
|
||||
"tools/dep-collector",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "bb74f5a60ee307a6ec7d5ad589cd2184f7ba5f2c"
|
||||
revision = "cad8ba5b64ca151d6435a914fd29f0b8a5cdec74"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5985ef4caf91ece5d54817c11ea25f182697534f8ae6521eadcd628c142ac4b6"
|
||||
|
@ -938,7 +938,7 @@
|
|||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:8ec01314b69645c0da5a23e0f257f0c90215176783684bf7aadfe988f641cc4d"
|
||||
digest = "1:52d224343dc361c41a93a8c01685d2f491b52366830bc6a783cd3f7315b01716"
|
||||
name = "knative.dev/pkg"
|
||||
packages = [
|
||||
"apis",
|
||||
|
@ -957,7 +957,7 @@
|
|||
"metrics/metricskey",
|
||||
]
|
||||
pruneopts = "T"
|
||||
revision = "a7dbe912205c611ffe07d57f995ee02b577d34c0"
|
||||
revision = "8fe96d53cc1856e044988703a4e46e7b431cfcd3"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
|
|
|
@ -299,6 +299,41 @@ 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.
|
||||
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
|
||||
}
|
||||
|
||||
# Runs a go test and generate a junit summary.
|
||||
# Parameters: $1... - parameters to go test
|
||||
function report_go_test() {
|
||||
|
@ -308,19 +343,25 @@ function report_go_test() {
|
|||
local go_test="go test -race -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_}
|
||||
|
@ -467,7 +508,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
|
||||
|
|
|
@ -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}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
Copyright 2019 The Knative Authors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
package kmeta
|
||||
|
||||
// OwnerRefableAccessor is a combination of OwnerRefable interface and Accessor interface
|
||||
// which inidcates that it has 1) sufficient information to produce a metav1.OwnerReference to an object,
|
||||
// 2) and a collection of interfaces from metav1.TypeMeta runtime.Object and metav1.Object that Kubernetes API types
|
||||
// registered with runtime.Scheme must support.
|
||||
type OwnerRefableAccessor interface {
|
||||
OwnerRefable
|
||||
Accessor
|
||||
}
|
|
@ -16,6 +16,8 @@ limitations under the License.
|
|||
|
||||
package ptr
|
||||
|
||||
import "time"
|
||||
|
||||
// Int32 is a helper for turning integers into pointers for use in
|
||||
// API types that want *int32.
|
||||
func Int32(i int32) *int32 {
|
||||
|
@ -39,3 +41,15 @@ func Bool(b bool) *bool {
|
|||
func String(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
||||
// Duration is a helper for turning time.Duration into pointers for use in
|
||||
// API types that want *time.Duration.
|
||||
func Duration(t time.Duration) *time.Duration {
|
||||
return &t
|
||||
}
|
||||
|
||||
// Time is a helper for turning a const time.Time into a pointer for use in
|
||||
// API types that want *time.Duration.
|
||||
func Time(t time.Time) *time.Time {
|
||||
return &t
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue