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

During checkout, retrieve all commits and tags #160

Merged
merged 1 commit into from
Apr 13, 2024
Merged

Conversation

hoechenberger
Copy link
Owner

No description provided.

…re the correct version number can be deduced dynamically
@hoechenberger
Copy link
Owner Author

hoechenberger commented Apr 13, 2024

cc @cbrnr @larsoner

I saw in other PRs:

2024-04-13T18:15:26.9073758Z * Creating isolated environment: venv+pip...
2024-04-13T18:15:26.9607420Z * Installing packages in isolated environment:
2024-04-13T18:15:28.7808422Z   - hatch-vcs
2024-04-13T18:15:28.7809025Z   - hatchling
2024-04-13T18:15:28.7810899Z * Getting build dependencies for sdist...
2024-04-13T18:15:28.8864272Z * Building sdist...
2024-04-13T18:15:29.2047469Z /tmp/build-env-xwqvbncu/lib/python3.10/site-packages/setuptools_scm/git.py:163: UserWarning: "/home/runner/work/openneuro-py/openneuro-py" is shallow and may cause errors
2024-04-13T18:15:29.2048664Z   warnings.warn(f'"{wd.path}" is shallow and may cause errors')
2024-04-13T18:15:29.3109724Z Successfully built openneuro_py-0.1.0.dev1+g392b40c.tar.gz

So the version number is wrong and we get a warning … I hope that fetching the entire git history (as per this PR) will fix this problem.

AFAIK it never affected our build+publish workflow as this one is only triggered on release, and then the GH checkout action retrieves the entire git history by default already

Edit:

Yep, seems to work:

2024-04-13T18:22:34.6097456Z * Creating isolated environment: venv+pip...
2024-04-13T18:22:34.6164282Z * Installing packages in isolated environment:
2024-04-13T18:22:36.6284100Z   - hatch-vcs
2024-04-13T18:22:36.6284694Z   - hatchling
2024-04-13T18:22:36.6285181Z * Getting build dependencies for sdist...
2024-04-13T18:22:36.7390133Z * Building sdist...
2024-04-13T18:22:37.1543894Z Successfully built openneuro_py-2024.3.0.dev10+g03b51e1.tar.gz

@hoechenberger hoechenberger marked this pull request as ready for review April 13, 2024 18:27
@hoechenberger hoechenberger merged commit fc57c9e into main Apr 13, 2024
13 checks passed
@hoechenberger hoechenberger deleted the fetch-depth branch April 13, 2024 18:27
@cbrnr
Copy link
Contributor

cbrnr commented Apr 15, 2024

So it seems this warning/error is due to raw-options = { version_scheme = "release-branch-semver" }, right? Whatever the default is, it should work even with a checkout depth of 1 (i.e. just 1 commit). (Not asking to switch, but because I'm trying to understand what's going on.)

@hoechenberger
Copy link
Owner Author

hoechenberger commented Apr 15, 2024

I don't think that's the full explanation, as the checkout action also doesn't seem to retrieve all tags by default

So determining the version number just on the very last commit and tag won't work either

Maybe the last tag will be received if it corresponds to the latest commit, I haven't tried that

We could copy the checkout action's command line and play with it to find out the required options. But I currently don't have time for this

@hoechenberger
Copy link
Owner Author

hoechenberger commented Apr 15, 2024

It appears this problem is also being tracked upstream at actions/checkout#249

@hoechenberger
Copy link
Owner Author

hoechenberger commented Apr 15, 2024

The checkout action also has a fetch-tags setting, which if true will fetch the tags even when fetch-depth is not zero. This could be an acceptable workaround for CI testing to avoid having to retrieve the entire repository with all commits

Not sure if it will get rid of the "shallow repository" warning though.

@cbrnr
Copy link
Contributor

cbrnr commented Apr 15, 2024

AFAIK it never affected our build+publish workflow as this one is only triggered on release, and then the GH checkout action retrieves the entire git history by default already

I don't understand why and how this happens; the checkout action is identical to the one in the tests, or no? https://github.com/hoechenberger/openneuro-py/blob/main/.github/workflows/python-publish.yml#L31

@hoechenberger
Copy link
Owner Author

I don't understand why and how this happens; the checkout action is identical to the one in the tests, or no?

Yes but the action itself parses what event triggered the action (new tag, release, commit, …) and adjusts its behavior accordingly.

@cbrnr
Copy link
Contributor

cbrnr commented Apr 15, 2024

Where did you find that information? I can't find it in their docs...

@hoechenberger
Copy link
Owner Author

hoechenberger commented Apr 15, 2024

Where did you find that information? I can't find it in their docs...

I thought I saw this in their code somewhere, but I'm failing to discover it again :D So … maybe I was mistaken!

Maybe because the Publish workflow only runs once we've added a tag, retrieving the latest commit will also load the tag that points to this commit, and everything works as intended then? And it's just a happy coincidence for us.

Definitely worth investigating!

Maybe the safest approach for now really is setting the fetch-depth to 0 for all workflows!!

@cbrnr I'd appreciate it if you could find the time to dig a little bit into this – I'm rather busy this week :( Or maybe @larsoner can help! In any case, we should try to better understand what's going on to ensure we won't run into unintended problems in the future!

also tagging @sappelhoff, @drammock and @agramfort just to keep them in the loop.

hoechenberger added a commit that referenced this pull request Apr 15, 2024
Just to be sure we can always derive the correct version number dynamically.

x-ref #160
hoechenberger added a commit that referenced this pull request Apr 15, 2024
Just to be sure we can always derive the correct version number
dynamically.

x-ref #160

cc @cbrnr @larsoner
@hoechenberger hoechenberger changed the title When building a pull request branch, retrieve all Git history to ensure the correct version number can be deduced dynamically During checkout, retrieve all commits and tags Apr 15, 2024
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