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

Fetch tags in CI for correct version #59

Merged
merged 5 commits into from
Mar 12, 2024
Merged

Conversation

glatterf42
Copy link
Member

I noticed before that our CI is not installing the correct version of our own library (it keeps being registered as v0.0.0). While reading up on poetry-dynamic-versioning limitations, I found a note about Dunamai's limitations, which powers poetry-dynamic-versioning. In order to register the version correctly in GitHub Actions, they recommend running the checkout action with fetch-depth: 0, which fetches all history for all branches and tags. However, v4 of the checkout action also offers fetch-tags, which is false by default.
In theory, this sounds exactly like the thing we need, so this PR sets it to true in the relevant workflows.

@glatterf42 glatterf42 added the enhancement New feature or request label Mar 8, 2024
@glatterf42 glatterf42 self-assigned this Mar 8, 2024
@glatterf42
Copy link
Member Author

The simple fetch-tags: true did not fetch any tags, it seems. However, even though fetch-depth: 0 did fetch all tags (check the build-docs run from the second commit), the installed version of ixmp4 remains 0.0.0.

@glatterf42
Copy link
Member Author

glatterf42 commented Mar 8, 2024

The solution was already partly contained in the publish workflow: we need to install the dynamic-versioning plugin in the CI runs as well, of course.
However, the old publish workflow still produced a warning in the build package step: Warning: This is a shallow repository, so Dunamai may not produce the correct version.
This PR should remedy this by cloning the whole repo history.

One final note: we are currently only using lightweight tags. Git also offers annotated tags, which save the tag author and tag date. Should we ever apply multiple lightweight tags to the current commit, poetry-dynamic-versioning might struggle to identify the most recent tag. The solution for this is to use annotated tags. We can create them easily via git tag -a v0.7.3 (for example). This will ask for a tag creation message, which will be displayed when investigating the tag e.g. via git show v0.7.3. It might also be possible to use git tag -s, which gpg-signs a tag, to create an annotated tag. I'm not sure it this also requires a tag message.

@glatterf42 glatterf42 requested a review from meksor March 8, 2024 11:02
Copy link
Member

@danielhuppmann danielhuppmann left a comment

Choose a reason for hiding this comment

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

Thanks, looks good - but please go through the workflow files once more and make the section-headings consistent (centered and see other comments inline).

.github/workflows/pytest.yaml Show resolved Hide resolved
.github/workflows/pytest.yaml Outdated Show resolved Hide resolved
@glatterf42 glatterf42 merged commit f88985c into main Mar 12, 2024
6 checks passed
@glatterf42 glatterf42 deleted the enh/ci-package-version branch March 12, 2024 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants