Skip to content

Commit ddaa7b5

Browse files
committed
add .kokoro for CI on Google Cloud
Updates #289
1 parent 7fccabe commit ddaa7b5

File tree

9 files changed

+214
-0
lines changed

9 files changed

+214
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eo pipefail
17+
18+
cd github/python-spanner-django
19+
20+
# Disable buffering, so that the logs stream through.
21+
export PYTHONUNBUFFERED=1
22+
23+
# Debug: show build environment
24+
env | grep KOKORO
25+
26+
# Setup service account credentials.
27+
export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/service-account.json
28+
29+
# Setup project id.
30+
export PROJECT_ID=$(cat "${KOKORO_GFILE_DIR}/project-id.json")
31+
32+
# Install tox
33+
python3.6 -m pip install --upgrade --quiet tox
34+
python3.6 -m tox --version
35+
36+
python3.6 -m tox
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Build logs will be here
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Download trampoline resources.
11+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
12+
13+
# Download resources for system tests (service account key, etc.)
14+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"
15+
16+
# Use the trampoline script to run in docker.
17+
build_file: "python-spanner-django/.kokoro/trampoline.sh"
18+
19+
# Configure the docker image for kokoro-trampoline.
20+
env_vars: {
21+
key: "TRAMPOLINE_IMAGE"
22+
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
23+
}
24+
env_vars: {
25+
key: "TRAMPOLINE_BUILD_FILE"
26+
value: "github/python-spanner-django/.kokoro/build.sh"
27+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Build logs will be here
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Download trampoline resources.
11+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
12+
13+
# Download resources for system tests (service account key, etc.)
14+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-python"
15+
16+
# Use the trampoline script to run in docker.
17+
build_file: "python-spanner-django/.kokoro/trampoline.sh"
18+
19+
# Configure the docker image for kokoro-trampoline.
20+
env_vars: {
21+
key: "TRAMPOLINE_IMAGE"
22+
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
23+
}
24+
env_vars: {
25+
key: "TRAMPOLINE_BUILD_FILE"
26+
value: "github/python-spanner-django/.kokoro/build.sh"
27+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
# Copyright 2020 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
#!/bin/bash
17+
18+
set -eo pipefail
19+
20+
# Start the releasetool reporter
21+
python3 -m pip install gcp-releasetool
22+
python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
23+
24+
# Ensure that we have the latest versions of Twine, Wheel, and Setuptools.
25+
python3 -m pip install --upgrade twine wheel setuptools
26+
27+
# Disable buffering, so that the logs stream through.
28+
export PYTHONUNBUFFERED=1
29+
30+
# Move into the package, build the distribution and upload.
31+
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google_cloud_pypi_password")
32+
cd github/python-spanner
33+
python3 setup.py sdist bdist_wheel
34+
twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/*
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
2+
3+
# Build logs will be here
4+
action {
5+
define_artifacts {
6+
regex: "**/*sponge_log.xml"
7+
}
8+
}
9+
10+
# Download trampoline resources.
11+
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
12+
13+
# Use the trampoline script to run in docker.
14+
build_file: "python-spanner-django/.kokoro/trampoline.sh"
15+
16+
# Configure the docker image for kokoro-trampoline.
17+
env_vars: {
18+
key: "TRAMPOLINE_IMAGE"
19+
value: "gcr.io/cloud-devrel-kokoro-resources/python-multi"
20+
}
21+
env_vars: {
22+
key: "TRAMPOLINE_BUILD_FILE"
23+
value: "github/python-spanner-django/.kokoro/release.sh"
24+
}
25+
26+
# Fetch the token needed for reporting release status to GitHub
27+
before_action {
28+
fetch_keystore {
29+
keystore_resource {
30+
keystore_config_id: 73713
31+
keyname: "yoshi-automation-github-key"
32+
}
33+
}
34+
}
35+
36+
# Fetch PyPI password
37+
before_action {
38+
fetch_keystore {
39+
keystore_resource {
40+
keystore_config_id: 73713
41+
keyname: "google_cloud_pypi_password"
42+
}
43+
}
44+
}
45+
46+
# Fetch magictoken to use with Magic Github Proxy
47+
before_action {
48+
fetch_keystore {
49+
keystore_resource {
50+
keystore_config_id: 73713
51+
keyname: "releasetool-magictoken"
52+
}
53+
}
54+
}
55+
56+
# Fetch api key to use with Magic Github Proxy
57+
before_action {
58+
fetch_keystore {
59+
keystore_resource {
60+
keystore_config_id: 73713
61+
keyname: "magic-github-proxy-api-key"
62+
}
63+
}
64+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Format: //devtools/kokoro/config/proto/build.proto
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# Copyright 2020 Google LLC.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eo pipefail
17+
18+
python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" || ret_code=$?
19+
20+
chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
21+
${KOKORO_GFILE_DIR}/trampoline_cleanup.sh || true
22+
23+
exit ${ret_code}

0 commit comments

Comments
 (0)