forked from GoogleCloudPlatform/esp-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcpproxy-coverage.sh
executable file
·85 lines (72 loc) · 3.32 KB
/
gcpproxy-coverage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# Copyright 2019 Google LLC
# 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
#
# https://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.
# Presubmit script triggered by Prow.
# Fail on any error.
set -eo pipefail
gcloud config set core/project cloudesf-testing
gcloud auth activate-service-account \
--key-file="${GOOGLE_APPLICATION_CREDENTIALS}"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "${ROOT}"
. ${ROOT}/scripts/all-utilities.sh || { echo 'Cannot load Bash utilities';
exit 1; }
# https://github.com/bazelbuild/bazel/issues/7247
# TODO(nareddyt): See if there are workarounds.
case "${JOB_TYPE}" in
"presubmit")
echo "Coverage job is disabled for presubmits due to a bug with remote caching."
echo "Otherwise, presubmits would take too long to complete."
echo "If you need to see coverage for your commit, please run this script locally."
echo "Coverage job will still run periodically on the master branch."
exit 0
;;
esac
#echo '======================================================='
#echo '===================== Setup Cache ====================='
#echo '======================================================='
#try_setup_bazel_remote_cache "${PROW_JOB_ID}" "${IMAGE}" "${ROOT}" "${JOB_TYPE}-coverage"
echo '======================================================='
echo '==================== C++ Coverage ====================='
echo '======================================================='
. ${ROOT}/third_party/tools/coverage/cpp_unit.sh
echo '======================================================='
echo '=================== Upload Coverage ==================='
echo '======================================================='
# Note that JOB_TYPE is set by Prow.
# https://github.com/kubernetes/test-infra/blob/master/prow/jobs.md#job-environment-variables
PUBLIC_DIRECTORY=""
case "${JOB_TYPE}" in
"presubmit")
# Store in directory with the SHA for each presubmit run.
PUBLIC_DIRECTORY=$(get_tag_name)
;;
"periodic")
# Overwrite global directory with latest coverage for all continuous runs.
PUBLIC_DIRECTORY="latest"
;;
*)
# If running locally, just upload to special-case folder.
echo "Unknown job type: ${JOB_TYPE}"
PUBLIC_DIRECTORY="local-run"
;;
esac
# Upload folder.
gsutil -m rsync -r -d "${ROOT}/generated" "gs://esp-v2-coverage/${PUBLIC_DIRECTORY}"
# No browser cache since some directories change often and that would be misleading.
gsutil -m setmeta -h "Cache-Control:private, max-age=0, no-transform" "gs://esp-v2-coverage/${PUBLIC_DIRECTORY}/**"
echo '======================================================='
echo '==================== View Coverage ===================='
echo '======================================================='
echo "C++ Unit test coverage is viewable at the URL below"
echo "https://storage.googleapis.com/esp-v2-coverage/${PUBLIC_DIRECTORY}/third_party/tools/coverage/coverage_tests/index.html"