Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate code from googleapis/python-cloudbuild #8473

Merged
merged 88 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
78d493b
feat!: migrate to use microgenerator (#23)
arithmetic1728 Jul 23, 2020
438080d
docs: Adding samples (#69)
dinagraves Mar 25, 2021
e5290de
chore(deps): update dependency google-cloud-build to v3.1.0 (#76)
renovate-bot Mar 26, 2021
fbf10ce
chore(deps): update dependency google-cloud-build to v3.1.1 (#77)
renovate-bot Apr 1, 2021
4a1354b
chore(deps): update dependency google-cloud-build to v3.2.0 (#80)
renovate-bot Apr 3, 2021
de7e062
chore(deps): update dependency google-auth to v1.28.1 (#83)
renovate-bot Apr 10, 2021
466b593
chore(deps): update dependency pytest to v6.2.3 (#85)
renovate-bot Apr 12, 2021
9098a56
chore(deps): update dependency google-auth to v1.30.0 (#87)
renovate-bot Apr 28, 2021
67b2ff1
chore(deps): update dependency pytest to v6.2.4 (#92)
renovate-bot May 13, 2021
3b7ad5f
chore(deps): update dependency google-cloud-build to v3.2.1 (#103)
renovate-bot May 18, 2021
fdc359b
chore(deps): update dependency google-auth to v1.30.1 (#107)
renovate-bot May 25, 2021
89a0e56
chore(deps): update dependency google-auth to v1.30.2 (#109)
renovate-bot Jun 9, 2021
9c91ec0
chore(deps): update dependency google-auth to v1.31.0 (#110)
renovate-bot Jun 10, 2021
85ad643
chore(deps): update dependency google-auth to v1.32.0 (#117)
renovate-bot Jun 26, 2021
84df89e
chore(deps): update dependency google-auth to v1.32.1 (#124)
renovate-bot Jun 30, 2021
5ba12d4
chore(deps): update dependency google-cloud-build to v3.3.0 (#125)
renovate-bot Jul 1, 2021
2dec2f3
chore(deps): update dependency google-auth to v1.33.0 (#128)
renovate-bot Jul 15, 2021
3eb3348
chore(deps): update dependency google-auth to v1.33.1 (#133)
renovate-bot Jul 21, 2021
b334022
chore(deps): update dependency google-cloud-build to v3.3.1 (#140)
renovate-bot Jul 26, 2021
76e526d
chore(deps): update dependency google-auth to v1.34.0 (#141)
renovate-bot Jul 28, 2021
7a2a3af
chore(deps): update dependency google-cloud-build to v3.3.2 (#144)
renovate-bot Jul 29, 2021
bae2d11
chore(deps): update dependency google-auth to v1.35.0 (#148)
renovate-bot Aug 17, 2021
aea1f78
chore: add missing import in owlbot.py (#152)
parthea Aug 20, 2021
295e129
chore(deps): update dependency google-auth to v2 (#150)
renovate-bot Aug 20, 2021
943e888
chore(deps): update dependency google-cloud-build to v3.4.0 (#153)
renovate-bot Aug 23, 2021
0aa4f1a
chore(deps): update dependency google-cloud-build to v3.5.0 (#162)
renovate-bot Aug 31, 2021
927ba3a
chore(deps): update dependency pytest to v6.2.5 (#161)
renovate-bot Aug 31, 2021
1c489d0
chore(deps): update dependency google-auth to v2.0.2 (#163)
renovate-bot Sep 1, 2021
20804d7
chore(deps): update dependency google-auth to v2.1.0 (#167)
renovate-bot Sep 16, 2021
feec642
chore: blacken samples noxfile template (#168)
gcf-owl-bot[bot] Sep 17, 2021
44284d8
chore(deps): update dependency google-cloud-build to v3.5.1 (#174)
renovate-bot Sep 24, 2021
447a8d9
chore(deps): update dependency google-auth to v2.2.0 (#175)
renovate-bot Sep 27, 2021
a66b340
chore(deps): update dependency google-auth to v2.2.1 (#176)
renovate-bot Sep 29, 2021
627fa17
chore: fail samples nox session if python version is missing (#179)
gcf-owl-bot[bot] Sep 30, 2021
36b5d9f
chore(python): Add kokoro configs for python 3.10 samples testing (#186)
gcf-owl-bot[bot] Oct 8, 2021
ace00b5
chore(deps): update dependency google-cloud-build to v3.5.2 (#180)
renovate-bot Oct 9, 2021
a14ff57
chore(deps): update dependency google-auth to v2.3.0 (#187)
renovate-bot Oct 11, 2021
dac754d
chore(deps): update dependency google-cloud-build to v3.6.0 (#188)
renovate-bot Oct 12, 2021
6965596
chore(deps): update dependency google-cloud-build to v3.7.0 (#191)
renovate-bot Oct 15, 2021
dea2200
chore(deps): update dependency google-auth to v2.3.1 (#192)
renovate-bot Oct 25, 2021
a661fce
chore(deps): update dependency google-auth to v2.3.2 (#194)
renovate-bot Oct 26, 2021
7649cb6
chore(deps): update dependency google-auth to v2.3.3 (#197)
renovate-bot Nov 2, 2021
b47ae12
chore(deps): update dependency google-cloud-build to v3.7.1 (#203)
renovate-bot Nov 9, 2021
c712324
chore: update python-docs-samples link to main branch (#207)
gcf-owl-bot[bot] Dec 12, 2021
bb253f2
chore(samples): Add check for tests in directory (#214)
gcf-owl-bot[bot] Jan 11, 2022
8a29734
chore(python): Noxfile recognizes that tests can live in a folder (#219)
gcf-owl-bot[bot] Jan 19, 2022
23e5799
chore(deps): update all dependencies (#224)
renovate-bot Feb 7, 2022
d7c58a3
chore(deps): update dependency pytest to v7.0.1 (#229)
renovate-bot Feb 14, 2022
fbe596d
chore(deps): update dependency google-cloud-build to v3.8.0 (#230)
renovate-bot Feb 23, 2022
7e16765
chore: Adding support for pytest-xdist and pytest-parallel (#240)
gcf-owl-bot[bot] Mar 4, 2022
36b3a64
chore(deps): update dependency google-cloud-build to v3.8.1 (#243)
renovate-bot Mar 7, 2022
22fd651
chore(deps): update dependency pytest to v7.1.0 (#246)
renovate-bot Mar 13, 2022
de17fa3
chore(deps): update all dependencies (#247)
renovate-bot Mar 19, 2022
2b6dbe2
chore(python): use black==22.3.0 (#250)
gcf-owl-bot[bot] Mar 29, 2022
87967fc
chore(deps): update dependency google-auth to v2.6.3 (#261)
renovate-bot Apr 7, 2022
0d27920
chore(deps): update dependency google-auth to v2.6.4 (#265)
renovate-bot Apr 12, 2022
692eddf
chore(deps): update dependency google-auth to v2.6.5 (#267)
renovate-bot Apr 15, 2022
d396ffb
chore(quickstart): clarify private pools instructions (#268)
Apr 19, 2022
1479493
chore(python): add nox session to sort python imports (#269)
gcf-owl-bot[bot] Apr 21, 2022
5a6593e
chore(deps): update dependency google-auth to v2.6.6 (#272)
renovate-bot Apr 22, 2022
f394338
chore(deps): update dependency pytest to v7.1.2 (#273)
renovate-bot Apr 25, 2022
fbb8ef7
chore(deps): update dependency google-cloud-build to v3.8.2 (#278)
renovate-bot May 5, 2022
8767483
fix: require python 3.7+ (#308)
gcf-owl-bot[bot] Jul 10, 2022
02490d1
chore(deps): update all dependencies (#300)
renovate-bot Jul 16, 2022
9361e88
chore(deps): update all dependencies (#314)
renovate-bot Aug 2, 2022
088c1d4
chore(deps): update all dependencies (#317)
renovate-bot Aug 6, 2022
8c6f1b5
chore(deps): update dependency google-cloud-build to v3.9.1 (#323)
renovate-bot Aug 18, 2022
4ce6763
chore(python): Add example of using client_options for regional endpo…
joshuamo Aug 18, 2022
8baad9f
chore(deps): update dependency google-auth to v2.11.0 (#325)
renovate-bot Aug 23, 2022
c9507fd
chore(deps): update dependency pytest to v7.1.3 (#335)
renovate-bot Sep 6, 2022
98d7986
chore: detect samples tests in nested directories (#339)
gcf-owl-bot[bot] Sep 13, 2022
be38215
chore(deps): update dependency google-auth to v2.11.1 (#340)
renovate-bot Sep 20, 2022
42e452f
chore(deps): update dependency google-auth to v2.12.0 (#343)
renovate-bot Oct 3, 2022
28c128f
chore(deps): update dependency google-cloud-build to v3.9.2 (#345)
renovate-bot Oct 4, 2022
d41a48c
chore(deps): update dependency google-cloud-build to v3.9.3 (#348)
renovate-bot Oct 10, 2022
335977b
chore(deps): update dependency google-auth to v2.13.0 (#349)
renovate-bot Oct 18, 2022
7934f8a
chore(deps): update dependency pytest to v7.2.0 (#350)
renovate-bot Oct 26, 2022
5af6eb3
chore(deps): update dependency google-auth to v2.14.0 (#354)
renovate-bot Nov 1, 2022
2d33288
Merge remote-tracking branch 'migration/main' into python-cloudbuild-…
donmccasland Nov 8, 2022
bfdaf13
Adding 2.7 test
donmccasland Nov 8, 2022
84b6a24
Removing 2.7 test
donmccasland Nov 8, 2022
31a92c9
removing noxfile and adding noxfile_config.py
donmccasland Nov 8, 2022
af372c6
Merge branch 'main' into python-cloudbuild-migration
donmccasland Nov 8, 2022
e450172
Adding CODEOWNERS and blunderbuss
donmccasland Nov 9, 2022
01c20f0
updating owners
donmccasland Nov 9, 2022
67c7cd8
Update cloudbuild/snippets/quickstart.py
donmccasland Nov 9, 2022
3cf3348
Update cloudbuild/snippets/quickstart_test.py
donmccasland Nov 9, 2022
c278ce9
Update cloudbuild/snippets/quickstart_test.py
donmccasland Nov 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/billing/**/* @GoogleCloudPlatform/billing-samples-maintainers @GoogleCloudPlatform/python-samples-reviewers
/blog/**/* @GoogleCloudPlatform/python-samples-reviewers
/cdn/**/* @mpwarres @GoogleCloudPlatform/python-samples-reviewers
/cloudbuild/**/* @GoogleCloudPlatform/torus-dpe @GoogleCloudPlatform/python-samples-reviewers
/cloud-sql/**/* @GoogleCloudPlatform/infra-db-dpes @GoogleCloudPlatform/python-samples-reviewers
/codelabs/**/* @GoogleCloudPlatform/python-samples-reviewers
/composer/**/* @leahecole @rachael-ds @rafalbiegacz @GoogleCloudPlatform/python-samples-reviewers
Expand Down
4 changes: 4 additions & 0 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ assign_issues_by:
- 'api: cloudbilling'
to:
- GoogleCloudPlatform/billing-samples-maintainers
- labels:
- 'api: cloudbuild'
to:
- GoogleCloudPlatform/torus-dpe
- labels:
- 'api: cloudsql'
to:
Expand Down
1 change: 1 addition & 0 deletions cloudbuild/AUTHORING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md
1 change: 1 addition & 0 deletions cloudbuild/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/CONTRIBUTING.md
40 changes: 40 additions & 0 deletions cloudbuild/snippets/noxfile_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Default TEST_CONFIG_OVERRIDE for python repos.

# You can copy this file into your directory, then it will be imported from
# the noxfile.py.

# The source of truth:
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py

TEST_CONFIG_OVERRIDE = {
# You can opt out from the test for specific Python versions.
# NOTE: We currently only run the test in Python 3.8.
"ignored_versions": ["2.7"],
# Old samples are opted out of enforcing Python type hints
# All new samples should feature them
"enforce_type_hints": True,
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
# to use your own Cloud project.
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
# A dictionary you want to inject into your test. Don't put any
# secrets here. These values will override predefined values.
"envs": {
},
}
60 changes: 60 additions & 0 deletions cloudbuild/snippets/quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# [START cloudbuild_quickstart]
import google.auth
from google.cloud.devtools import cloudbuild_v1


def quickstart() -> None:
"""Create and execute a simple Google Cloud Build configuration,
print the in-progress status and print the completed status."""

# Authorize the client with Google defaults
credentials, project_id = google.auth.default()
client = cloudbuild_v1.services.cloud_build.CloudBuildClient()

# If you're using Private Pools or a non-global default pool, add a regional
# `api_endpoint` to `CloudBuildClient()`
# For example, '<YOUR_POOL_REGION>-cloudbuild.googleapis.com'
#
# from google.api_core import client_options
# client_options = client_options.ClientOptions(
# api_endpoint="us-central1-cloudbuild.googleapis.com"
# )
# client = cloudbuild_v1.services.cloud_build.CloudBuildClient(client_options=client_options)

build = cloudbuild_v1.Build()

# The following build steps will output "hello world"
# For more information on build configuration, see
# https://cloud.google.com/build/docs/configuring-builds/create-basic-configuration
build.steps = [{"name": "ubuntu",
"entrypoint": "bash",
"args": ["-c", "echo hello world"]}]

operation = client.create_build(project_id=project_id, build=build)
# Print the in-progress operation
print("IN PROGRESS:")
print(operation.metadata)

result = operation.result()
# Print the completed status
print("RESULT:", result.status)
# [END cloudbuild_quickstart]


if __name__ == "__main__":
quickstart()
27 changes: 27 additions & 0 deletions cloudbuild/snippets/quickstart_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


import pytest

import quickstart
donmccasland marked this conversation as resolved.
Show resolved Hide resolved


def test_quickstart(capsys: pytest.CaptureFixture) -> None:
quickstart.quickstart()
out, _ = capsys.readouterr()
# Prints in-progress message
assert "hello world" in out
# Prints final status
assert "Status.SUCCESS" in out
1 change: 1 addition & 0 deletions cloudbuild/snippets/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==7.2.0
2 changes: 2 additions & 0 deletions cloudbuild/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
google-cloud-build==3.9.3
google-auth==2.14.0