Skip to content

Commit d043b5a

Browse files
authored
fix: fail quickly if a subprocess returns 1 (#2165)
* chore: fail quickly if a subprocess returns 1 * Add build-dev.sh script for development builds * Update copyright year in build-dev.sh * Improve subprocess call error handling Add check=True to subprocess calls for better error handling. * Update node_mono_repo.py * Replace check_call with run for subprocess
1 parent e1e6350 commit d043b5a

2 files changed

Lines changed: 42 additions & 3 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# File for local development of the Docker image. This is not intended to be used in CI, but can be used to test changes to the Dockerfile and entrypoint script.
17+
set -e
18+
19+
# Get the directory of the script
20+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
21+
# Navigate to the root of the synthtool repo
22+
cd "$DIR/../../.."
23+
24+
echo "Preparing post-processor-changes.txt..."
25+
# Generate post-processor-changes.txt as expected by some Dockerfiles/CI
26+
git log -1 --format="%B%n%nSource-Link: https://github.com/googleapis/synthtool/commit/%H" > post-processor-changes.txt &&
27+
sed -i "s/([^()]*)$//g" post-processor-changes.txt &&
28+
sed -i "s/^\(feat\|fix\)/chore/g" post-processor-changes.txt &&
29+
sed -i "s/\!:/:/g" post-processor-changes.txt
30+
31+
echo "Building owlbot-nodejs-mono-repo..."
32+
docker build -t owlbot-nodejs-mono-repo -f docker/owlbot/nodejs_mono_repo/Dockerfile .
33+
34+
# Cleanup temporary file
35+
rm post-processor-changes.txt
36+
37+
echo ""
38+
echo "Successfully built owlbot-nodejs-mono-repo"
39+
echo "To run it against a local repository, use:"
40+
echo " docker run --rm -v \$(pwd):/workspace -w /workspace owlbot-nodejs-mono-repo [RELATIVE_DIRS]"

synthtool/languages/node_mono_repo.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from synthtool.languages import common
2828
from datetime import date
2929
import logging
30-
from os import system
3130
from synthtool import _tracked_paths
3231
from synthtool import gcp
3332

@@ -641,7 +640,7 @@ def owlbot_entrypoint(
641640
for dir in specified_owlbot_dirs:
642641
owlbot_py_file_path = hasOwlBotPy(dir)
643642
if owlbot_py_file_path:
644-
system(f"python3 {owlbot_py_file_path}")
643+
subprocess.run(["python3", str(owlbot_py_file_path)], check=True)
645644
else:
646645
owlbot_main(
647646
dir,
@@ -657,7 +656,7 @@ def owlbot_entrypoint(
657656
for dir in owlbot_dirs:
658657
owlbot_py_file_path = hasOwlBotPy(dir)
659658
if owlbot_py_file_path:
660-
system(f"python3 {owlbot_py_file_path}")
659+
subprocess.run(["python3", str(owlbot_py_file_path)], check=True)
661660
else:
662661
owlbot_main(
663662
dir,

0 commit comments

Comments
 (0)