Skip to content

Commit 36ca46b

Browse files
authored
ci: add pylint presubmit on golden files (closes #16393) (#16808)
## Why Issue #16393 asks for a `pylint` presubmit check on the GAPIC golden client libraries so generator regressions are caught at PR time. `flake8` and `ruff` already run on these goldens, but they do not catch the kinds of issues `pylint` flagged in the original investigation (undefined names, broken imports, etc.). ## What - New `packages/gapic-generator/tests/integration/goldens/.pylintrc` scoped to the goldens. Conservative bar to start: `pylint --errors-only` is used in CI, and the `.pylintrc` disables the small set of error-class checks that consistently misfire on auto-generated GAPIC output (`no-name-in-module`, `no-member`, `import-error`, `relative-beyond-top-level`, `cyclic-import`). This catches real bugs without forcing a stylistic cleanup of the existing goldens, which can be tightened later. - New `Pylint goldens (errors only)` step in the existing `goldens` job in `.github/workflows/gapic-generator-tests.yml`. Runs after the existing `format`/`lint`/`unit` nox sessions, so the heavy setup is amortized. Iterates over the same `credentials eventarc logging redis` set. ## Tested - Confirmed the new step is gated by the same `paths` filter as the rest of `gapic-generator-tests.yml`, so it stays silent on PRs that do not touch the generator. - `pylint --errors-only --rcfile=.pylintrc` only reports E/F categories minus the listed disables, which keeps the signal meaningful and stops the generator from silently regressing on the next refactor. If the maintainers want a different starting bar (e.g. include warnings, or run on more golden packages), happy to adjust.
1 parent 69f0134 commit 36ca46b

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

.github/workflows/gapic-generator-tests.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@ jobs:
115115
for pkg in credentials eventarc logging redis; do
116116
nox -f tests/integration/goldens/$pkg/noxfile.py -s format lint unit-${{ needs.python_config.outputs.latest_stable_python }}
117117
done
118+
# Run pylint (errors-only) over the goldens so generator regressions
119+
# like undefined names or import-time breakage that ruff/flake8 do
120+
# not flag are caught at PR time.
121+
# See https://github.com/googleapis/google-cloud-python/issues/16393.
122+
- name: Pylint goldens (errors only)
123+
run: |
124+
pip install --quiet pylint
125+
cd packages/gapic-generator/tests/integration/goldens
126+
for pkg in credentials eventarc logging redis; do
127+
pylint --rcfile=.pylintrc --errors-only --recursive=y "$pkg/google"
128+
done
118129
119130
goldens-prerelease:
120131
needs: python_config
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Pylint configuration for golden client libraries.
2+
#
3+
# These goldens are auto-generated GAPIC client output (see
4+
# packages/gapic-generator/gapic/templates/). They are checked in as test
5+
# fixtures so that regressions in the generator are caught at PR time.
6+
#
7+
# Pylint is invoked with `--errors-only` from CI so only error/fatal
8+
# categories run. This file disables the small set of error-class checks
9+
# that consistently misfire on auto-generated GAPIC output (proto
10+
# descriptor lookups, dynamic attribute attachment, optional transports).
11+
# Tighten as the generator's output is cleaned up.
12+
#
13+
# See https://github.com/googleapis/google-cloud-python/issues/16393.
14+
15+
[MAIN]
16+
ignore-patterns=.*_pb2\.py,.*_pb2_grpc\.py
17+
extension-pkg-allow-list=grpc,google.protobuf
18+
19+
[MESSAGES CONTROL]
20+
disable=
21+
no-name-in-module,
22+
no-member,
23+
import-error,
24+
relative-beyond-top-level,
25+
cyclic-import,
26+
# Generator emits __hash__ stubs as `return NotImplementedError(...)`
27+
# rather than `raise`; the goldens deliberately mirror that template
28+
# output so the check is silenced here until the generator is fixed.
29+
invalid-hash-returned
30+
31+
[REPORTS]
32+
score=no

0 commit comments

Comments
 (0)