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

ci: use gvm instead of gimme #1537

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 0 additions & 4 deletions .github/workflows/microbenchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ on:
permissions:
contents: read

env:
GO_VERSION: stable

jobs:
microbenchmark:
runs-on: ubuntu-latest
Expand All @@ -38,7 +35,6 @@ jobs:
script=scripts/ci/bench.sh
repo=apm-agent-go
sha=${{ github.sha }}
GO_VERSION=${{ env.GO_VERSION }}

- if: ${{ failure() }}
uses: elastic/apm-pipeline-library/.github/actions/slack-message@current
Expand Down
4 changes: 4 additions & 0 deletions scripts/ci/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ if [ "$CI" == "true" ] ; then
trap clean_up EXIT
fi

## Fetch the latest stable goversion
export GO_VERSION=$(curl 'https://go.dev/VERSION?m=text' | grep 'go' | sed 's#go##g')

## Bench specific
set -u
source ./scripts/ci/setenv.sh
Expand All @@ -37,5 +40,6 @@ make test | tee ${OUT_FILE}
if [ "$CI" == "true" ] ; then
set +x
set +u
echo "Sending data with gobench"
go run -modfile=scripts/ci/ci.go.mod github.com/elastic/gobench -index "benchmark-go" -es "${APM_AGENT_GO_CLOUD_SECRET}" < ${OUT_FILE}
fi
43 changes: 40 additions & 3 deletions scripts/ci/setenv.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
#!/usr/bin/env bash
set -euxo pipefail

# Install Go using the same travis approach
echo "Installing ${GO_VERSION} with gimme."
eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=${GO_VERSION} bash)"
# Install Golang using gvm
echo "Installing ${GO_VERSION} with gvm."
MSG="environment variable missing"
GO_VERSION=${GO_VERSION:?$MSG}
HOME=${HOME:?$MSG}
OS=$(uname -s| tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m| tr '[:upper:]' '[:lower:]')
GVM_CMD="${HOME}/bin/gvm"

if command -v go ; then
amannocci marked this conversation as resolved.
Show resolved Hide resolved
set +e
echo "Found Go. Checking version.."
FOUND_GO_VERSION=$(go version|awk '{print $3}'|sed s/go//)
if [ "$FOUND_GO_VERSION" == "$GO_VERSION" ]
then
echo "Versions match. No need to install Go. Exiting."
exit 0
fi
set -e
fi

if [ "${ARCH}" == "aarch64" ] ; then
GVM_ARCH_SUFFIX=arm64
elif [ "${ARCH}" == "x86_64" ] ; then
GVM_ARCH_SUFFIX=amd64
elif [ "${ARCH}" == "i686" ] ; then
GVM_ARCH_SUFFIX=386
elif [ "${ARCH}" == "arm64" ] ; then
GVM_ARCH_SUFFIX=arm64
else
GVM_ARCH_SUFFIX=arm
fi

echo "UNMET DEP: Installing Go"
mkdir -p "${HOME}/bin"

curl -sSLo "${GVM_CMD}" "https://github.com/andrewkroh/gvm/releases/download/v0.5.2/gvm-${OS}-${GVM_ARCH_SUFFIX}"
chmod +x "${GVM_CMD}"

eval "$("${GVM_CMD}" "${GO_VERSION}")"

# Install tools used only in CI using a local go.mod file.
GO_INSTALL_FLAGS="-modfile=$PWD/scripts/ci/ci.go.mod"
Expand Down