-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Print Version Number on startup #1659
Conversation
…ions workflow and pass it to the main.go file Added a function in main.go to fetch the enviroment varible and to have a fallback if the env variable isnt there Added a test for the version to use for this branch only
Im not totally sure how the docker build and push works as i personally use buildah but it should be the same logic, as you set the enviroment variable on the runner machine and the docker daemon is hosted on the same "container" so it should inherit the enviorment variable. If not then maybe we can pass it. |
It's probably worth doing #1161 as part of this PR or in a follow up PR |
I have a quick question then. Shall i put the get version function inside github.go. I dont feel like it belongs there really, as its not really related to github per say. But it makes sense inheritance wise, that way we can have one function that both github.go calls internally and the same function that main.go calls, so we dont have two diffrent functions / code blocks. Could you make a "design" call on this kindly EDIT: We also dont need it to be a function it could just be two diffrent code blocks that get the ENV but with a function i creates one source of truth etc etc |
…by toast-gear Added version as issue#1161 requests. Decided to use a docker tag structure for the userAgent string, with : being a seperator of the name and version
@ViktorLindgren95 Thanks a lot for your effort! The direction looks very good. Implementation-wise, I have two comments- would you mind reviewing those comments and, if that makes sense to you, make corresponding changes, so that we can merge this before 0.26.0? Thanks in advance for your help |
Changed Dockerfile to use $VERSION from the workflow Added version.go and the build package Removed the getVersion function as we can just get the value directly
Changed Dockerfile to use $VERSION from the workflow Added version.go and the build package Removed the getVersion function as we can just get the value directly
No problem im just happy to do some coding in my free time 🥰 |
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.
The default didn't seem to take when I tested (built using the Makefile make docker-buildx
). Additionally, the Makefile needs adjusting to support passing in a version if desired (I still expected to see the verison as dev
but instead I got version": "",
). We can probably move the default value being set from the Go code to being set via an ARG in the Dockerfile with a default value if no arg is passed in. The project is designed to run from the image produced from its Dockerfile so I don't see an issue with doing that.
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.
ignore
Ok i think i know what happens. If the $VERSION variable is empty, aka not set, the version becomes empty instead of dev. I just confirmed this in my local enviroment. Because i got the version from the github actions variable its not fetched from any local instance. If you set version tag inside your own enviroment do you see a version being printed or is it still empty? I unfortunately dont know much about makefiles but, Would the makefile create it with the dockerfile? then try setting the version env in your enviroment and confirm for me . EDIT: Alternatively make a len < 1 return dev function , like a getter function but that seems hacky |
mmmm looks like some changes are needed:
EDIT @ViktorLindgren95 really appreciate your work so far, we're keen to get this in the current milestone v0.26.0 so if you do find some time to make those changes sooner rather than later we'd very much appreciate it 🙏 |
I will try to get a push before tommorow evening. When is 0.26 deadline? Also thanks for the patience on your end. This is all pretty new to me, the contributing to opensource and all that ^^ EDIT: @toast-gear "The default removed from the code" Do you mean just remove the dev part inside the build/version and leave it blank ? |
* Changed version from latest to dev inside makefile * Added buildarg for version to the dockerfile in the makerfile * Added VERSION with default dev value as arg inside dockerfile * Cleaned up inside dockerfile
We don't have specific deadlines for releases as the maintainers have full time jobs. There's only this + a small refactor to do (https://github.com/actions-runner-controller/actions-runner-controller/milestone/9) and then we are ready to release so we are hoping in the next week or 2.
yeh, leave it blank was what I was thinking |
I set it as N/A to make debugging easier instead of an empty message. Changes have been made |
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.
LGTM. Thank you so much for your efforts and contribution @ViktorLindgren95!!
@@ -25,7 +24,7 @@ RUN go mod download | |||
# With the above commmand, | |||
# TARGETOS can be "linux", TARGETARCH can be "amd64", "arm64", and "arm", TARGETVARIANT can be "v7". | |||
|
|||
ARG TARGETPLATFORM TARGETOS TARGETARCH TARGETVARIANT | |||
ARG TARGETPLATFORM TARGETOS TARGETARCH TARGETVARIANT VERSION=dev |
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.
Do we need to also update the workflow yaml file to set the VERSION
arg?
https://github.com/actions-runner-controller/actions-runner-controller/blob/master/.github/workflows/publish-arc.yaml
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.
nvm... build.Version=${VERSION}
will read from the ENV.
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.
@TingluoHuang Ahhh, that's actually a good catch!
Although our go-build snippet refers to the VERSION env, I don't think we now pass that env as a build-arg for the docker build.
Probably we might need to add something like build-args: VERSION=${{env.VERSION}}
to the docker-build-push action step.
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.
Addressed in da14999
…d arg in docker-build-push step
Updated the Also fixed the failing test related to the UA string generation in a4b3019 |
Merged. The next release of our canary image which will be available within 10 minutes or so would show |
Based on Issue 1654
Built a function that will print the current ARC version by fetching the enviroment variable ARC_VERSION with a fallback incase the enviroment variable isnt set yet.
ARC_VERSION is set inside the dockerfile which gets its value from the Publish ARC workflow
Works on my local windows machine, Havent confirmed on either my linux machine or K8s cluster. I will in future contributions setup a local test enviroment