Skip to content

Commit ee53cc5

Browse files
authored
Merge branch 'master' into simple-nox
2 parents 882742a + d26b380 commit ee53cc5

File tree

29 files changed

+4797
-30
lines changed

29 files changed

+4797
-30
lines changed

.kokoro/tests/run_tests.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ for file in **/requirements.txt; do
7676
fi
7777
fi
7878

79+
# Skip unsupported Python versions for Cloud Functions
80+
# (Some GCF samples' dependencies don't support them)
81+
if [[ "$file" == "functions/"* ]]; then
82+
PYTHON_VERSION="$(python --version 2>&1)"
83+
if [[ "$PYTHON_VERSION" == "Python 2."* || "$PYTHON_VERSION" == "Python 3.5"* ]]; then
84+
# echo -e "\n Skipping $file: Python $PYTHON_VERSION is not supported by Cloud Functions.\n"
85+
continue
86+
fi
87+
fi
88+
7989
echo "------------------------------------------------------------"
8090
echo "- testing $file"
8191
echo "------------------------------------------------------------"
@@ -95,6 +105,31 @@ for file in **/requirements.txt; do
95105
nox -s "$RUN_TESTS_SESSION"
96106
EXIT=$?
97107

108+
# If this is a continuous build, send the test log to the Build Cop Bot.
109+
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop.
110+
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
111+
XML=$(base64 -w 0 sponge_log.xml)
112+
113+
# See https://github.com/apps/build-cop-bot/installations/5943459.
114+
MESSAGE=$(cat <<EOF
115+
{
116+
"Name": "buildcop",
117+
"Type" : "function",
118+
"Location": "us-central1",
119+
"installation": {"id": "5943459"},
120+
"repo": "GoogleCloudPlatform/python-docs-samples",
121+
"buildID": "$KOKORO_GIT_COMMIT",
122+
"buildURL": "https://source.cloud.google.com/results/invocations/$KOKORO_BUILD_ID",
123+
"xunitXML": "$XML"
124+
}
125+
EOF
126+
)
127+
128+
# Use a service account with access to the repo-automation-bots project.
129+
gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
130+
gcloud pubsub topics publish passthrough --project=repo-automation-bots --message="$MESSAGE"
131+
fi
132+
98133
if [[ $EXIT -ne 0 ]]; then
99134
RTN=1
100135
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"

appengine/flexible/tasks/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Use the official Python image.
22
# https://hub.docker.com/_/python
3-
FROM python:3.7
3+
FROM python:3.8
44

55
# Copy local code to the container image.
66
ENV APP_HOME /app
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Flask==1.1.1
2-
Werkzeug==0.16.0
2+
Werkzeug==0.16.1
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
flask==1.1.1
2-
psycopg2==2.8.4
3-
psycopg2-binary==2.8.4
2+
# psycopg2==2.8.4
3+
psycopg2-binary==2.8.4 # you will need either the binary or the regular - for more info see http://initd.org/psycopg/docs/install.html
44
PyMySQL==0.9.3
5-
SQLAlchemy==1.3.12
5+
SQLAlchemy==1.3.13

cloud-sql/mysql/sqlalchemy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Use the official Python image.
1616
# https://hub.docker.com/_/python
17-
FROM python:3.7
17+
FROM python:3.8
1818

1919
# Copy application dependency manifests to the container image.
2020
# Copying this separately prevents re-running pip install on every code change.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Flask==1.1.1
2-
SQLAlchemy==1.3.12
2+
SQLAlchemy==1.3.13
33
PyMySQL==0.9.3

cloud-sql/postgres/sqlalchemy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# Use the official Python image.
1616
# https://hub.docker.com/_/python
17-
FROM python:3.7
17+
FROM python:3.8
1818

1919
# Copy application dependency manifests to the container image.
2020
# Copying this separately prevents re-running pip install on every code change.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
Flask==1.1.1
2-
SQLAlchemy==1.3.12
3-
pg8000==1.13.2
2+
SQLAlchemy==1.3.13
3+
pg8000==1.13.2; python_version > '3.0'
4+
pg8000==1.12.5; python_version < '3.0'

