refactor(gapic-generator): harmonize and deduplicate showcase nox test sessions
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 55/100
- issue の種類
- リファクタリング
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
Read packages/gapic-generator/noxfile.py, focusing on showcase_library, run_showcase_unit_tests, and the showcase sessions around lines 397–629. Run the existing Showcase nox sessions before changing them, then verify that unified system and unit runners preserve each listed variant, options, paths, and pytest behavior.
索引モデルが issue の本文から書いたものです。
説明
Problem Summary
In packages/gapic-generator/noxfile.py, the test suite for the Showcase client has grown into over 10 distinct showcase_* sessions across system tests and unit tests.
While proto compilation and client generation were previously consolidated into the with showcase_library(...) context manager, the test execution logic inside the context blocks has suffered from copy-paste sprawl:
-
System Tests Duplication:
The sessionsshowcase,showcase_w_rest_async,showcase_mtls, andshowcase_pqc(lines 397–535) each duplicate a ~25-line block of setup, dependency installation, path resolution, andpy.testexecution. There is no sharedrun_showcase_system_tests()helper. Adding a flag, environment override (such as local core installation), or pytest option requires touching 4 separate sessions. -
Unit Tests Session Explosion:
There are 6 distinct unit test sessions (showcase_unit,showcase_unit_w_rest_async,showcase_unit_alternative_templates,showcase_unit_add_iam_methods,showcase_unit_mixins,showcase_unit_alternative_templates_mixinsacross lines 566–629) that simply pass different template options or flags toshowcase_libraryand then callrun_showcase_unit_tests().
This proliferation leads to maintenance drift, inconsistencies in flags, and makes targeted testing harder.
Proposed Refactor
Consolidate the duplicated sessions into unified, maintainable runners using @nox.parametrize or shared helper functions.
1. System Tests Refactor (Consolidate 4+ sessions into 1)
Instead of 4 copy-pasted sessions:
# Before: 4 duplicate sessions (showcase, showcase_w_rest_async, showcase_mtls, showcase_pqc)
@nox.session(python=ALL_PYTHON)
def showcase(session):
with showcase_library(session):
session.install("pytest", "pytest-asyncio<1.0.0")
...
session.run("py.test", ...)
@nox.session(python=ALL_PYTHON)
def showcase_w_rest_async(session):
with showcase_library(session, rest_async_io_enabled=True):
session.install("pytest", "pytest-asyncio<1.0.0")
...
session.run("py.test", ...)
Consolidate into a single parameterized session with a shared runner:
# After: Single parameterized system test session
SYSTEM_VARIANTS = {
"grpc": {"rest_async": False, "extra_args": []},
"rest_async": {"rest_async": True, "extra_args": []},
"mtls": {"rest_async": False, "extra_args": ["--mtls"]},
"pqc": {"rest_async": False, "extra_args": ["--tls"], "test_path": "tests/system/test_pqc.py"},
}
@nox.session(python=ALL_PYTHON)
@nox.parametrize("variant", list(SYSTEM_VARIANTS.keys()))
def showcase_system(session, variant):
"""Run all Showcase system tests through a unified runner."""
config = SYSTEM_VARIANTS[variant]
with showcase_library(session, rest_async_io_enabled=config["rest_async"]):
session.install("pytest", "pytest-asyncio<1.0.0")
if variant == "pqc":
session.install("--upgrade", "grpcio>=1.83.0", "grpcio-status>=1.83.0")
test_path = config.get("test_path", "tests/system")
session.run("py.test", "--quiet", *config["extra_args"], *(session.posargs or [test_path]))
2. Unit Tests Refactor (Consolidate 6 sessions into 1)
Instead of 6 distinct sessions calling run_showcase_unit_tests(), parametrize the template and option configurations:
# After: Single parameterized unit test session
UNIT_CONFIGS = {
"default": {"templates": "DEFAULT", "other_opts": ()},
"rest_async": {"templates": "DEFAULT", "rest_async_io_enabled": True},
"ads_old_naming": {"templates": ADS_TEMPLATES, "other_opts": ("old-naming",)},
"add_iam_methods": {"other_opts": ("add-iam-methods",), "fail_under": 100},
"mixins": {"include_service_yaml": True},
"ads_mixins": {"templates": ADS_TEMPLATES, "other_opts": ("old-naming",), "include_service_yaml": True},
}
@nox.session(python=ALL_PYTHON)
@nox.parametrize("config_name", list(UNIT_CONFIGS.keys()))
def showcase_unit(session, config_name):
"""Run all Showcase unit tests across template configurations."""
cfg = UNIT_CONFIGS[config_name]
with showcase_library(
session,
templates=cfg.get("templates", "DEFAULT"),
other_opts=cfg.get("other_opts", ()),
rest_async_io_enabled=cfg.get("rest_async_io_enabled", False),
include_service_yaml=cfg.get("include_service_yaml", False),
) as lib:
session.chdir(lib)
run_showcase_unit_tests(session, fail_under=cfg.get("fail_under", 100))
Benefits
- Zero Drift: All test invocation logic, constraint handling, and pytest argument handling exist in single shared locations.
- Simplified CI Workflows: Matrix jobs in GitHub Actions can cleanly target
showcase_systemorshowcase_unitwith-k <variant>. - Easier Extensibility: Adding canaries, local dependency overrides, or new transport profiles requires modifying a config dictionary rather than copy-pasting an entire session.
- 主要言語
- Python
- スター
- 5.4k
- フォーク
- 1.8k
- 平均マージ
- 2日 7時間
- マージ済み PR(30日)
- 173
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/google-cloud-python のほかの issue
-
firestore: field path with a quoted name ending in a backslash is misparsed対応中かも @sebxt が 25 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
googleapis/google-cloud-python#18771 ·
メンテナーはふだん 1 日以内に返信
-
api: spanner type: feature request
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
googleapis/google-cloud-python#18584 ·
メンテナーはふだん 1 日以内に返信
-
auth: `impersonated_credentials` loses `subject` on copy, so `with_scopes()` and `with_quota_project()` turn off domain wide delegation対応中かも @Om-singhaI が 55 日前に担当しました。 オープンauth priority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
googleapis/google-cloud-python#18428 ·
メンテナーはふだん 1 日以内に返信
-
A client called `run_in_transaction` be stuck if Spanner is down対応中かも @founderinaction が 7 日前に担当しました。 オープンpriority: p2 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
googleapis/google-cloud-python#18375 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
ci: enable --strict flag in presubmit twine_check再び着手できるかも @ohmayr が 44 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
googleapis/google-cloud-python#18339 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
googleapis/google-cloud-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
cpp-best-practices/project_validator#267 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Project-N-E-K-O/N.E.K.O#3725 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] Sending a Telegram message chain twice duplicates mentions対応中かも @123XieC が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
AstrBotDevs/AstrBot#11125 ·
メンテナーはふだん 1 日以内に返信
-
backend bug priority: high
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nooriegarg/ContribIQ#73 ·
メンテナーはふだん 1 日以内に返信
-
bug p3 security
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信