Improve the speed of do-nothing build.

As thockin found out here https://github.com/kubernetes/kubernetes/issues/24518,
vast majority of the do-nothing build time is spent in rebuilding the test
binaries. There is no staleness check support for test binaries.

This commit implements the staleness checks for test binaries and uses them
while building packages.

Tests are TBD. I am still trying to figure out how to test this.
This commit is contained in:
Madhusudan.C.S
2016-04-26 23:13:14 -07:00
parent 4486385bc6
commit dcaf005ffe
2 changed files with 215 additions and 1 deletions

View File

@@ -114,6 +114,7 @@ kube::golang::test_targets() {
cmd/linkcheck
examples/k8petstore/web-server/src
vendor/github.com/onsi/ginkgo/ginkgo
hack/cmd/teststale
test/e2e/e2e.test
test/e2e_node/e2e_node.test
)
@@ -443,15 +444,25 @@ kube::golang::build_binaries_for_platform() {
fi
fi
teststale=$(kube::golang::output_filename_for_binary "hack/cmd/teststale" "${platform}")
for test in "${tests[@]:+${tests[@]}}"; do
local outfile=$(kube::golang::output_filename_for_binary "${test}" \
"${platform}")
local testpkg="$(dirname ${test})"
if [[ "$(${teststale} -binary "${outfile}" -package "${testpkg}")" == "false" ]]; then
continue
fi
go install "${goflags[@]:+${goflags[@]}}" \
-ldflags "${goldflags}" \
"${testpkg}"
mkdir -p "$(dirname ${outfile})"
go test -c \
"${goflags[@]:+${goflags[@]}}" \
-ldflags "${goldflags}" \
-o "${outfile}" \
"$(dirname ${test})"
"${testpkg}"
done
}