Skip to content
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 embedded files instead of ldflags to get the build info during runtime #2421

Closed
wants to merge 6 commits into from
Closed

fix: use embedded files instead of ldflags to get the build info during runtime #2421

wants to merge 6 commits into from

Conversation

tty47
Copy link
Contributor

@tty47 tty47 commented Jul 3, 2023

hello team,

I've added this small fix to use embed files rather than ldflags, we are missing the build info during the runtime (in Docker containers) and I think that's the only way to fix it...

Also, I added a couple of things to the Makefile.

  • gen-embeded: Generate the embed files for celestia-node binary.
  • docker-build: Builds the Docker container

The result of this looks like this:

Screenshot 2023-07-03 at 14 07 39

Please let me know what you think about it.

Best,

Jose Ramon Mañes

tty47 added 4 commits July 3, 2023 13:53
… during runtime

Signed-off-by: Jose Ramon Mañes <jose@celestia.org>
Signed-off-by: Jose Ramon Mañes <jose@celestia.org>
Signed-off-by: Jose Ramon Mañes <jose@celestia.org>
Signed-off-by: Jose Ramon Mañes <jose@celestia.org>
@tty47 tty47 self-assigned this Jul 3, 2023
@github-actions github-actions bot added the external Issues created by non node team members label Jul 3, 2023
@tty47 tty47 requested review from sysrex, Bidon15 and smuu July 3, 2023 12:11
@tty47 tty47 added docker Pull requests that update Docker code and removed external Issues created by non node team members labels Jul 3, 2023
Copy link
Member

@renaynay renaynay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe version.go is used in any unit tests, so can you add //+build: !test at top of file pls? Otherwise it'll throw errors

@Wondertan
Copy link
Member

Are we 100% this is the only way to fix this? I've seen various projects using ldflags and docker together without needing to do this setup.

Signed-off-by: Jose Ramon Mañes <jose@celestia.org>
@tty47
Copy link
Contributor Author

tty47 commented Jul 3, 2023

Are we 100% this is the only way to fix this? I've seen various projects using ldflags and docker together without needing to do this setup.

I think so, at least the other changes haven't worked, the other thing we can try is to move the ldflags and the build command to the Dockerfile here, but if we want to keep using only the make build...

buildTime string
lastCommit string
buildTime string
//go:embed lastCommit.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to document this lastCommit.txt here.
And exclude it from the the go test executor

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my commetn

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm the no build directive for tests seems to not work @jrmanes do you mind looking into it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can take a look 👌

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to fix the tests, we can either add the files lastCommit.txt& semanticVersion.txt to the repo (they can be empty), or run the make gen-embed before make test, but if we run go test ./... it will fail if these files are not there
wdyt?

Signed-off-by: Jose Ramon Mañes <jose@celestia.org>
Wondertan pushed a commit that referenced this pull request Jul 12, 2023
hello team!

I've created a new version in the common pipeline, this one should fix the issues with the forks and we'll have the version output that we're currently missing when using the docker containers.

If this works, we could close the PR: #2421
I've tested on my end and seems to be working crossed_fingers

PR where we've done the fix: celestiaorg/.github#65

Thanks in advance! rocket

Jose Ramon Mañes

celestiaorg/devops#370
@tty47
Copy link
Contributor Author

tty47 commented Jul 17, 2023

hello team!

we can close this PR, we fixed the issue using the latest version of the pipeline

I've done a couple of tests with different commits, and I can see it working 🔥

cheers! 🚀

@tty47 tty47 closed this Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker Pull requests that update Docker code
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants