summaryrefslogtreecommitdiffhomepage
path: root/scripts/common_bazel.sh
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-09-16 08:15:40 -0700
committergVisor bot <gvisor-bot@google.com>2019-09-16 08:17:00 -0700
commit010b0932583711ab3f6a88b1136cf8d87c2a53d2 (patch)
tree5d97437e3f7c03918071a677fe02893f0cc7d76e /scripts/common_bazel.sh
parent239a07aabfad8991556b43c85c30270d09353f86 (diff)
Bring back to life features lost in recent refactor
- Sandbox logs are generated when running tests - Kokoro uploads the sandbox logs - Supports multiple parallel runs - Revive script to install locally built runsc with docker PiperOrigin-RevId: 269337274
Diffstat (limited to 'scripts/common_bazel.sh')
-rwxr-xr-xscripts/common_bazel.sh34
1 files changed, 24 insertions, 10 deletions
diff --git a/scripts/common_bazel.sh b/scripts/common_bazel.sh
index dc0e2041d..dde0b51ed 100755
--- a/scripts/common_bazel.sh
+++ b/scripts/common_bazel.sh
@@ -53,16 +53,7 @@ function build() {
}
function test() {
- (bazel test "${BAZEL_RBE_FLAGS[@]}" "${BAZEL_RBE_AUTH_FLAGS[@]}" "${BAZEL_FLAGS[@]}" "$@" && rc=0) || rc=$?
-
- # Zip out everything into a convenient form.
- if [[ -v KOKORO_ARTIFACTS_DIR ]] && [[ -e bazel-testlogs ]]; then
- find -L "bazel-testlogs" -name "test.xml" -o -name "test.log" -o -name "outputs.zip" |
- tar --create --files-from - --transform 's/test\./sponge_log./' |
- tar --extract --directory ${KOKORO_ARTIFACTS_DIR}
- fi
-
- return $rc
+ bazel test "${BAZEL_RBE_FLAGS[@]}" "${BAZEL_RBE_AUTH_FLAGS[@]}" "${BAZEL_FLAGS[@]}" "$@"
}
function run() {
@@ -76,3 +67,26 @@ function run_as_root() {
shift
bazel run --run_under="sudo" "${binary}" -- "$@"
}
+
+function collect_logs() {
+ # Zip out everything into a convenient form.
+ if [[ -v KOKORO_ARTIFACTS_DIR ]] && [[ -e bazel-testlogs ]]; then
+ # Move test logs to Kokoro directory. tar is used to conveniently perform
+ # renames while moving files.
+ find -L "bazel-testlogs" -name "test.xml" -o -name "test.log" -o -name "outputs.zip" |
+ tar --create --files-from - --transform 's/test\./sponge_log./' |
+ tar --extract --directory ${KOKORO_ARTIFACTS_DIR}
+
+ # Collect sentry logs, if any.
+ if [[ -v RUNSC_LOGS_DIR ]] && [[ -d "${RUNSC_LOGS_DIR}" ]]; then
+ local -r logs=$(ls "${RUNSC_LOGS_DIR}")
+ if [[ -z "${logs}" ]]; then
+ tar --create --gzip --file="${KOKORO_ARTIFACTS_DIR}/${RUNTIME}.tar.gz" -C "${RUNSC_LOGS_DIR}" .
+ fi
+ fi
+ fi
+}
+
+function find_branch_name() {
+ git branch --show-current || git rev-parse HEAD || bazel info workspace | xargs basename
+}