Skip to content

Commit 7324804

Browse files
authored
chore: remove compile protos from post processor (#1899)
* chore: remove compile protos from post processor
1 parent d7b3591 commit 7324804

File tree

5 files changed

+2
-97
lines changed

5 files changed

+2
-97
lines changed

docker/owlbot/nodejs_mono_repo/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ RUN find /synthtool -type d -exec chmod a+x {} \;
5151

5252
# Install dependencies used for post processing:
5353
# * gts/typescript are used for linting.
54-
# * google-gax and gapic-tools are used for compiling protos.
55-
RUN cd /synthtool && mkdir node_modules && npm i [email protected] [email protected] \
56-
54+
RUN cd /synthtool && mkdir node_modules && npm i [email protected] \
55+
5756

5857
ENTRYPOINT [ "/bin/bash", "/synthtool/docker/owlbot/nodejs_mono_repo/entrypoint.sh" ]

synthtool/languages/node.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -234,43 +234,16 @@ def fix_hermetic(hide_output=False):
234234
)
235235

236236

237-
def compile_protos(hide_output=False):
238-
"""
239-
Compiles protos into .json, .js, and .d.ts files using
240-
compileProtos script from google-gax.
241-
"""
242-
logger.debug("Compiling protos...")
243-
shell.run(["npx", "compileProtos", "src"], hide_output=hide_output)
244-
245-
246-
# TODO: delete these functions if it turns out we no longer
247-
# need them to be hermetic.
248-
def compile_protos_hermetic(hide_output=False):
249-
"""
250-
Compiles protos into .json, .js, and .d.ts files using
251-
compileProtos script from google-gax. Assumes that compileProtos
252-
is already installed in a well known location on disk (node_modules/.bin).
253-
"""
254-
logger.debug("Compiling protos...")
255-
shell.run(
256-
["node_modules/.bin/compileProtos", "src"],
257-
check=True,
258-
hide_output=hide_output,
259-
)
260-
261-
262237
def postprocess_gapic_library(hide_output=False):
263238
logger.debug("Post-processing GAPIC library...")
264239
install(hide_output=hide_output)
265240
fix(hide_output=hide_output)
266-
compile_protos(hide_output=hide_output)
267241
logger.debug("Post-processing completed")
268242

269243

270244
def postprocess_gapic_library_hermetic(hide_output=False):
271245
logger.debug("Post-processing GAPIC library...")
272246
fix(hide_output=hide_output)
273-
compile_protos(hide_output=hide_output)
274247
logger.debug("Post-processing completed")
275248

276249

synthtool/languages/node_mono_repo.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -335,52 +335,16 @@ def fix_hermetic(relative_dir, hide_output=False):
335335
)
336336

337337

338-
def compile_protos(hide_output=False, is_esm=False):
339-
"""
340-
Compiles protos into .json, .js, and .d.ts files using
341-
compileProtos script from google-gax.
342-
"""
343-
logger.debug("Compiling protos...")
344-
command = (
345-
["npx", "compileProtos", "src"]
346-
if not is_esm
347-
else ["npx", "compileProtos", "esm/src", "--esm"]
348-
)
349-
shell.run(command, hide_output=hide_output)
350-
351-
352-
def compile_protos_hermetic(relative_dir, is_esm=False, hide_output=False):
353-
"""
354-
Compiles protos into .json, .js, and .d.ts files using
355-
compileProtos script from google-gax. Assumes that compileProtos
356-
is already installed in a well known location on disk (node_modules/.bin).
357-
"""
358-
logger.debug("Compiling protos...")
359-
command = (
360-
[f"{_TOOLS_DIRECTORY}/node_modules/.bin/compileProtos", "esm/src", "--esm"]
361-
if not is_esm
362-
else [f"{_TOOLS_DIRECTORY}/node_modules/.bin/compileProtos", "esm/src", "--esm"]
363-
)
364-
shell.run(
365-
command,
366-
cwd=relative_dir,
367-
check=True,
368-
hide_output=hide_output,
369-
)
370-
371-
372338
def postprocess_gapic_library(hide_output=False, is_esm=False):
373339
logger.debug("Post-processing GAPIC library...")
374340
install(hide_output=hide_output)
375341
fix(hide_output=hide_output)
376-
compile_protos(hide_output=hide_output, is_esm=is_esm)
377342
logger.debug("Post-processing completed")
378343