composer/workflows/kubernetes_pod_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
# project-id as the gcr.io images and the service account that Composer
7979
# uses has permission to access the Google Container Registry
8080
# (the default service account has permission)
81-
image='gcr.io/gcp-runtimes/ubuntu_16_0_4')
81+
image='gcr.io/gcp-runtimes/ubuntu_18_0_4')
8282
# [END composer_kubernetespodoperator_minconfig]
8383
# [START composer_kubernetespodoperator_templateconfig]
8484
kubenetes_template_ex = kubernetes_pod_operator.KubernetesPodOperator(

composer/workflows/requirements.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
apache-airflow[gcp]==1.10.6
22
kubernetes==10.0.1
3-
scipy==1.4.1
4-
numpy==1.17.4
3+
scipy==1.4.1; python_version > '3.0'
4+
scipy==1.2.3; python_version < '3.0'
5+
numpy==1.17.4; python_version > '3.0'
6+
numpy==1.16.6; python_version < '3.0'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
apache-beam[gcp]==2.17.0
1+
apache-beam[gcp]==2.19.0

endpoints/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Google Cloud Endpoints Examples
2+
3+
The files in this directory are referenced from [Google Cloud Endpoints Documentation](https://cloud.google.com/endpoints/docs/).
4+
5+
### CA File
6+
7+
`roots.pem` is copied from [github.com/grpc/grpc](https://github.com/grpc/grpc/blob/master/etc/roots.pem).
8+
This file should be updated regularly.

endpoints/bookstore-grpc/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ ADD . /bookstore/
1717
WORKDIR /bookstore
1818
RUN pip install -r requirements.txt
1919

20-
EXPOSE 8000
21-
2220
ENTRYPOINT ["python", "/bookstore/bookstore_server.py"]

endpoints/bookstore-grpc/bookstore_client.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@
2222
import bookstore_pb2_grpc
2323

2424

25-
def run(host, port, api_key, auth_token, timeout):
25+
def run(host, port, api_key, auth_token, timeout, use_tls):
2626
"""Makes a basic ListShelves call against a gRPC Bookstore server."""
2727

28-
channel = grpc.insecure_channel('{}:{}'.format(host, port))
28+
if use_tls:
29+
with open('../roots.pem', 'rb') as f:
30+
creds = grpc.ssl_channel_credentials(f.read())
31+
channel = grpc.secure_channel('{}:{}'.format(host, port), creds)
32+
else:
33+
channel = grpc.insecure_channel('{}:{}'.format(host, port))
2934

3035
stub = bookstore_pb2_grpc.BookstoreStub(channel)
3136
metadata = []
@@ -52,5 +57,8 @@ def run(host, port, api_key, auth_token, timeout):
5257
parser.add_argument(
5358
'--auth_token', default=None,
5459
help='The JWT auth token to use for the call')
60+
parser.add_argument(
61+
'--use_tls', type=bool, default=False,
62+
help='Enable when the server requires TLS')
5563
args = parser.parse_args()
56-
run(args.host, args.port, args.api_key, args.auth_token, args.timeout)
64+
run(args.host, args.port, args.api_key, args.auth_token, args.timeout, args.use_tls)

endpoints/bookstore-grpc/bookstore_server.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import argparse
1818
from concurrent import futures
1919
import time
20+
import os
2021

2122
from google.protobuf import struct_pb2
2223
import grpc
@@ -109,6 +110,8 @@ def serve(port, shutdown_grace_duration):
109110
server.add_insecure_port('[::]:{}'.format(port))
110111
server.start()
111112

113+
print('Listening on port {}'.format(port))
114+
112115
try:
113116
while True:
114117
time.sleep(_ONE_DAY_IN_SECONDS)
@@ -121,11 +124,20 @@ def serve(port, shutdown_grace_duration):
121124
description=__doc__,
122125
formatter_class=argparse.RawDescriptionHelpFormatter)
123126
parser.add_argument(
124-
'--port', type=int, default=8000, help='The port to listen on')
127+
'--port', type=int, default=None,
128+
help='The port to listen on.'
129+
'If arg is not set, will listen on the $PORT env var.'
130+
'If env var is empty, defaults to 8000.')
125131
parser.add_argument(
126132
'--shutdown_grace_duration', type=int, default=5,
127133
help='The shutdown grace duration, in seconds')
128134

129135
args = parser.parse_args()
130136

131-
serve(args.port, args.shutdown_grace_duration)
137+
port = args.port
138+
if not port:
139+
port = os.environ.get('PORT')
140+
if not port:
141+
port = 8000
142+
143+
serve(port, args.shutdown_grace_duration)

0 commit comments

Comments
 (0)