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

feat: set a better version for dev builds #1415

Merged
merged 6 commits into from
Nov 12, 2024

Conversation

robbkidd
Copy link
Member

@robbkidd robbkidd commented Nov 7, 2024

Which problem is this PR solving?

Prior to these changes, dev builds in CI have only an integer set for their version (main.BuildID). That left humans to:

  1. Humans have to remember that this integer is a CircleCI job ID.
  2. Humans have to remember how to get to a CircleCI job ID directly on the right workflow.
https://app.circleci.com/pipelines/github/honeycombio/refinery/4470/workflows/21612810-63c4-4780-8b30-a9f98575931f/jobs/<JOB_ID_HERE>
  1. Humans then have to open that job and read the banner at the top to determine which branch and commit that job was run on.

Short description of the changes

What if we encode most of that in the version number?

  • Use git to consistently generate a version number for any dev build.
    • git describe - Return the most recent annotated tag that is reachable from a commit.
    • --tags - OK, any tag, not just the annotated ones. We don't always remember to annotate a version tag.
    • --match='v[0-9]*' - But of all those tags, only the version ones (starts with a v and a digit).
    • --always - … and if a tag can't be found, fallback to the commit ID.
  • Append the CircleCI job ID to the version number if the build is running there.

Example of a version computed in CI for any build that isn't a tagging event:

v2.8.2-45-ge527ea1-ci8675309

That the version contains more than v2.8.2 indicates:

  • It's a dev build.
  • It's from git commit e527ea1.
  • That commit is 45 commits ahead of the commit tagged with v2.8.2.
  • It was built in CI in job number 8675309.

@robbkidd robbkidd requested a review from a team as a code owner November 7, 2024 21:16
@robbkidd robbkidd self-assigned this Nov 7, 2024
@robbkidd robbkidd added the type: enhancement New feature or request label Nov 7, 2024
@robbkidd robbkidd changed the title fix: set a better version for dev builds feat: set a better version for dev builds Nov 7, 2024
@robbkidd robbkidd added the version: no bump A PR with maintenance or doc changes that aren't included in a release. label Nov 7, 2024
VERSION="${CIRCLE_BUILD_NUM}"
# If we are doing a dev build on circle, append the build number (job id) to the version
if [[ -n "${CIRCLE_BUILD_NUM:-}" ]]; then
VERSION="${VERSION}-ci${CIRCLE_BUILD_NUM}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
VERSION="${VERSION}-ci${CIRCLE_BUILD_NUM}"
VERSION="${VERSION}-${CIRCLE_BUILD_NUM}"

So I love the general idea of this. However, I find the full version a bit distracting with the extra descriptors. I also wonder if the 45 commits is necessary. I don't know if it's possible to drop the g, but I feel like it would be clearer if we dropped the g and the ci.

A radical idea could be something like...

v2.8.2-45-ge527ea1-ci8675309 becomes v2.8.2+e527ea1_8675309

Copy link
Contributor

Choose a reason for hiding this comment

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

Personally, I don't see the value in the 45. I also like dropping g and ci, but I don't think we win much with the + and _ -- I'd rather see dashes or underscores everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea to quickly know how much deviation between a dev build and the last stable release. Since the CI build ID is always a number, I find it helpful to have the ci prefix to remind me what the number is. However, I agree that the g for git is not as helpful since commit hash also contains letters.

Copy link
Member Author

Choose a reason for hiding this comment

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

Starting with defaults, the 45 and the g is what comes out of the git describe command:

❯ git describe --tags --match='v[0-9]*' --always
v2.8.2-45-ge527ea1

g for git is not as helpful since commit hash also contains letters

I agree that's annoying. I happen to know that commit IDs are SHA1 hashes and SHA1 hashes are hexadecimal and g is not a hex digit, so my brain parses that fine and it doesn't bother me that much. … But as I list all that out, I see that it takes me knowing a lot of things to get to the point of it not bothering me much.

So my current tolerance for this format is such that I am currently not convinced that the added complexity to shape this dev version differently will be worth writing and maintaining. I am open to being convinced, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's not worth fixing that for a minor annoyance. I'm going to approve this, but it might be useful to also hear from others before merging.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, that's makes much more sense. Thank you for the explanation. My brain can now process it better. Always learning something new from Robb.

I agree with you that this is not something that worth adding more complexity for

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, not worth the added effort. This gives me so much information so I'm plenty pleased 😃

Copy link
Contributor

Choose a reason for hiding this comment

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

I also don't find much value in the ci prefix for circle build IDs. I'm don't mind the hyphen's or the number of commits as they match the default git format.

Also agree there's we've been blocked on this for awhile, we can always come back and change it if needed but this better than what we have now.

Copy link
Contributor

@VinozzZ VinozzZ left a comment

Choose a reason for hiding this comment

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

I love the idea!
I do find it hard to interpret the meaning of the version tag without reading through the PR description. Do you think we can add what you wrote in the PR description for how to read the version tag into the build script?

VERSION="${CIRCLE_BUILD_NUM}"
# If we are doing a dev build on circle, append the build number (job id) to the version
if [[ -n "${CIRCLE_BUILD_NUM:-}" ]]; then
VERSION="${VERSION}-ci${CIRCLE_BUILD_NUM}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's not worth fixing that for a minor annoyance. I'm going to approve this, but it might be useful to also hear from others before merging.

@robbkidd
Copy link
Member Author

robbkidd commented Nov 7, 2024

Added a version number decoder ring to doc comments, as @VinozzZ recommended.

Copy link
Contributor

@VinozzZ VinozzZ left a comment

Choose a reason for hiding this comment

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

Thank you for making this improvement! Our future infra PRs will be much easier to review now

Copy link
Contributor

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

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

tenor-73554740

build-docker.sh Outdated Show resolved Hide resolved
VERSION="${CIRCLE_BUILD_NUM}"
# If we are doing a dev build on circle, append the build number (job id) to the version
if [[ -n "${CIRCLE_BUILD_NUM:-}" ]]; then
VERSION="${VERSION}-ci${CIRCLE_BUILD_NUM}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I also don't find much value in the ci prefix for circle build IDs. I'm don't mind the hyphen's or the number of commits as they match the default git format.

Also agree there's we've been blocked on this for awhile, we can always come back and change it if needed but this better than what we have now.

@MikeGoldsmith
Copy link
Contributor

Gonna take this as it is now. We can always make more changes later.

@MikeGoldsmith MikeGoldsmith merged commit 6bf6c1c into main Nov 12, 2024
5 checks passed
@MikeGoldsmith MikeGoldsmith deleted the robb.more-informative-dev-versions branch November 12, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request version: no bump A PR with maintenance or doc changes that aren't included in a release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants