Skip to content

Commit e80fef9

Browse files
authored
fix(node): exclude test fixtures from post-processing (#2174)
Excludes `core/generator/gapic-generator-typescript/test-fixtures` from directory traversal in `node_mono_repo.py` to prevent the post-processor from re-adding them to `release-please-config.json`. See googleapis/google-cloud-node#8171 for an example of the issue.
1 parent ba9afbd commit e80fef9

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

synthtool/languages/node_mono_repo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ def walk_through_owlbot_dirs(dir: Path, search_for_changed_files: bool):
482482
packages_to_exclude = [
483483
r"packages/gapic-node-processing/templates/bootstrap-templates",
484484
r"node_modules",
485+
r"core/generator/gapic-generator-typescript/test-fixtures",
485486
]
486487
if search_for_changed_files:
487488
try:

tests/test_node_mono_repo.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,49 @@ def test_walk_through_owlbot_dirs_handwritten(mock_subproc_popen):
509509
assert any(re.search("handwritten/dlp", d) for d in owlbot_dirs)
510510

511511

512+
@patch("subprocess.run")
513+
def test_walk_through_owlbot_dirs_excluded(mock_subproc_popen):
514+
process_mock = Mock()
515+
attrs = {"communicate.return_value": ("output", "error")}
516+
process_mock.configure_mock(**attrs)
517+
mock_subproc_popen.return_value = process_mock
518+
519+
with util.copied_fixtures_dir(
520+
FIXTURES / "nodejs_mono_repo_with_staging"
521+
) as workdir:
522+
excluded_dir = (
523+
workdir
524+
/ "core"
525+
/ "generator"
526+
/ "gapic-generator-typescript"
527+
/ "test-fixtures"
528+
/ "speech"
529+
)
530+
excluded_dir.mkdir(parents=True)
531+
(excluded_dir / ".OwlBot.yaml").touch()
532+
533+
regular_dir = workdir / "core" / "generator" / "gapic-generator-typescript"
534+
regular_dir.mkdir(parents=True, exist_ok=True)
535+
(regular_dir / ".OwlBot.yaml").touch()
536+
537+
owlbot_dirs = node_mono_repo.walk_through_owlbot_dirs(
538+
workdir, search_for_changed_files=False
539+
)
540+
541+
assert not mock_subproc_popen.called
542+
assert any(
543+
re.search("core/generator/gapic-generator-typescript$", d)
544+
for d in owlbot_dirs
545+
)
546+
assert not any(
547+
re.search(
548+
"core/generator/gapic-generator-typescript/test-fixtures/speech",
549+
d,
550+
)
551+
for d in owlbot_dirs
552+
)
553+
554+
512555
@patch("subprocess.run")
513556
def test_walk_through_owlbot_dirs_no_staging(mock_subproc_popen):
514557
process_mock = Mock()

0 commit comments

Comments
 (0)