Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 6e461cd

Browse files
build: owlbot.py changes for merging split gapic clients correctly (#1739)
* build: speculative owlbot.py changes for merging selective clients * test: perhaps trigger owlbot * test: update owlbot staging * build: fix admin excludes and class copying * fix: remove previously added admin clients * build: add new paths for admin clients * fix: shim the old admin locations for now * build: bug fixes, json munging * build: update to owlbot.py processing to fix import errors; typo in test/index.ts * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * build: remove extraneous admin samples from v2 * build: remove commented out debug code, fix comment --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent fccdbbb commit 6e461cd

104 files changed

Lines changed: 52741 additions & 37269 deletions

File tree

Some content is hidden

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

owlbot.py

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,96 @@
1818
import os
1919
from pathlib import Path
2020
from synthtool import _tracked_paths
21+
from typing import AnyStr
2122
import shutil
2223

2324
logging.basicConfig(level=logging.DEBUG)
2425

2526
staging = Path("owl-bot-staging")
2627

2728
if staging.is_dir():
28-
logging.info(f"Copying files from staging directory ${staging}.")
29+
versions = ['v2']
30+
versions_admin = [f"admin/{p}" for p in versions]
2931

32+
logging.info(f"Copying files from staging directory {staging}.")
33+
34+
src_paths = {}
35+
src_files = {}
36+
for version in versions + versions_admin:
37+
src_paths[version] = staging / version
38+
src_files[version] = list([fn for fn in src_paths[version].glob('**/*.*')])
3039

3140
# Copy bigtable library.
32-
# src/index.ts src/v2/index.ts has added AdminClients manually, we don't wanna override it.
41+
# src/index.ts src/admin/v2/index.ts has added AdminClients manually, we don't wanna override it.
3342
# src/*.ts is a added layer for the client libraries, they need extra setting in tsconfig.json & tslint.json
3443
# Tracking issues: 1. https://github.com/googleapis/nodejs-bigtable/issues/636
3544
# 2. https://github.com/googleapis/nodejs-bigtable/issues/635
36-
for version in ['v2']:
37-
library = staging / version
45+
for version in versions:
46+
library = src_paths[version]
3847
_tracked_paths.add(library)
39-
s.copy([library], excludes=['package.json', 'README.md', 'src/index.ts', 'src/v2/index.ts', 'tsconfig.json', 'tslint.json', '.github/sync-repo-settings.yaml'])
48+
admin_files = filter(
49+
lambda f: str(f).find('_admin') >= 0,
50+
src_files[version]
51+
)
52+
excludes = [
53+
'package.json',
54+
'README.md',
55+
'src/index.ts',
56+
'src/v2/index.ts',
57+
'tsconfig.json',
58+
'tslint.json',
59+
'.github/sync-repo-settings.yaml',
60+
'.OwlBot.yaml',
61+
] + list(admin_files)
62+
logging.info(f"excluding files for non-admin: {excludes}")
63+
s.copy([library], excludes = excludes)
4064

41-
# Copy the admin library.
42-
# Not override system-test for admin/v2, just keep the v2 version.
43-
for version in ['v2']:
44-
library = staging / 'admin' / version
65+
# Copy the admin library pieces and knit them in.
66+
# Don't override system-test for admin/v2, just keep the v2 version.
67+
for version in versions:
68+
admin_version = f"admin/{version}"
69+
library = src_paths[admin_version]
70+
inProtoPath = f"protos/google/bigtable/{admin_version}"
71+
protos = library / inProtoPath
72+
classes = library / 'src' / version
73+
samples = library / 'samples' / 'generated'
74+
tests = library / 'test'
4575
_tracked_paths.add(library)
46-
s.copy([library], excludes=['package.json', 'README.md', 'src/index.ts', 'src/v2/index.ts', 'tsconfig.json', 'tslint.json', 'system-test/fixtures/sample/src/index.ts', 'system-test/fixtures/sample/src/index.js', '.github/sync-repo-settings.yaml'])
76+
77+
# We also have to munge the proto paths in the *_proto_list.json due to making it a level deeper.
78+
# That also applies to the classes themselves.
79+
classesStr = str(classes)
80+
jsons = [fn
81+
for fn
82+
in src_files[admin_version]
83+
if str(fn)[:len(classesStr)] == classesStr]
84+
for jfn in jsons:
85+
logging.info(f"munging json file: {str(jfn)}")
86+
contents = jfn.read_text()
87+
contents = contents.replace("'../..", "'../../..")
88+
contents = contents.replace('"../..', '"../../..')
89+
jfn.write_text(contents)
90+
91+
# Also to the tests that import stuff from src. ../ -> ../../../
92+
testsStr = str(tests)
93+
tfns = [fn
94+
for fn
95+
in src_files[admin_version]
96+
if str(fn)[:len(testsStr)] == testsStr]
97+
for tfn in tfns:
98+
logging.info(f"munging test file: {str(tfn)}")
99+
contents = tfn.read_text()
100+
contents = contents.replace("'../", "'../../../")
101+
tfn.write_text(contents)
102+
103+
os.system(f"mkdir -p {inProtoPath}")
104+
s.copy([protos / '*'], destination=inProtoPath)
105+
os.system(f"mkdir -p src/{admin_version}")
106+
s.copy([classes / '*'], destination=f"src/{admin_version}")
107+
os.system(f"mkdir -p samples/generated/{admin_version}")
108+
s.copy([samples / 'v2' / '*admin*'], destination=f"samples/generated/{admin_version}")
109+
os.system(f"mkdir -p test/{admin_version}")
110+
s.copy([tests / '*admin*.ts'], destination=f"test/{admin_version}")
47111

48112
# Replace the client name for generated system-test.
49113
system_test_files=['system-test/fixtures/sample/src/index.ts','system-test/fixtures/sample/src/index.js']

0 commit comments

Comments
 (0)