@@ -18,9 +18,9 @@ set -euo pipefail
1818
1919# Actions
2020benchmark=0 # Should run benchmarks?
21- build=1 # Should build images?
22- library_tests =0 # Should try to install top N Python libraries
23- system_tests =0 # Should run system tests ?
21+ build=0 # Should build images?
22+ system_test =0 # Should run system tests?
23+ test =0 # Should run standard test suite ?
2424
2525local=0 # Should run using local Docker daemon instead of GCR?
2626
@@ -40,32 +40,37 @@ Build and test artifacts in this repository
4040
4141Options:
4242 --[no]benchmark: Run benchmarking suite (default false)
43- --[no]build: Build all images (default true)
44- --[no]library_tests : Run library compatiblity tests (default false )
43+ --[no]build: Build all images (default true if no options set )
44+ --[no]test : Run basic tests (default true if no options set )
4545 --[no]local: Build images using local Docker daemon (default false)
46- --[no]system_tests : Run system tests (default false)
46+ --[no]system_test : Run system tests (default false)
4747"
4848}
49-
49+
5050# Read environment variables
51- if [ -z " ${DOCKER_NAMESPACE+set} " ] ; then
51+ if [ -z " ${DOCKER_NAMESPACE: +set} " ] ; then
5252 fatal ' Error: $DOCKER_NAMESPACE is not set; invoke with something like DOCKER_NAMESPACE=gcr.io/YOUR-PROJECT-NAME'
5353fi
5454
55- if [ -z " ${BUILDER_DOCKER_NAMESPACE+set} " ] ; then
55+ if [ -z " ${BUILDER_DOCKER_NAMESPACE: +set} " ] ; then
5656 export BUILDER_DOCKER_NAMESPACE=" ${DOCKER_NAMESPACE} "
5757fi
5858
59- if [ -z " ${TAG+set} " ] ; then
59+ if [ -z " ${TAG: +set} " ] ; then
6060 export TAG=` date +%Y-%m-%d-%H%M%S`
6161fi
6262
63- substitutions =" \
63+ build_substitutions =" \
6464_BUILDER_DOCKER_NAMESPACE=${BUILDER_DOCKER_NAMESPACE} ,\
6565_DOCKER_NAMESPACE=${DOCKER_NAMESPACE} ,\
6666_TAG=${TAG} \
6767"
6868
69+ substitutions=" \
70+ _DOCKER_NAMESPACE=${DOCKER_NAMESPACE} ,\
71+ _TAG=${TAG} \
72+ "
73+
6974# Read command line arguments
7075while [ $# -gt 0 ]; do
7176 case " $1 " in
@@ -85,14 +90,6 @@ while [ $# -gt 0 ]; do
8590 build=0
8691 shift
8792 ;;
88- --library_tests)
89- library_tests=1
90- shift
91- ;;
92- --nolibrary_tests)
93- library_tests=0
94- shift
95- ;;
9693 --local)
9794 local=1
9895 shift
@@ -101,12 +98,20 @@ while [ $# -gt 0 ]; do
10198 local=0
10299 shift
103100 ;;
104- --system_tests)
105- system_tests=1
101+ --system_test)
102+ system_test=1
103+ shift
104+ ;;
105+ --nosystem_test)
106+ system_test=0
106107 shift
107108 ;;
108- --nosystem_tests)
109- system_tests=0
109+ --test)
110+ test=1
111+ shift
112+ ;;
113+ --notest)
114+ test=0
110115 shift
111116 ;;
112117 * )
@@ -118,9 +123,12 @@ done
118123# If no actions chosen, then tell the user
119124if [ " ${benchmark} " -eq 0 -a \
120125 " ${build} " -eq 0 -a \
121- " ${library_tests} " -eq 0 -a \
122- " ${system_tests} " -eq 0 ]; then
123- fatal ' Error: No actions specified (for example, --build), exiting'
126+ " ${system_test} " -eq 0 -a \
127+ " ${test} " -eq 0 \
128+ ]; then
129+ echo ' No actions specified, defaulting to --build --test'
130+ build=1
131+ test=1
124132fi
125133
126134# Running build local or remote?
@@ -129,7 +137,7 @@ if [ "${local}" -eq 1 ]; then
129137fi
130138
131139# Read action-specific environment variables
132- if [ " ${system_tests } " -eq 1 ]; then
140+ if [ " ${system_test } " -eq 1 ]; then
133141 if [ -z " ${GOOGLE_APPLICATION_CREDENTIALS_FOR_TESTS+set} " ] ; then
134142 fatal ' Error: $GOOGLE_APPLICATION_CREDENTIALS_FOR_TESTS is not set; invoke with something like GOOGLE_APPLICATION_CREDENTIALS_FOR_TESTS=/path/to/service/account/creds.json'
135143 fi
@@ -155,7 +163,8 @@ for outfile in \
155163 tests/google-cloud-python-system/Dockerfile \
156164 tests/integration/Dockerfile \
157165 ; do
158- envsubst < " ${outfile} " .in > " ${outfile} " ' $DEBIAN_BASE_IMAGE $STAGING_IMAGE $GOOGLE_CLOUD_PROJECT_FOR_TESTS'
166+ envsubst < " ${outfile} " .in > " ${outfile} " \
167+ ' $DEBIAN_BASE_IMAGE $STAGING_IMAGE $GOOGLE_CLOUD_PROJECT_FOR_TESTS $TAG'
159168done
160169
161170# Make some files available to the runtime builder Docker context
@@ -174,36 +183,27 @@ cp -a scripts/testdata/hello_world/main.py tests/eventlet/main.py
174183# Build images and push to GCR
175184if [ " ${build} " -eq 1 ]; then
176185 echo " Building images"
177- ${gcloud_cmd} --config cloudbuild.yaml --substitutions " ${substitutions } "
186+ ${gcloud_cmd} --config cloudbuild.yaml --substitutions " ${build_substitutions } "
178187fi
179188
180- # Run just the library compatibility tests (for DPE Gardener bot usually)
181- if [ " ${library_tests } " -eq 1 ]; then
189+ # Run the tests that don't require (too many) external services
190+ if [ " ${test } " -eq 1 ]; then
182191 echo " Testing compatibility with popular Python libraries"
183- ${gcloud_cmd} --config cloudbuild_library_tests .yaml --substitutions " ${substitutions} "
192+ ${gcloud_cmd} --config cloudbuild_test .yaml --substitutions " ${substitutions} "
184193fi
185194
186- # If both system tests and benchmarks are requested, run them both
187- # even if one or the other has errors. If the build step had errors,
188- # this script will have already exited.
189- exit_code=0
190-
191195# Run system tests
192- if [ " ${system_tests } " -eq 1 ]; then
196+ if [ " ${system_test } " -eq 1 ]; then
193197 echo " Running system tests using project ${GOOGLE_CLOUD_PROJECT_FOR_TESTS} "
194198
195199 trap " rm -f tests/google-cloud-python-system/credentials.json" EXIT
196200 cp " ${GOOGLE_APPLICATION_CREDENTIALS_FOR_TESTS} " tests/google-cloud-python-system/credentials.json
197- ${gcloud_cmd} --config cloudbuild_system_tests.yaml --substitutions " ${substitutions} " || \
198- exit_code=1
201+ ${gcloud_cmd} --config cloudbuild_system_test.yaml --substitutions " ${substitutions} "
199202 rm -f tests/google-cloud-python-system/credentials.json
200203fi
201204
202205# Run benchmarks
203206if [ " ${benchmark} " -eq 1 ] ; then
204207 echo " Running benchmark"
205- ${gcloud_cmd} --config cloudbuild_benchmark.yaml --substitutions " ${substitutions} " || \
206- exit_code=1
208+ ${gcloud_cmd} --config cloudbuild_benchmark.yaml --substitutions " ${substitutions} "
207209fi
208-
209- exit ${exit_code}
0 commit comments