Any suggestions on properly handling toolchain go1.xx.xx
with aqua based project?
#2609
-
QuestionI've been using aqua based go in my pipelines, via a pipeline style script. Now, when doing this we run into a problem. However, it will mean that Go not kept in sync with aqua + go.mod toolchain version will result in downloading an aqua managed go then again having to redownload another Go based on the toolchain. This can double the step time. Background of the questionNo response Example CodeUseful code perhaps for azure pipeline example, though this needs toolchain support to better handle this situation. ---
parameters:
# - name: GO_VERSION # set dynamically in the task
# type: string
# default: 1.x
- name: GOPATH
type: string
default: $(Agent.HomeDirectory)/go
- name: workingDirectory
type: string
default: $(Build.SourcesDirectory)
steps:
- bash: |
# Search for the aqua.yaml file
if [[ -f "aqua.yaml" ]]; then
file="aqua.yaml"
elif [[ -f "aqua/aqua.yaml" ]]; then
file="aqua/aqua.yaml"
elif [[ -f ".aqua/aqua.yaml" ]]; then
file=".aqua/aqua.yaml"
else
echo "Error: aqua.yaml file not found."
echo "##vso[task.logissue type=warning]unable to find aqua config, behavior with tools might unpredictable"
fi
echo "found aqua.yaml at: $file"
GO_VERSION=$(grep -oP 'golang/go@go\K[\d\.]+' "${file}")
echo "##vso[task.setvariable variable=GO_VERSION;isreadonly=true;isoutput=true;]${GO_VERSION}"
echo "##vso[task.setvariable variable=GO_VERSION;isreadonly=true;]${GO_VERSION}"
echo "👉 use go version: ${GO_VERSION}"
displayName: set-go-version
name: getgoversion
workingDirectory: ${{ parameters.workingDirectory }}
- task: GoTool@0
displayName: install-go
inputs:
version: $(getgoversion.GO_VERSION)
goPath: $(GOPATH) You could use this in the docs if you like, perhaps it would be useful. NoteAny ideas on how you'd handle? Aqua running Maybe a grouped go.mod + aqua renovate dependency so they both get updated in sync together with renovate? Just looking for a fresh perspective so I don't have more confusing steps in the future for contributors. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Thank you for your question. I found that if the go version in aqua.yaml is older than the go version of go directive in go.mod, go is installed twice.
How to reproduce
Install aqua on a container. https://aquaproj.github.io/docs/tutorial/#docker docker run --rm -ti debian:bookworm-20231009 bash apt update
apt install -y curl vim
mkdir ~/workspace
cd ~/workspace
export PATH="${AQUA_ROOT_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/aquaproj-aqua}/bin:$PATH"
curl -sSfL -O https://raw.githubusercontent.com/aquaproj/aqua-installer/v2.2.0/aqua-installer
echo "d13118c3172d90ffa6be205344b93e8621de9bf47c852d80da188ffa6985c276 aqua-installer" | sha256sum -c
chmod +x aqua-installer
./aqua-installer $ aqua version
aqua version 2.21.3 (8ddf104abfab2feb15018280c53ec9936aeff31e)
aqua init
aqua g -i golang/go@go1.21.0
aqua i aqua.yaml ---
# aqua - Declarative CLI Version Manager
# https://aquaproj.github.io/
# checksum:
# enabled: true
# require_checksum: true
# supported_envs:
# - all
registries:
- type: standard
ref: v4.114.0 # renovate: depName=aquaproj/aqua-registry
packages:
- name: golang/go@go1.21.0
$ go version
go version go1.21.0 linux/arm64
go mod init foo
sed -i s/1.21.0/1.21.5/ go.mod go.mod
$ go version
go: downloading go1.21.5 (linux/arm64)
go version go1.21.5 linux/arm64 We can confirm when go version is run
|
Beta Was this translation helpful? Give feedback.
-
One of the workarounds is to update toolchain and go in aqua.yaml at the same time by Renovate's grouping feature. |
Beta Was this translation helpful? Give feedback.
aqua v2.28.0 is out 🎉
https://github.com/aquaproj/aqua/releases/tag/v2.28.0