-
Notifications
You must be signed in to change notification settings - Fork 55
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
Conversation
Mismatch in |
library_generation/utilities.sh
Outdated
detect_OS() { | ||
if [[ "${OSTYPE}" == "linux-gnu"* ]] || [[ "${OSTYPE}" == "freebsd"* ]]; then | ||
os_architecture="linux-x86_64" | ||
elif [[ "${OSTYPE}" == "darwin"* ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about osx-aarm_64
?
I think you can use uname -sm
to detect OS type and CPU architecture, but I'm not sure whether windows can run this command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I defaulted to win32
regardless of architecture and changed it to uname -m
to detect the architecture only, while keeping reliance on ${OSTYPE}
library_generation/utilities.sh
Outdated
@@ -273,3 +273,24 @@ get_version_from_versions_txt() { | |||
version=$(grep "$key:" "${versions}" | cut -d: -f3) # 3rd field is snapshot | |||
echo "${version}" | |||
} | |||
|
|||
detect_os_architecture() { | |||
case "${OSTYPE}" in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does OSTYPE
come from?
library_generation/utilities.sh
Outdated
os_architecture="linux-$(uname -m)" | ||
;; | ||
"darwin"*) | ||
os_architecture="osx-$(uname -m)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I run uname -m
on my machine, the output is arm64
.
However, the right os architecture should be osx-aarch_64.
You can reference the os architecture here
I also implemented a os architecture detection function:
get_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}"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, thanks for the function :) I couldn't confirm for the aarch64
case since I don't have such machine, but I switched the detection function to this one
uses function by Joe Wang
[gapic-generator-java-root] Kudos, SonarCloud Quality Gate passed! |
[java_showcase_integration_tests] Kudos, SonarCloud Quality Gate passed! |
[java_showcase_unit_tests] Kudos, SonarCloud Quality Gate passed! |
Adds OS detection to
generate_library.sh
Manual input from workflow matrix is removed in favor of automatic detection