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

Add backup logic for Go installation in Amazon Linux buildspec #4253

Merged
merged 16 commits into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions buildspecs/pr-build-amzn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ phases:
# Ref: https://docs.aws.amazon.com/linux/al2023/ug/managing-repos-os-updates.html
# xmllint is required to find the latest distribution release from releasemd.xml in us-west-2
- AL23_VERSION="$(curl -s https://al2023-repos-us-west-2-de612dc2.s3.dualstack.us-west-2.amazonaws.com/core/releasemd.xml | xmllint --xpath "string(//root/releases/release[last()]/@version)" -)"
- AGENT_VERSION=$(cat VERSION)
- AGENT_VERSION="$(cat VERSION)"

# Need to install GOLANG explicitly as required versions do not come preinstalled
# Remove existing go installation (goenv utility)
Expand All @@ -53,20 +53,29 @@ phases:

# Define the Go version to install
- GOVERSION="$(cat GO_VERSION)"

# Install Go and define variables based on Amazon Linux version (2 or 2023)
# Amazon Linux 2023 uses package manager DNF, while older versions use YUM
# Set the appropriate AL23 version echo string to include in build log
# First, try to install the specified Go version, if unable, install latest Go version available
- |
if [[ "$amzn_version" = "amzn2023" ]]; then
sudo dnf --releasever="$AL23_VERSION" update -y
sudo yum install -y golang-$GOVERSION
amzn_version="amzn2023"
al23_version_echo="Amazon Linux 2023 Version: $AL23_VERSION"
echo "Amazon Linux 2023 Version: $AL23_VERSION" 2>&1 | tee -a $BUILD_LOG
if sudo dnf install -y golang-$GOVERSION; then
Ephylouise marked this conversation as resolved.
Show resolved Hide resolved
echo "Installed Go version: $GOVERSION" 2>&1 | tee -a $BUILD_LOG
else
echo "Specified Go version $GOVERSION not found, installing latest available version" 2>&1 | tee -a $BUILD_LOG
sudo dnf install -y golang
fi
Ephylouise marked this conversation as resolved.
Show resolved Hide resolved

elif [[ "$amzn_version" = "amzn2" ]]; then
sudo yum install -y golang-$GOVERSION
amzn_version="amzn2"
al23_version_echo=""
if sudo yum install -y golang-$GOVERSION; then
echo "Installed Go version $GOVERSION" 2>&1 | tee -a $BUILD_LOG
else
echo "Specified Go version $GOVERSION not found, installing latest available version" 2>&1 | tee -a $BUILD_LOG
sudo yum install -y golang
fi

else
echo "Unsupported Amazon Linux version"
exit 1
Expand All @@ -76,8 +85,6 @@ phases:
- BUILD_LOG="build_${amzn_version}_${architecture}.log"

# Print all environment variables to the log file
# Amazon Linux 2023 verion will print only to the AL23 log
- echo "$al23_version_echo" | tee -a $BUILD_LOG
- which go | tee -a $BUILD_LOG
- go version | tee -a $BUILD_LOG

Expand Down
Loading