Skip to content

Allow injection of the commit hash and timestamp for hermetic builds.#1543

Open
SamirTalwar wants to merge 3 commits into
cheeaun:mainfrom
SamirTalwar:inject-commit-hash
Open

Allow injection of the commit hash and timestamp for hermetic builds.#1543
SamirTalwar wants to merge 3 commits into
cheeaun:mainfrom
SamirTalwar:inject-commit-hash

Conversation

@SamirTalwar

Copy link
Copy Markdown

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.

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.
Comment thread .prettierrc Outdated
Comment thread .prettierrc Outdated
Comment thread vite.config.js
PHANPY_DISALLOW_ROBOTS: DISALLOW_ROBOTS,
PHANPY_COMMIT_HASH: COMMIT_HASH,
PHANPY_COMMIT_TIME: COMMIT_TIME,
PHANPY_NOW: NOW,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This seems not needed if there's PHANPY_COMMIT_TIME?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is used for the build timestamp in version.json. It's not used elsewhere as far as I can see.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants