-
Notifications
You must be signed in to change notification settings - Fork 83
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
fix: use the right Go version in the CI #346
Conversation
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪 |
.ci/Jenkinsfile
Outdated
} | ||
} | ||
stage('Check') { | ||
options { skipDefaultCheckout() } | ||
steps { | ||
cleanup() | ||
withGoEnv(){ | ||
withGoEnv(version: "${GO_VERSION}"){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withGoEnv()
will search for the GO_VERSION or the file .go-version because it uses goDefaultVersion()
https://github.com/elastic/apm-pipeline-library/blob/master/vars/withGoEnvUnix.groovy#L37
https://github.com/elastic/apm-pipeline-library/blob/master/vars/goDefaultVersion.groovy#L19
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We must be missing something then, as previous executions are not setting the GO_VERSION properly: https://beats-ci.elastic.co/blue/organizations/jenkins/Ingest-manager%2Ffleet-server/detail/PR-289/12/pipeline/143. As you can see there, the version is 1.15.8, even though the .go-version file for that PR is set to 1.16.2 (https://github.com/elastic/fleet-server/blob/60c9b4647d913e018471fb790629a27f65097786/.go-version)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuisathaverat after reading the code in the pipeline step, I'm pretty sure this line https://github.com/elastic/apm-pipeline-library/blob/master/vars/goDefaultVersion.groovy#L29 is evaluated to false
, therefore the goDefaultVersion
is not overridden and it takes the default value: 1.15.8 (https://github.com/elastic/apm-pipeline-library/blob/master/vars/goDefaultVersion.groovy#L41)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR, we are reading the file from:
- this PR:
readFile("${env.WORKSPACE}/${env.BASE_DIR}/.go-version")
- in the step:
readFile(file: ".go-version")?.trim()
So I think the step should always read from BASE_DIR, as it's a common pattern we use. Do you think we should open a bug in the library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should run withGoEnv()
at root source level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh good catch! Will send a commit with that change, thanks!
This reverts commit 40e6fb3.
If we call it within the BASE_DIR, it will automatically infer the .go-version reading it from the root dir
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for fixing this!
* fix: use the right Go version in the CI (cherry picked from commit 40e6fb3) * chore: replace gimme with gvm (cherry picked from commit f888d11) * chore: enforce running the tests with go version (cherry picked from commit 078b9bc) # Conflicts: # Makefile * Revert "fix: use the right Go version in the CI" This reverts commit 40e6fb3. (cherry picked from commit 0871589) * fix: use WithGoEnv properly If we call it within the BASE_DIR, it will automatically infer the .go-version reading it from the root dir (cherry picked from commit 21328bf) * Update Makefile Co-authored-by: Manuel de la Peña <[email protected]> Co-authored-by: Sean Cunningham <[email protected]>
* fix: use the right Go version in the CI (cherry picked from commit 40e6fb3) * chore: replace gimme with gvm (cherry picked from commit f888d11) * chore: enforce running the tests with go version (cherry picked from commit 078b9bc) * Revert "fix: use the right Go version in the CI" This reverts commit 40e6fb3. (cherry picked from commit 0871589) * fix: use WithGoEnv properly If we call it within the BASE_DIR, it will automatically infer the .go-version reading it from the root dir (cherry picked from commit 21328bf) Co-authored-by: Manuel de la Peña <[email protected]>
@Mergifyio backport 7.14 |
Command
|
What does this PR do?
This PR sets an environment variable on CI, reading this project's
.go-version
file and setting that value toGO_VERSION
. Then, because thewithGoEnv
built-in step supports passing a version, we are using the new variable as an input parameter in the step. As a consequence, the step will internally use GVM to setup the Go environment for that version.The PR also replaces Gimme with gvm, and finally uses the existing script to set the Go version in the execution of the tests.
Why is it important?
We want to run the code in the proper version
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues
Follow-ups
I'd recommend moving to
gvm
in the automation scripts, to match what the CI does. I did that in f888d11, but we can revert that commit if you disagree.