Skip to content

added commit-hash.txt file under export-subst flag#12717

Closed
nishant-sachdeva wants to merge 1 commit intoargotorg:developfrom
nishant-sachdeva:replacing_commit_hash_and_prerelease_with_git_archive_placeholders
Closed

added commit-hash.txt file under export-subst flag#12717
nishant-sachdeva wants to merge 1 commit intoargotorg:developfrom
nishant-sachdeva:replacing_commit_hash_and_prerelease_with_git_archive_placeholders

Conversation

@nishant-sachdeva
Copy link
Contributor

closes #9720

@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch 4 times, most recently from e93e202 to 17395cd Compare February 26, 2022 15:03
@chriseth
Copy link
Contributor

Approach looks good. We need to change all the code that reads those files and query the information from git if the contents contain placeholders.

@chriseth
Copy link
Contributor

Maybe we can even execute a git command to do the replacement (of course not modify the files)?

@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch 4 times, most recently from be09f5c to ee4005f Compare February 28, 2022 18:13
@cameel
Copy link
Collaborator

cameel commented Mar 1, 2022

Not sure if job failures are even related to the PR. There were some CircleCI problems yesterday to I reran it to make sure. It looks like CircleCI had some problems executing the bash code in the config. If it's reproducible, could also be that they changed something in their API/config format but that seems unlikely to me.

@cameel
Copy link
Collaborator

cameel commented Mar 1, 2022

Approach looks good. We need to change all the code that reads those files and query the information from git if the contents contain placeholders.

@nishant-sachdeva Does this replace the placeholders only when you explicitly run git archive or every time the code is checked out (would be nice to actually have a comment explaining that in the code)? If it's the former, you'll need to look through everything that reads these two files and manually tell either git to generate them before hand or just treat it as if the files did not exist.

@ekpyron
Copy link
Collaborator

ekpyron commented Mar 1, 2022

It'll only replace the placeholders on git archive, so yes: we will need to change the logic when reading those files, in particular cmake/scripts/buildinfo.cmake.

If the files do not contain placeholders, we can assume that it's a release tarball and use the commit hash from the file.

The tricky part will be the case, in which the files do contain placeholders: we will probably need to check if there is a release tag at the current commit to be able to tell, if we should build as prerelease or as release. EDIT: ah right - or we can inspect the top of the changelog instead as suggested in #9720.

@ekpyron
Copy link
Collaborator

ekpyron commented Mar 1, 2022

Using $Format:%d$ is probably too error-prone.
I think we may need to replace the prerelease.txt mechanism entirely and instead have something like a date.txt file plus checking the changelog for unreleased (unless someone comes up with something better).

@cameel
Copy link
Collaborator

cameel commented Mar 1, 2022

Is there are way for git to create the files during git archive? There would be fewer changes needed if they did not exist by default. Or they could exist but under a different name, like prerelease.txt.template or something.

@ekpyron
Copy link
Collaborator

ekpyron commented Mar 1, 2022

Is there are way for git to create the files during git archive? There would be fewer changes needed if they did not exist by default. Or they could exist but under a different name, like prerelease.txt.template or something.

Would that really help that much? In any case, I think the only thing you can do is to exclude files from git archive, which is not much help for our case.

The only complicated part I really see for this is to determine whether we're at a release tag on a git checkout.

@ekpyron
Copy link
Collaborator

ekpyron commented Mar 1, 2022

Or put differently: for the commit hash this is straightforward, but the prerelease/release logic we will basically have to rewrite for this no matter what.

@cameel
Copy link
Collaborator

cameel commented Mar 3, 2022

Would that really help that much?

I think it would. As I see it, the issue is all about source archives created by github. If these files were created only on git archive, we'd have proper source archives and keep everything working as it used to in other cases. We'd not have to worry that the files may exist but still contain the template. So we'd be done here already.

@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch from ee4005f to 8ace852 Compare March 3, 2022 14:21
@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch from 8ace852 to 4bd0405 Compare March 3, 2022 14:35
@@ -32,15 +32,19 @@ endif()
if (EXISTS ${ETH_SOURCE_DIR}/commit_hash.txt)
Copy link
Collaborator

@ekpyron ekpyron Mar 3, 2022

Choose a reason for hiding this comment

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

We should really make it an error if it doesn't exist instead of just doing this conditionally.
Does the file(READ thing cause an error if the file doesn't exist? If so we can just remove the ìf entirely.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was this marked as resolved?

@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch 5 times, most recently from 92b0664 to aecdd93 Compare March 3, 2022 15:14
@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch from aecdd93 to a04d83f Compare March 4, 2022 14:26
@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch 9 times, most recently from 5bace78 to 8433936 Compare April 1, 2022 10:21
@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch 3 times, most recently from 7c4552f to 75291ac Compare April 4, 2022 10:06
@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch from 75291ac to adaa92d Compare April 4, 2022 10:56
Comment on lines +51 to +52
)
endif()
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could also query git tag --points-at HEAD and check if it's a v* tag...
Ideally, we would default SOL_FORCE_RELEASE to true in that case, but that may be a hassle, so we could also just always force a release build then...

cd "${BUILDDIR}"

cmake .. -DCMAKE_BUILD_TYPE="$BUILD_TYPE" "${@:2}"
if [[ "$(git tag --points-at HEAD 2>/dev/null)" == v* ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this robust in the case there are several tags at HEAD?
That usually won't happen, but if it ever does, this might break...
It should really check, whether any tag at the HEAD is a v* tag, shouldn't it?

@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch from adaa92d to 1294836 Compare April 4, 2022 11:23
if ("$Env:FORCE_RELEASE" -Or "$Env:CIRCLE_TAG") {
New-Item prerelease.txt -type file
Write-Host "Building release version."
..\deps\cmake\bin\cmake --build . -j 10 --target install --config Release -DSOL_RELEASE_VERSION="On"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The cmake options here and below don't seem to match the new cmake options defined below, do they?
Also it doesn't seem nice to invoke cmake here and then again below...

@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch 2 times, most recently from 6c68d8b to ec10d35 Compare April 7, 2022 05:10
@nishant-sachdeva nishant-sachdeva force-pushed the replacing_commit_hash_and_prerelease_with_git_archive_placeholders branch from ec10d35 to 5feb9a9 Compare April 7, 2022 05:14
@ekpyron ekpyron self-assigned this Apr 7, 2022
@ekpyron
Copy link
Collaborator

ekpyron commented Aug 10, 2022

I think it's easier to redo this properly at some point rather than keeping this PR alive, so I'm closing for now.

@ekpyron ekpyron closed this Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace commit_hash.txt with git archive placeholders (and try also replacing prerelease.txt)

5 participants

Comments