Skip to content

Commit

Permalink
Merge branch 'master' into simple-nox
Browse files Browse the repository at this point in the history
  • Loading branch information
leahecole authored Feb 10, 2020
2 parents 882742a + d26b380 commit ee53cc5
Show file tree
Hide file tree
Showing 29 changed files with 4,797 additions and 30 deletions.
35 changes: 35 additions & 0 deletions .kokoro/tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ for file in **/requirements.txt; do
fi
fi

# Skip unsupported Python versions for Cloud Functions
# (Some GCF samples' dependencies don't support them)
if [[ "$file" == "functions/"* ]]; then
PYTHON_VERSION="$(python --version 2>&1)"
if [[ "$PYTHON_VERSION" == "Python 2."* || "$PYTHON_VERSION" == "Python 3.5"* ]]; then
# echo -e "\n Skipping $file: Python $PYTHON_VERSION is not supported by Cloud Functions.\n"
continue
fi
fi

echo "------------------------------------------------------------"
echo "- testing $file"
echo "------------------------------------------------------------"
Expand All @@ -95,6 +105,31 @@ for file in **/requirements.txt; do
nox -s "$RUN_TESTS_SESSION"
EXIT=$?

# If this is a continuous build, send the test log to the Build Cop Bot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
XML=$(base64 -w 0 sponge_log.xml)

# See https://github.com/apps/build-cop-bot/installations/5943459.
MESSAGE=$(cat <<EOF
{
"Name": "buildcop",
"Type" : "function",
"Location": "us-central1",
"installation": {"id": "5943459"},
"repo": "GoogleCloudPlatform/python-docs-samples",
"buildID": "$KOKORO_GIT_COMMIT",
"buildURL": "https://source.cloud.google.com/results/invocations/$KOKORO_BUILD_ID",
"xunitXML": "$XML"
}
EOF
)

# Use a service account with access to the repo-automation-bots project.
gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
gcloud pubsub topics publish passthrough --project=repo-automation-bots --message="$MESSAGE"
fi

if [[ $EXIT -ne 0 ]]; then
RTN=1
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
Expand Down
2 changes: 1 addition & 1 deletion appengine/flexible/tasks/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use the official Python image.
# https://hub.docker.com/_/python
FROM python:3.7
FROM python:3.8

# Copy local code to the container image.
ENV APP_HOME /app
Expand Down
2 changes: 1 addition & 1 deletion appengine/standard/flask/tutorial/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Flask==1.1.1
Werkzeug==0.16.0
Werkzeug==0.16.1
6 changes: 3 additions & 3 deletions appengine/standard_python37/cloudsql/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
flask==1.1.1
psycopg2==2.8.4
psycopg2-binary==2.8.4
# psycopg2==2.8.4
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
PyMySQL==0.9.3
SQLAlchemy==1.3.12
SQLAlchemy==1.3.13
2 changes: 1 addition & 1 deletion cloud-sql/mysql/sqlalchemy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Use the official Python image.
# https://hub.docker.com/_/python
FROM python:3.7
FROM python:3.8

# Copy application dependency manifests to the container image.
# Copying this separately prevents re-running pip install on every code change.
Expand Down
2 changes: 1 addition & 1 deletion cloud-sql/mysql/sqlalchemy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Flask==1.1.1
SQLAlchemy==1.3.12
SQLAlchemy==1.3.13
PyMySQL==0.9.3
2 changes: 1 addition & 1 deletion cloud-sql/postgres/sqlalchemy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Use the official Python image.
# https://hub.docker.com/_/python
FROM python:3.7
FROM python:3.8

# Copy application dependency manifests to the container image.
# Copying this separately prevents re-running pip install on every code change.
Expand Down
5 changes: 3 additions & 2 deletions cloud-sql/postgres/sqlalchemy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Flask==1.1.1
SQLAlchemy==1.3.12
pg8000==1.13.2
SQLAlchemy==1.3.13
pg8000==1.13.2; python_version > '3.0'
pg8000==1.12.5; python_version < '3.0'
2 changes: 1 addition & 1 deletion composer/workflows/kubernetes_pod_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
# project-id as the gcr.io images and the service account that Composer
# uses has permission to access the Google Container Registry
# (the default service account has permission)
image='gcr.io/gcp-runtimes/ubuntu_16_0_4')
image='gcr.io/gcp-runtimes/ubuntu_18_0_4')
# [END composer_kubernetespodoperator_minconfig]
# [START composer_kubernetespodoperator_templateconfig]
kubenetes_template_ex = kubernetes_pod_operator.KubernetesPodOperator(
Expand Down
6 changes: 4 additions & 2 deletions composer/workflows/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apache-airflow[gcp]==1.10.6
kubernetes==10.0.1
scipy==1.4.1
numpy==1.17.4
scipy==1.4.1; python_version > '3.0'
scipy==1.2.3; python_version < '3.0'
numpy==1.17.4; python_version > '3.0'
numpy==1.16.6; python_version < '3.0'
2 changes: 1 addition & 1 deletion dataflow/encryption-keys/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
apache-beam[gcp]==2.17.0
apache-beam[gcp]==2.19.0
8 changes: 8 additions & 0 deletions endpoints/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Google Cloud Endpoints Examples

The files in this directory are referenced from [Google Cloud Endpoints Documentation](https://cloud.google.com/endpoints/docs/).

### CA File

`roots.pem` is copied from [github.com/grpc/grpc](https://github.com/grpc/grpc/blob/master/etc/roots.pem).
This file should be updated regularly.
2 changes: 0 additions & 2 deletions endpoints/bookstore-grpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ ADD . /bookstore/
WORKDIR /bookstore
RUN pip install -r requirements.txt

EXPOSE 8000

ENTRYPOINT ["python", "/bookstore/bookstore_server.py"]
14 changes: 11 additions & 3 deletions endpoints/bookstore-grpc/bookstore_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@
import bookstore_pb2_grpc


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

channel = grpc.insecure_channel('{}:{}'.format(host, port))
if use_tls:
with open('../roots.pem', 'rb') as f:
creds = grpc.ssl_channel_credentials(f.read())
channel = grpc.secure_channel('{}:{}'.format(host, port), creds)
else:
channel = grpc.insecure_channel('{}:{}'.format(host, port))

stub = bookstore_pb2_grpc.BookstoreStub(channel)
metadata = []
Expand All @@ -52,5 +57,8 @@ def run(host, port, api_key, auth_token, timeout):
parser.add_argument(
'--auth_token', default=None,
help='The JWT auth token to use for the call')
parser.add_argument(
'--use_tls', type=bool, default=False,
help='Enable when the server requires TLS')
args = parser.parse_args()
run(args.host, args.port, args.api_key, args.auth_token, args.timeout)
run(args.host, args.port, args.api_key, args.auth_token, args.timeout, args.use_tls)
16 changes: 14 additions & 2 deletions endpoints/bookstore-grpc/bookstore_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import argparse
from concurrent import futures
import time
import os

from google.protobuf import struct_pb2
import grpc
Expand Down Expand Up @@ -109,6 +110,8 @@ def serve(port, shutdown_grace_duration):
server.add_insecure_port('[::]:{}'.format(port))
server.start()

print('Listening on port {}'.format(port))

try:
while True:
time.sleep(_ONE_DAY_IN_SECONDS)
Expand All @@ -121,11 +124,20 @@ def serve(port, shutdown_grace_duration):
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'--port', type=int, default=8000, help='The port to listen on')
'--port', type=int, default=None,
help='The port to listen on.'
'If arg is not set, will listen on the $PORT env var.'
'If env var is empty, defaults to 8000.')
parser.add_argument(
'--shutdown_grace_duration', type=int, default=5,
help='The shutdown grace duration, in seconds')

args = parser.parse_args()

serve(args.port, args.shutdown_grace_duration)
port = args.port
if not port:
port = os.environ.get('PORT')
if not port:
port = 8000

serve(port, args.shutdown_grace_duration)
Loading

0 comments on commit ee53cc5

Please sign in to comment.