File tree Expand file tree Collapse file tree 5 files changed +47
-6
lines changed
sdk-platform-java/hermetic_build/library_generation Expand file tree Collapse file tree 5 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -73,9 +73,7 @@ if [[ "${is_monorepo}" == "true" ]]; then
7373 # - "/google-.*/src"
7474
7575 library_name=$( basename " ${postprocessing_target} " )
76- cat " ${postprocessing_target} /${owlbot_yaml_file_name} " \
77- | sed " s/- \" \/${library_name} / - \" /" \
78- > " ${postprocessing_target} /.OwlBot.hermetic.yaml"
76+ normalize_owlbot_yaml " ${postprocessing_target} /${owlbot_yaml_file_name} " " ${postprocessing_target} /.OwlBot.hermetic.yaml" " ${library_name} "
7977 owlbot_yaml_relative_path=" .OwlBot.hermetic.yaml"
8078else
8179 owlbot_yaml_relative_path=" .github/${owlbot_yaml_file_name} "
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ deep-remove-regex:
2121
2222deep-preserve-regex:
2323- "/{{ module_name }}/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java"
24- - "/.*google-.*/src/main/java/com/google/[^/]+/.*/v .*/stub/Version.java"
24+ - "/.*google-.*/src/main/java/.*/stub/Version.java"
2525
2626deep-copy-regex:
2727- source: "/{{ proto_path }}/(v.*)/.*-java/proto-google-.*/src"
Original file line number Diff line number Diff line change @@ -213,6 +213,35 @@ get_proto_path_from_preprocessed_sources_multiple_proto_dirs_fails() {
213213 assertEquals 1 ${res}
214214}
215215
216+ normalize_owlbot_yaml_test () {
217+ local temp_dir=$( mktemp -d)
218+ local input_file=" ${temp_dir} /input.yaml"
219+ local output_file=" ${temp_dir} /output.yaml"
220+
221+ cat << EOF > "${input_file} "
222+ deep-remove-regex:
223+ - "/java-accesscontextmanager/proto-google-.*/src"
224+ - "/java-accesscontextmanager/samples/snippets/generated"
225+ - "/.*google-.*/src/main/java/.*/stub/Version.java"
226+ EOF
227+
228+ normalize_owlbot_yaml " ${input_file} " " ${output_file} " " java-accesscontextmanager"
229+
230+ # Verify content
231+ local expected_content
232+ expected_content=$( cat << EOF
233+ deep-remove-regex:
234+ - "/proto-google-.*/src"
235+ - "/samples/snippets/generated"
236+ - "/.*google-.*/src/main/java/.*/stub/Version.java"
237+ EOF
238+ )
239+ local actual_content=$( cat " ${output_file} " )
240+ assertEquals " ${expected_content} " " ${actual_content} "
241+
242+ rm -rf " ${temp_dir} "
243+ }
244+
216245# Execute tests.
217246# One line per test.
218247test_list=(
@@ -237,6 +266,7 @@ test_list=(
237266 get_proto_path_from_preprocessed_sources_valid_library_succeeds
238267 get_proto_path_from_preprocessed_sources_empty_library_fails
239268 get_proto_path_from_preprocessed_sources_multiple_proto_dirs_fails
269+ normalize_owlbot_yaml_test
240270)
241271
242272pushd " ${script_dir} "
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ deep-remove-regex:
2121
2222deep-preserve-regex :
2323- " /java-bare-metal-solution/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java"
24- - " /.*google-.*/src/main/java/com/google/[^/]+/.*/v .*/stub/Version.java"
24+ - " /.*google-.*/src/main/java/.*/stub/Version.java"
2525
2626deep-copy-regex :
2727- source : " /google/cloud/baremetalsolution/(v.*)/.*-java/proto-google-.*/src"
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ download_protoc() {
108108 " protoc-${protoc_version} .zip" \
109109 " GitHub"
110110 unzip -o -q " protoc-${protoc_version} .zip"
111- rm " protoc-${protoc_version} .zip" " readme.txt"
111+ rm -f " protoc-${protoc_version} .zip" " readme.txt"
112112}
113113
114114download_grpc_plugin () {
@@ -333,3 +333,16 @@ error_if_not_exists() {
333333 exit 1
334334 fi
335335}
336+
337+ normalize_owlbot_yaml () {
338+ local input_file=" $1 "
339+ local output_file=" $2 "
340+ local library_name=" $3 "
341+
342+ # Step 1: Remove library name prefix and normalize indentation for matching lines.
343+ # Step 2: Normalize indentation for lines that didn't have the prefix.
344+ # Using | as sed delimiter to avoid escaping forward slashes.
345+ sed -e " s|^\s*- \" /${library_name} |- \" |" \
346+ -e " s|^\s*- \" |- \" |" \
347+ " ${input_file} " > " ${output_file} "
348+ }
You can’t perform that action at this time.
0 commit comments