Skip to content

Commit 86d741c

Browse files
committed
fix(node): exclude test fixtures from post-processing
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 86d741c

2 files changed

Lines changed: 28 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: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,33 @@ 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 = workdir / "core" / "generator" / "gapic-generator-typescript" / "test-fixtures" / "speech"
523+
excluded_dir.mkdir(parents=True)
524+
(excluded_dir / ".OwlBot.yaml").touch()
525+
526+
regular_dir = workdir / "core" / "generator" / "gapic-generator-typescript"
527+
regular_dir.mkdir(parents=True)
528+
(regular_dir / ".OwlBot.yaml").touch()
529+
530+
owlbot_dirs = node_mono_repo.walk_through_owlbot_dirs(
531+
workdir, search_for_changed_files=False
532+
)
533+
534+
assert not mock_subproc_popen.called
535+
assert any(re.search("core/generator/gapic-generator-typescript$", d) for d in owlbot_dirs)
536+
assert not any(re.search("core/generator/gapic-generator-typescript/test-fixtures/speech", d) for d in owlbot_dirs)
537+
538+
512539
@patch("subprocess.run")
513540
def test_walk_through_owlbot_dirs_no_staging(mock_subproc_popen):
514541
process_mock = Mock()

0 commit comments

Comments
 (0)