Skip to content

Commit

Permalink
ci: use gvm instead of gimme (elastic#1537)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v authored Nov 9, 2023
1 parent 9849db8 commit b3a0425
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
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
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

0 comments on commit b3a0425

Please sign in to comment.