From 242a26b8e084fc6ed0d1363491bf9eaf5d268684 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 6 Nov 2023 09:18:55 +0100 Subject: [PATCH 1/3] ci: use gvm instead of gimme uses the script from https://github.com/elastic/beats/blob/024a9cec6608c6f371ad1cb769649e024124ff92/.ci/scripts/install-go.sh --- scripts/ci/setenv.sh | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/scripts/ci/setenv.sh b/scripts/ci/setenv.sh index 60a4926db..39df6c0ab 100755 --- a/scripts/ci/setenv.sh +++ b/scripts/ci/setenv.sh @@ -1,9 +1,47 @@ #!/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" From 4533b4e2c402805e49ce39c5756c6b4d78a22d39 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 6 Nov 2023 09:28:39 +0100 Subject: [PATCH 2/3] get dynamically the latest stable version --- .github/workflows/microbenchmark.yml | 4 ---- scripts/ci/bench.sh | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/microbenchmark.yml b/.github/workflows/microbenchmark.yml index ea38e148b..f59431c5e 100644 --- a/.github/workflows/microbenchmark.yml +++ b/.github/workflows/microbenchmark.yml @@ -15,9 +15,6 @@ on: permissions: contents: read -env: - GO_VERSION: stable - jobs: microbenchmark: runs-on: ubuntu-latest @@ -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 diff --git a/scripts/ci/bench.sh b/scripts/ci/bench.sh index d08741325..be2565011 100755 --- a/scripts/ci/bench.sh +++ b/scripts/ci/bench.sh @@ -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 From 5f469aade2d20f6bc2db2292197b4a5b12552d8c Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 6 Nov 2023 09:38:52 +0100 Subject: [PATCH 3/3] chore: cosmetic log --- scripts/ci/bench.sh | 1 + scripts/ci/setenv.sh | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/bench.sh b/scripts/ci/bench.sh index be2565011..4b64d52e2 100755 --- a/scripts/ci/bench.sh +++ b/scripts/ci/bench.sh @@ -40,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 diff --git a/scripts/ci/setenv.sh b/scripts/ci/setenv.sh index 39df6c0ab..e8b672c89 100755 --- a/scripts/ci/setenv.sh +++ b/scripts/ci/setenv.sh @@ -42,7 +42,6 @@ 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"