Skip to content

Commit 14cf702

Browse files
authored
chore: migrate to owl bot (#48)
* chore: migrate to owl bot * run post processor
1 parent 04de3ca commit 14cf702

File tree

8 files changed

+80
-121
lines changed

8 files changed

+80
-121
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
docker:
15+
digest: sha256:c66ba3c8d7bc8566f47df841f98cd0097b28fff0b1864c86f5817f4c8c3e8600
16+
image: gcr.io/repo-automation-bots/owlbot-python:latest
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
docker:
16+
image: gcr.io/repo-automation-bots/owlbot-python:latest
17+
18+
begin-after-commit-hash: 6acf4a0a797f1082027985c55c4b14b60f673dd7

packages/googleapis-common-protos/.github/header-checker-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{"allowedCopyrightHolders": ["Google LLC"],
22
"allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"],
3-
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"],
3+
"ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt", "**/__init__.py", "samples/**/constraints.txt", "samples/**/constraints-test.txt"],
44
"sourceFileExtensions": [
55
"ts",
66
"js",

packages/googleapis-common-protos/.kokoro/release.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools
2626
export PYTHONUNBUFFERED=1
2727

2828
# Move into the package, build the distribution and upload.
29-
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google_cloud_pypi_password")
29+
TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token")
3030
cd github/python-api-common-protos
3131
python3 setup.py sdist bdist_wheel
32-
twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/*
32+
twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/*

packages/googleapis-common-protos/.kokoro/release/common.cfg

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,8 @@ env_vars: {
2323
value: "github/python-api-common-protos/.kokoro/release.sh"
2424
}
2525

26-
# Fetch PyPI password
27-
before_action {
28-
fetch_keystore {
29-
keystore_resource {
30-
keystore_config_id: 73713
31-
keyname: "google_cloud_pypi_password"
32-
}
33-
}
34-
}
35-
3626
# Tokens needed to report release status back to GitHub
3727
env_vars: {
3828
key: "SECRET_MANAGER_KEYS"
39-
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
40-
}
29+
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token"
30+
}

packages/googleapis-common-protos/.kokoro/test-samples.sh

Lines changed: 16 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
# The default test runner for samples.
17+
#
18+
# For periodic builds, we rewinds the repo to the latest release, and
19+
# run test-samples-impl.sh.
1620

1721
# `-e` enables the script to automatically fail when a command fails
1822
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
@@ -24,81 +28,19 @@ cd github/python-api-common-protos
2428

2529
# Run periodic samples tests at latest release
2630
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
31+
# preserving the test runner implementation.
32+
cp .kokoro/test-samples-impl.sh "${TMPDIR}/test-samples-impl.sh"
33+
echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
34+
echo "Now we rewind the repo back to the latest release..."
2735
LATEST_RELEASE=$(git describe --abbrev=0 --tags)
2836
git checkout $LATEST_RELEASE
29-
fi
30-
31-
# Disable buffering, so that the logs stream through.
32-
export PYTHONUNBUFFERED=1
33-
34-
# Debug: show build environment
35-
env | grep KOKORO
36-
37-
# Install nox
38-
python3.6 -m pip install --upgrade --quiet nox
39-
40-
# Use secrets acessor service account to get secrets
41-
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then
42-
gcloud auth activate-service-account \
43-
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \
44-
--project="cloud-devrel-kokoro-resources"
45-
fi
46-
47-
# This script will create 3 files:
48-
# - testing/test-env.sh
49-
# - testing/service-account.json
50-
# - testing/client-secrets.json
51-
./scripts/decrypt-secrets.sh
52-
53-
source ./testing/test-env.sh
54-
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json
55-
56-
# For cloud-run session, we activate the service account for gcloud sdk.
57-
gcloud auth activate-service-account \
58-
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}"
59-
60-
export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json
61-
62-
echo -e "\n******************** TESTING PROJECTS ********************"
63-
64-
# Switch to 'fail at end' to allow all tests to complete before exiting.
65-
set +e
66-
# Use RTN to return a non-zero value if the test fails.
67-
RTN=0
68-
ROOT=$(pwd)
69-
# Find all requirements.txt in the samples directory (may break on whitespace).
70-
for file in samples/**/requirements.txt; do
71-
cd "$ROOT"
72-
# Navigate to the project folder.
73-
file=$(dirname "$file")
74-
cd "$file"
75-
76-
echo "------------------------------------------------------------"
77-
echo "- testing $file"
78-
echo "------------------------------------------------------------"
79-
80-
# Use nox to execute the tests for the project.
81-
python3.6 -m nox -s "$RUN_TESTS_SESSION"
82-
EXIT=$?
83-
84-
# If this is a periodic build, send the test log to the Build Cop Bot.
85-
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop.
86-
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
87-
chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop
88-
$KOKORO_GFILE_DIR/linux_amd64/buildcop
37+
echo "The current head is: "
38+
echo $(git rev-parse --verify HEAD)
39+
echo "--- IMPORTANT IMPORTANT IMPORTANT ---"
40+
# move back the test runner implementation if there's no file.
41+
if [ ! -f .kokoro/test-samples-impl.sh ]; then
42+
cp "${TMPDIR}/test-samples-impl.sh" .kokoro/test-samples-impl.sh
8943
fi
44+
fi
9045

91-
if [[ $EXIT -ne 0 ]]; then
92-
RTN=1
93-
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
94-
else
95-
echo -e "\n Testing completed.\n"
96-
fi
97-
98-
done
99-
cd "$ROOT"
100-
101-
# Workaround for Kokoro permissions issue: delete secrets
102-
rm testing/{test-env.sh,client-secrets.json,service-account.json}
103-
104-
exit "$RTN"
46+
exec .kokoro/test-samples-impl.sh

packages/googleapis-common-protos/synth.py renamed to packages/googleapis-common-protos/owlbot.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import os
15+
import subprocess
16+
import shutil
1517

1618

1719
import synthtool as s
1820
import synthtool.gcp as gcp
19-
from synthtool import tmp
2021
from synthtool.languages import python
2122
from synthtool.sources import git
2223

@@ -26,29 +27,46 @@
2627
# Get api-common-protos
2728
# ----------------------------------------------------------------------------
2829

29-
# Use api-common-protos as a proper synthtool git source
30+
# Clean up api-common-protos
31+
shutil.rmtree('api-common-protos', ignore_errors=True)
32+
33+
# Clone api-common-protos
3034
api_common_protos_url = git.make_repo_clone_url(API_COMMON_PROTOS_REPO)
31-
api_common_protos = git.clone(api_common_protos_url)
35+
subprocess.run(["git", "clone", api_common_protos_url])
36+
37+
# This is required in order for s.copy() to work
38+
s._tracked_paths.add("api-common-protos/google")
3239

3340
excludes = [
3441
# Exclude iam protos (they are released in a separate package)
3542
"iam/**/*",
3643
"**/BUILD.bazel",
3744
]
38-
s.copy(api_common_protos / "google", excludes=excludes)
45+
s.copy("api-common-protos/google", "google", excludes=excludes)
46+
47+
# Clean up api-common-protos
48+
shutil.rmtree('api-common-protos')
3949

4050
# ----------------------------------------------------------------------------
4151
# Get gapic metadata proto from googleapis
4252
# ----------------------------------------------------------------------------
4353

44-
# Use googleapis as a proper synthtool git source
54+
# Clean up googleapis
55+
shutil.rmtree('googleapis', ignore_errors=True)
56+
57+
# Clone googleapis
4558
googleapis_url = git.make_repo_clone_url(GOOGLEAPIS_REPO)
46-
googleapis_protos = git.clone(googleapis_url)
59+
subprocess.run(["git", "clone", googleapis_url])
60+
61+
# This is required in order for s.copy() to work
62+
s._tracked_paths.add("googleapis/gapic")
4763

4864
# Gapic metadata proto needed by gapic-generator-python
4965
# Desired import is "from google.gapic.metadata import gapic_metadata_pb2"
50-
s.copy(googleapis_protos / "gapic", "google/gapic", excludes=["lang/", "packaging/", "**/BUILD.bazel"],)
66+
s.copy("googleapis/gapic", "google/gapic", excludes=["lang/", "packaging/", "**/BUILD.bazel"],)
5167

68+
# Clean up googleapis
69+
shutil.rmtree('googleapis')
5270

5371
# ----------------------------------------------------------------------------
5472
# Add templated files

packages/googleapis-common-protos/synth.metadata

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)