-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hermetic build scripts to use a single output/generation folder (…
…#1987) * move generation tools and generated source to single folder * script fixes * capture exit code from failing script * remove accidental file * wip: fix showcase test * post rebase fixes * adjust showcase failure handling * update readme * fix output path in IT * download googleapis in output folder * Update library_generation/README.md Co-authored-by: Joe Wang <[email protected]> * remove unrelated os detection function * use pushd instead of cd in gen script output cleanup * correct destination_path documentation * Update library_generation/README.md Co-authored-by: Joe Wang <[email protected]> * fix pushd in generate_library.sh * ignore output folder * Update library_generation/README.md Co-authored-by: Joe Wang <[email protected]> * Update library_generation/README.md Co-authored-by: Joe Wang <[email protected]> * spit output to stdout * centralize output folder computation * label popped folders * prevent wrong version unit test from exiting the test suite * resolve output dir using pwd --------- Co-authored-by: Joe Wang <[email protected]>
- Loading branch information
1 parent
9c0316b
commit f5efb0e
Showing
9 changed files
with
86 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,10 @@ set -xeo pipefail | |
|
||
# defaults | ||
googleapis_gen_url="[email protected]:googleapis/googleapis-gen.git" | ||
script_dir=$(dirname "$(readlink -f "$0")") | ||
source "${script_dir}/../utilities.sh" | ||
library_generation_dir="${script_dir}"/.. | ||
output_folder="$(get_output_folder)" | ||
|
||
while [[ $# -gt 0 ]]; do | ||
key="$1" | ||
|
@@ -38,14 +42,13 @@ esac | |
shift # past argument or value | ||
done | ||
|
||
script_dir=$(dirname "$(readlink -f "$0")") | ||
source "${script_dir}/../utilities.sh" | ||
library_generation_dir="${script_dir}"/.. | ||
cd "${library_generation_dir}" | ||
mkdir -p "${output_folder}" | ||
pushd "${output_folder}" | ||
# checkout the master branch of googleapis/google (proto files) and WORKSPACE | ||
echo "Checking out googlapis repository..." | ||
sparse_clone https://github.com/googleapis/googleapis.git "${proto_path} WORKSPACE google/api google/rpc google/cloud/common_resources.proto google/iam/v1 google/type google/longrunning" | ||
cd googleapis | ||
pushd googleapis | ||
cp -r google "${output_folder}" | ||
# parse version of gapic-generator-java, protobuf and grpc from WORKSPACE | ||
gapic_generator_version=$(get_version_from_WORKSPACE "_gapic_generator_java_version" WORKSPACE "=") | ||
echo "The version of gapic-generator-java is ${gapic_generator_version}." | ||
|
@@ -60,6 +63,8 @@ rest_numeric_enums=$(get_rest_numeric_enums_from_BUILD "${proto_build_file_path} | |
include_samples=$(get_include_samples_from_BUILD "${proto_build_file_path}") | ||
echo "GAPIC options are transport=${transport}, rest_numeric_enums=${rest_numeric_enums}, include_samples=${include_samples}." | ||
# generate GAPIC client library | ||
popd | ||
popd | ||
echo "Generating library from ${proto_path}, to ${destination_path}..." | ||
"${library_generation_dir}"/generate_library.sh \ | ||
-p "${proto_path}" \ | ||
|
@@ -74,19 +79,19 @@ echo "Generating library from ${proto_path}, to ${destination_path}..." | |
echo "Generate library finished." | ||
echo "Checking out googleapis-gen repository..." | ||
|
||
pushd "${output_folder}" | ||
sparse_clone "${googleapis_gen_url}" "${proto_path}" | ||
|
||
echo "Compare generation result..." | ||
RESULT=0 | ||
diff -r "googleapis-gen/${proto_path}/${destination_path}" "${destination_path}" -x "*gradle*" || RESULT=$? | ||
diff -r "googleapis-gen/${proto_path}/${destination_path}" "${output_folder}/${destination_path}" -x "*gradle*" || RESULT=$? | ||
|
||
if [ ${RESULT} == 0 ] ; then | ||
echo "SUCCESS: Comparison finished, no difference is found." | ||
else | ||
echo "FAILURE: Differences found." | ||
fi | ||
|
||
cd .. | ||
rm -rf googleapis | ||
popd # output_folder | ||
|
||
exit ${RESULT} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters