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

Github action with sparse checkout causes cake Gitversion to crash #4308

Open
2 tasks done
OsirisTerje opened this issue Apr 3, 2024 · 0 comments
Open
2 tasks done

Comments

@OsirisTerje
Copy link

OsirisTerje commented Apr 3, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

Cake runner

Cake .NET Tool

Cake version

5.12.0

Operating system

Windows

Operating system architecture

64-Bit

CI Server

Github actions

What are you seeing?

Gitversion needs to have history to calculate the version. The default for the checkout task in github actions is sparse checkout, only a single commit (the latest) is pulled down. This causes the cake gitversion code to crash.

Without any diagnostics the error message does not point to the problem at hand.
image

Enabling diagnostic verbosity, one can see where it crashes, and since I have made this mistake in other builds earlier I recognized the pattern (red line indicates it). Others may not be that lucky.
image

If you run the gitversion tool as a separate step in the action, it will give you more information, and will not crash, but you get of course a meaningless version number.

The gitversion code in cake should detect this situation and try to give a more meaningful error message.

What is expected?

A message like: Not able to calculate gitversion

And since this is Gitversion, it could suggest something like Do you have a shallow clone?

Steps to Reproduce

Fork the repo https://github.com/nunit/nunit-console/

Select branch: https://github.com/nunit/nunit-console/tree/githubbuilds

The issue is fixed there now, but go down to commit 72062fc and build from that one.

To prevent the issue from appearing, make sure the checkout action looks like this:

 - name: ⤵️ Checkout Source
   uses: actions/checkout@v4
   with:
     fetch-depth: 0

Output log

See builds in nunit/nunit-console#1396, for commits 924fbc8 or later

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

No branches or pull requests

1 participant