Allow injection of the commit hash and timestamp for hermetic builds.#1543
Allow injection of the commit hash and timestamp for hermetic builds.#1543SamirTalwar wants to merge 3 commits into
Conversation
Hermetic build systems, such as Nix, typically don't provide the `.git` directory, which means that building Phanpy will fall back to the randomly-generated commit hash and current timestamp. As a workaround, I propose allowing the packager to specify this during build time with environment variables. I have also added some extra logging to make it clear what's going on.
| PHANPY_DISALLOW_ROBOTS: DISALLOW_ROBOTS, | ||
| PHANPY_COMMIT_HASH: COMMIT_HASH, | ||
| PHANPY_COMMIT_TIME: COMMIT_TIME, | ||
| PHANPY_NOW: NOW, |
There was a problem hiding this comment.
This seems not needed if there's PHANPY_COMMIT_TIME?
There was a problem hiding this comment.
This is used for the build timestamp in version.json. It's not used elsewhere as far as I can see.
There was a problem hiding this comment.
Oh, I guess it's reasonable to say that if you provide a PHANPY_COMMIT_TIME, then we can set now to that too, and use that for the buildTime in version.json as well. Would you prefer that?
There was a problem hiding this comment.
technically commit time != build time. commitTime = now; was a workaround as there's no available specific time for a commit. buildTime in version.json is also not used anywhere, so it's safe for it to be now, for now.
There was a problem hiding this comment.
That makes sense to me, and it's what I intended. PHANPY_COMMIT_TIME provides an override for the commit time, and PHANPY_NOW provides an override for the build time.
Hermetic build systems, such as Nix, typically don't provide the
.gitdirectory, which means that building Phanpy will fall back to the randomly-generated commit hash and current timestamp. As a workaround, I propose allowing the packager to specify this during build time with environment variables.I have also added some extra logging to make it clear what's going on.