Post 145

Which Build Is This?

Every Lux binary now says exactly which commit it came from. Version numbers only change when a release ships, so 'v0.44.0' was previously true of the release, of my breakfast-time build, and of yours. Now it isn't.

Here is a question that sounds trivial and is not: what version of Lux are you running?

You would say 0.44.0, because that is what the title bar and lux --version and the first line of your log file all told you. And you would be right, in the sense that a horoscope is right. Version numbers change when a release ships. Between one release and the next, every build in existence carries the same number: the official binary, the one I compiled at breakfast with three days of unmerged work in it, and the one you built yourself from a branch to try something out. Same string. Three different programs.

This matters exactly once, and it matters a lot: the moment something goes wrong and you send me a log.

The number that changes when the code changes

Every Lux binary now identifies the commit it was built from:

$ lux --version
lux 0.44.0+1072.gfc3a6709

The 0.44.0 is the release, as before. The 1072 counts every change that has ever landed in Lux, so it goes up by one each time anything does; it is a build number in the way you would want a build number to behave, and you can say it out loud. The gfc3a6709 names the precise commit, so I can check out the exact code you were running rather than the code I think you were running.

It heads your log file too, which is the real point. The first line of a pasted log now says which program produced the rest of the lines.

The part that would have been a trap

The obvious way to do this is to have the build write the number into a file that lives in the project. I nearly did, and it would have been quietly disastrous: this project refuses to certify its own test results on a modified tree, so a build that edits a tracked file makes the tree look modified, and every build would have broken the gate that lets anything merge at all. The number is now asked of git at compile time and baked straight into the binary. Nothing is written down. Nothing to get stale, nothing to conflict, nothing to forget to commit.

The release build gets one further indignity: after the binary is built, the release pipeline runs --version on it and refuses to publish if the answer is vague. A build that could not reach git will happily report itself as 0.44.0+unknown, which is the correct thing for someone compiling from a source tarball and an unacceptable thing for a binary I am about to hand to you. If the release cannot say what it is, it does not ship.

Nothing here makes a single pixel prettier. It just means that when you tell me something is broken, my first reply can be something other than “which build?”

← All posts