Skip to content

Commit 24a1a19

Browse files
committed
Merge remote-tracking branch 'remote.googleapis/gapic-generator-python/main' into migration.gapic-generator-python.migration.2025-11-24_21-55-24.migrate
2 parents 0737369 + 1fdf60b commit 24a1a19

File tree

1,069 files changed

+357271
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,069 files changed

+357271
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# See https://github.com/bazelbuild/bazelisk
2+
USE_BAZEL_VERSION=6.5.0

packages/gapic-generator/.bazelrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# New protobuf requires C++17
2+
build --repo_env=BAZEL_CXXOPTS="-std=c++17"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[run]
2+
branch = True
3+
omit =
4+
gapic/cli/*.py
5+
*_pb2.py
6+
7+
[report]
8+
fail_under = 100
9+
show_missing = True
10+
exclude_lines =
11+
# Re-enable the standard pragma
12+
pragma: NO COVER
13+
# Enable an English version.
14+
Impossible; skip coverage checks.
15+
# Ignore debug-only repr
16+
def __repr__
17+
# Abstract methods by definition are not invoked
18+
@abstractmethod
19+
@abc.abstractmethod
20+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Version control scaffolding
2+
.git
3+
.gitignore
4+
5+
# Python scaffolding
6+
*.py[cod]
7+
*.egg
8+
*.egg-info
9+
dist
10+
build
11+
eggs
12+
parts
13+
bin
14+
var
15+
sdist
16+
develop-eggs
17+
.installed.cfg
18+
lib
19+
lib64
20+
__pycache__
21+
22+
# Installer logs
23+
pip-log.txt
24+
25+
# Unit test / coverage reports
26+
.coverage
27+
.nox
28+
.tox
29+
.cache
30+
.pytest_cache
31+
htmlcov
32+
33+
# Translations
34+
*.mo
35+
36+
# Mac
37+
.DS_Store
38+
39+
# Mr Developer
40+
.mr.developer.cfg
41+
.project
42+
.pydevproject
43+
44+
# JetBrains
45+
.idea
46+
47+
# Built documentation
48+
docs/_build
49+
docs/_build_doc2dash
50+
51+
# Virtual environment
52+
env/
53+
coverage.xml
54+
55+
# Make sure a generated file isn't accidentally committed.
56+
pylintrc
57+
pylintrc.test

packages/gapic-generator/.flake8

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[flake8]
2+
ignore =
3+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): E123, E124
4+
# Closing bracket mismatches opening bracket's line.
5+
# This works poorly with type annotations in method declarations.
6+
E123, E124
7+
# Line over-indented for visual indent.
8+
# This works poorly with type annotations in method declarations.
9+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): E126, E128, E131
10+
E126, E128, E131
11+
# Line break after binary operator.
12+
# This catches line breaks after "and" / "or" as a means of breaking up
13+
# long if statements, which PEP 8 explicitly encourages.
14+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): W504
15+
W504
16+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): E203
17+
E203
18+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): E501
19+
E501
20+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): E712
21+
E712
22+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): E711
23+
E711
24+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): E722
25+
E722
26+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): E741
27+
E741
28+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): F401
29+
F401
30+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): F541
31+
F541
32+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): F841
33+
F841
34+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): F811
35+
F811
36+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): W503
37+
W503
38+
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2333): W291
39+
W291
40+
exclude =
41+
# Exclude golden files
42+
tests/integration
43+
# Exclude generated protobuf code
44+
*_pb2.py
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#!/bin/sh
2+
3+
# Copyright 2021 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Pre-commit Git checks.
18+
# Set up:
19+
# ln -s .githooks/pre-commit .git/hooks/pre-commit
20+
21+
# Constants.
22+
BOLD="\e[1m"
23+
UNSET="\e[0m"
24+
WHITE="\e[97m"
25+
RED="\e[91m"
26+
BACK_MAGENTA="\e[45m"
27+
BACK_BLUE="\e[44m"
28+
BACK_RED="\e[41m"
29+
BACK_GREEN="\e[42m"
30+
31+
# Methods.
32+
function echo_error {
33+
ERR_MSG=$1
34+
HELP_MSG=$2
35+
echo -e "$BOLD $BACK_BLUE $WHITE Precommit:\t $BACK_RED Changes NOT committed. $UNSET"
36+
echo -e "$BOLD $BACK_BLUE $WHITE Precommit:\t $BACK_RED $WHITE $ERR_MSG $BACK_BLUE $HELP_MSG $UNSET"
37+
}
38+
39+
function echo_status {
40+
STATUS_MSG=$1
41+
echo -e "$BOLD $BACK_BLUE $WHITE Precommit:\t $STATUS_MSG $UNSET"
42+
}
43+
44+
function echo_success {
45+
echo -e "$BOLD $BACK_BLUE $WHITE Precommit:\t $BACK_GREEN $WHITE SUCCESS. $UNSET All checks passed!"
46+
}
47+
48+
function header_check_preparation {
49+
echo_status "Setting up license check environment"
50+
export GOPATH=$(go env GOPATH)
51+
if [ $? -ne 0 ];
52+
then
53+
echo_status "Please install Go first, instructions can be found here: https://golang.org/doc/install."
54+
else
55+
export ENV_PATH=$(echo $PATH)
56+
if [[ $ENV_PATH != *$GOPATH* ]];
57+
then
58+
echo_status "GOPATH is not in the system path, adding it now."
59+
export PATH=$GOPATH/bin:$PATH
60+
fi
61+
which addlicense
62+
if [ $? -ne 0 ];
63+
then
64+
echo_status "addlicense tool is not yet installed, downloading it now."
65+
go get -u github.com/google/addlicense
66+
fi
67+
fi
68+
}
69+
70+
# Disk cache.
71+
BAZEL_CACHE_DIR=/tmp/bazel_cache_gapic_generator_java
72+
if [ ! -d $BAZEL_CACHE_DIR ]
73+
then
74+
mkdir $BAZEL_CACHE_DIR
75+
fi
76+
77+
# Check only the staged files.
78+
NUM_TOTAL_FILES_CHANGED=$(git diff --cached --name-only | wc -l)
79+
NUM_PYTHON_FILES_CHANGED=$(git diff --cached --name-only "*.py" | wc -l)
80+
NUM_UNIT_GOLDEN_FILES_CHANGED=$(git diff --cached --name-only "src/test/*/*.golden" | wc -l)
81+
NUM_INTEGRATION_GOLDEN_FILES_CHANGED=$(git diff --cached --name-only "tests/integration/goldens/*/*.golden" | wc -l)
82+
NUM_INTEGRATION_BAZEL_FILES_CHANGED=$(git diff --cached --name-only "tests/integration/*/BUILD.bazel" | wc -l)
83+
NUM_BAZEL_FILES_CHANGED=$(git diff --cached --name-only "*BUILD.bazel" | wc -l)
84+
85+
if [ $NUM_TOTAL_FILES_CHANGED -le 0 ]
86+
then
87+
echo_error "No new files to commit." ""
88+
exit 1
89+
fi
90+
91+
92+
if [ -x /usr/lib/git-core/google_hook ]; then
93+
/usr/lib/git-core/google_hook pre-commit "$@"
94+
fi
95+
96+
# Check unit tests.
97+
if [ $NUM_PYTHON_FILES_CHANGED -gt 0 ] || [ $NUM_UNIT_GOLDEN_FILES_CHANGED -gt 0 ]
98+
then
99+
echo_status "Checking unit tests..."
100+
nox -s unit-3.9
101+
TEST_STATUS=$?
102+
if [ $TEST_STATUS != 0 ]
103+
then
104+
echo_error "Tests failed." "Please fix them and try again."
105+
exit 1
106+
fi
107+
fi
108+
109+
# Check integration tests.
110+
if [ $NUM_PYTHON_FILES_CHANGED -gt 0 ] \
111+
|| [ $NUM_INTEGRATION_GOLDEN_FILES_CHANGED -gt 0 ] \
112+
|| [ $NUM_INTEGRATION_BAZEL_FILES_CHANGED -gt 0 ]
113+
then
114+
echo_status "Checking integration tests..."
115+
bazel --batch test --disk_cache="$BAZEL_CACHE_DIR" //tests/integration/...
116+
TEST_STATUS=$?
117+
if [ $TEST_STATUS != 0 ]
118+
then
119+
echo_error "Tests failed." "Please fix them and try again."
120+
exit 1
121+
fi
122+
fi
123+
124+
# Check and fix Bazel format.
125+
if [ $NUM_BAZEL_FILES_CHANGED -gt 0 ]
126+
then
127+
for FILE in $(find ./ -name BUILD.bazel)
128+
do
129+
buildifier --lint=fix $FILE
130+
done
131+
fi
132+
133+
echo_success
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Code owners file.
2+
# This file controls who is tagged for review for any given pull request.
3+
4+
* @googleapis/python-core-client-libraries
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# How to Contribute
2+
3+
We'd love to accept your patches and contributions to this project. There are
4+
just a few small guidelines you need to follow.
5+
6+
## Contributor License Agreement
7+
8+
Contributions to this project must be accompanied by a Contributor License
9+
Agreement. You (or your employer) retain the copyright to your contribution;
10+
this simply gives us permission to use and redistribute your contributions as
11+
part of the project. Head over to <https://cla.developers.google.com/> to see
12+
your current agreements on file or to sign a new one.
13+
14+
You generally only need to submit a CLA once, so if you've already submitted one
15+
(even if it was for a different project), you probably don't need to do it
16+
again.
17+
18+
## Code reviews
19+
20+
All submissions, including submissions by project members, require review. We
21+
use GitHub pull requests for this purpose. Consult
22+
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
23+
information on using pull requests.
24+
25+
## Community Guidelines
26+
27+
This project follows [Google's Open Source Community
28+
Guidelines](https://opensource.google.com/conduct/).
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
5+
---
6+
7+
Thanks for stopping by to let us know something could be better!
8+
9+
**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.
10+
11+
Please run down the following list and make sure you've tried the usual "quick fixes":
12+
13+
- Search the issues already opened: https://github.com/googleapis/gapic-generator-python/issues
14+
- Search StackOverflow: https://stackoverflow.com/questions/tagged/google-cloud-platform+python
15+
16+
If you are still having issues, please be sure to include as much information as possible:
17+
18+
#### Environment details
19+
20+
- OS type and version:
21+
- Python version: `python --version`
22+
- pip version: `pip --version`
23+
- `gapic-generator` version: `pip show gapic-generator`
24+
25+
#### Steps to reproduce
26+
27+
1. ?
28+
2. ?
29+
30+
#### Code example
31+
32+
```python
33+
# example
34+
```
35+
36+
#### Stack trace
37+
```
38+
# example
39+
```
40+
41+
Making sure to follow these steps will guarantee the quickest resolution possible.
42+
43+
Thanks!
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this library
4+
5+
---
6+
7+
Thanks for stopping by to let us know something could be better!
8+
9+
**PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response.
10+
11+
**Is your feature request related to a problem? Please describe.**
12+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
**Describe alternatives you've considered**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
**Additional context**
18+
Add any other context or screenshots about the feature request here.

0 commit comments

Comments
 (0)