379344

380345
def postprocess_gapic_library_hermetic(relative_dir, hide_output=False, is_esm=False):
381346
logger.debug("Post-processing GAPIC library...")
382347
fix_hermetic(relative_dir, hide_output=hide_output)
383-
compile_protos_hermetic(relative_dir, hide_output=hide_output, is_esm=is_esm)
384348
logger.debug("Post-processing completed")
385349

386350

tests/test_node.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,12 @@ def test_fix(self, shell_run_mock):
169169
calls = shell_run_mock.call_args_list
170170
assert any(["npm run fix" in " ".join(call[0][0]) for call in calls])
171171

172-
@patch("synthtool.shell.run")
173-
def test_compile_protos(self, shell_run_mock):
174-
node.compile_protos()
175-
calls = shell_run_mock.call_args_list
176-
assert any(["npx compileProtos src" in " ".join(call[0][0]) for call in calls])
177-
178172
@patch("synthtool.shell.run")
179173
def test_postprocess_gapic_library(self, shell_run_mock):
180174
node.postprocess_gapic_library()
181175
calls = shell_run_mock.call_args_list
182176
assert any(["npm install" in " ".join(call[0][0]) for call in calls])
183177
assert any(["npm run fix" in " ".join(call[0][0]) for call in calls])
184-
assert any(["npx compileProtos src" in " ".join(call[0][0]) for call in calls])
185178

186179

187180
# postprocess_gapic_library_hermetic() must be mocked because it depends on node modules

tests/test_node_mono_repo.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -354,43 +354,19 @@ def test_fix(self, shell_run_mock):
354354
calls = shell_run_mock.call_args_list
355355
assert any(["npm run fix" in " ".join(call[0][0]) for call in calls])
356356

357-
@patch("synthtool.shell.run")
358-
def test_compile_protos(self, shell_run_mock):
359-
node_mono_repo.compile_protos()
360-
calls = shell_run_mock.call_args_list
361-
assert any(["npx compileProtos src" in " ".join(call[0][0]) for call in calls])
362-
363-
@patch("synthtool.shell.run")
364-
def test_compile_protos_esm(self, shell_run_mock):
365-
node_mono_repo.compile_protos(is_esm=True)
366-
calls = shell_run_mock.call_args_list
367-
assert any(
368-
[
369-
"npx compileProtos esm/src --esm" in " ".join(call[0][0])
370-
for call in calls
371-
]
372-
)
373-
374357
@patch("synthtool.shell.run")
375358
def test_postprocess_gapic_library(self, shell_run_mock):
376359
node_mono_repo.postprocess_gapic_library()
377360
calls = shell_run_mock.call_args_list
378361
assert any(["npm install" in " ".join(call[0][0]) for call in calls])
379362
assert any(["npm run fix" in " ".join(call[0][0]) for call in calls])
380-
assert any(["npx compileProtos src" in " ".join(call[0][0]) for call in calls])
381363

382364
@patch("synthtool.shell.run")
383365
def test_postprocess_gapic_library_esm(self, shell_run_mock):
384366
node_mono_repo.postprocess_gapic_library(is_esm=True)
385367
calls = shell_run_mock.call_args_list
386368
assert any(["npm install" in " ".join(call[0][0]) for call in calls])
387369
assert any(["npm run fix" in " ".join(call[0][0]) for call in calls])
388-
assert any(
389-
[
390-
"npx compileProtos esm/src --esm" in " ".join(call[0][0])
391-
for call in calls
392-
]
393-
)
394370

395371

396372
# postprocess_gapic_library_hermetic() must be mocked because it depends on node modules

0 commit comments

Comments
 (0)