-
Notifications
You must be signed in to change notification settings - Fork 74
/
robot-presubmit
executable file
·110 lines (83 loc) · 3.71 KB
/
robot-presubmit
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/bash
#
# Copyright (C) Extensible Service Proxy Authors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
################################################################################
#
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
. ${ROOT}/script/all-utilities || { echo "Cannot load Bash utilities" ; exit 1 ; }
while getopts m arg; do
case ${arg} in
m) echo "-m is deprecated and a noop";;
?) exit 1;;
esac
done
( echo "Checking license headers."
"${ROOT}/script/check-license-headers"
) || error_exit "License headers check failed."
( echo "Checking coding styles."
"${ROOT}/script/robot-style"
) || error_exit "Code style check failed."
( echo "Bazel test third_party/service-control-client-cxx."
cd ${ROOT}/third_party/service-control-client-cxx
bazel clean \
|| error_exit "Failed to bazel clean before the build."
bazel test --test_output=errors :all \
|| error_exit "Bazel test failed for :all."
) || error_exit "Bazel build failed."
( echo "Building with Bazel."
bazel clean \
|| error_exit "Failed to bazel clean before the build."
bazel build //src/... \
|| error_exit "Bazel build failed for //src/..."
bazel build //tools/src/... \
|| error_exit "Bazel build failed for //tools/src/..."
# Test Perl test rules.
bazel test //test/perl:test_pass \
|| error_exit "Perl test expected to pass failed."
bazel test //test/perl:test_fail
[[ $? -ne 0 ]] || error_exit "Perl test expected to fail passed."
# Tests
bazel test --test_output=errors //src/... \
|| error_exit "Bazel test failed for //src/..."
bazel test --test_output=errors //tools/src/... \
|| error_exit "Bazel test failed for //tools/src/..."
bazel test --test_output=errors //third_party:all \
|| error_exit "Bazel test failed for //third_party:all (nginx tests)."
# Run the rest of the tests on release build.
bazel clean \
|| error_exit "Failed to bazel clean before the release build."
bazel test --config=release --test_output=errors \
//src/... \
//third_party:all \
|| error_exit "Failed release tests."
# Docker test.
bazel build --config=release //src/nginx/main:endpoints-server-proxy \
|| error_exit "Bazel build failed for //src/nginx/main:endpoints-server-proxy"
${ROOT}/test/docker/docker_test.sh \
-d "${ROOT}/bazel-bin/src/nginx/main/endpoints-server-proxy.deb" \
|| error_exit "Docker presubmit test failed."
) || error_exit "Bazel build failed."
echo "Presubmit tests completed successfully."