Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hermetic build OS detection #1988

Merged
merged 7 commits into from Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/verify_library_generation.yaml
Expand Up @@ -28,8 +28,7 @@ jobs:
library_generation/test/generate_library_integration_test.sh \
-p google/bigtable/v2 \
-d google-cloud-bigtable-v2-java \
--googleapis_gen_url https://cloud-java-bot:${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}@github.com/googleapis/googleapis-gen.git \
--os_type ${{ matrix.os }}
--googleapis_gen_url https://cloud-java-bot:${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}@github.com/googleapis/googleapis-gen.git
unit_tests:
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion library_generation/generate_library.sh
Expand Up @@ -78,7 +78,7 @@ if [ -z "${include_samples}" ]; then
fi

if [ -z "${os_architecture}" ]; then
os_architecture="linux-x86_64"
os_architecture=$(detect_os_architecture)
fi

mkdir -p "${destination_path}"
Expand Down
12 changes: 1 addition & 11 deletions library_generation/test/generate_library_integration_test.sh
Expand Up @@ -30,10 +30,6 @@ case $key in
googleapis_gen_url="$2"
shift
;;
--os_type)
os_type="$2"
shift
;;
*)
echo "Invalid option: [$1]"
exit 1
Expand Down Expand Up @@ -78,11 +74,6 @@ include_samples=$(get_config_from_BUILD \
"false"
)
echo "GAPIC options are transport=${transport}, rest_numeric_enums=${rest_numeric_enums}, include_samples=${include_samples}."
os_architecture="linux-x86_64"
if [[ "$os_type" == *"macos"* ]]; then
os_architecture="osx-x86_64"
fi
echo "OS Architecture is ${os_architecture}."
# generate GAPIC client library
echo "Generating library from ${proto_path}, to ${destination_path}..."
"${library_generation_dir}"/generate_library.sh \
Expand All @@ -93,8 +84,7 @@ echo "Generating library from ${proto_path}, to ${destination_path}..."
--grpc_version "${grpc_version}" \
--transport "${transport}" \
--rest_numeric_enums "${rest_numeric_enums}" \
--include_samples "${include_samples}" \
--os_architecture "${os_architecture}"
--include_samples "${include_samples}"

echo "Generate library finished."
echo "Checking out googleapis-gen repository..."
Expand Down
18 changes: 18 additions & 0 deletions library_generation/utilities.sh
Expand Up @@ -273,3 +273,21 @@ get_version_from_versions_txt() {
version=$(grep "$key:" "${versions}" | cut -d: -f3) # 3rd field is snapshot
echo "${version}"
}

detect_os_architecture() {
local os_type
local os_architecture
os_type=$(uname -sm)
case "${os_type}" in
*"Linux x86_64"*)
os_architecture="linux-x86_64"
;;
*"Darwin x86_64"*)
os_architecture="osx-x86_64"
;;
*)
os_architecture="osx-aarch_64"
;;
esac
echo "${os_architecture}"
}