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

gitversion from container image default behaviour differs from other installation methods #4042

Closed
f2calv opened this issue May 27, 2024 · 6 comments · Fixed by #4096
Closed

Comments

@f2calv
Copy link

f2calv commented May 27, 2024

Hi,

Firstly, love GitVersion, thanks to all contributors :)

Secondly, I've been experimenting with different methods of installing GitVersion in my GitHub workflows and believe I've found an anomaly in the containerised version... or at least something I can't explain, so I hope someone can shed some light here...

I one workflow am runinng 3 parallel jobs, each installing and executing GitVersion via 3 different mechanisms;

  • offical gittools actions
  • dotnet tool
  • container image

Here is the workflow I am executing;
https://github.com/f2calv/playground-gitversion/blob/f2calv/2024-05-checkout-testing/.github/workflows/test.yml

On a simple push trigger everything works as expected, actions/checkout checks out the HEAD;

On a Pull Request trigger the containerised version of GitVersion fails, actions/checkout checks out a MERGE commit;

The initial error is ERROR: fatal: detected dubious ownership in repository at '/repo'. If I then attempt to override the entrypoint in the container by setting safe.directory then GitVersion executes a little further but ultimately fails with Gitversion could not determine which branch to treat as the development branch, I got the safe-directory idea from another issue GitTools/build-images#34.

I would expect all three installation mechanisms of GitVersion to act the same.

Note: If I override the actions/checkout ref with github.event.pull_request.head.sha the containerised version works as expected.

@arturcic
Copy link
Member

@f2calv thank you for the detailed description. I will move the issue to the GitVersion repository

@arturcic arturcic transferred this issue from GitTools/build-images May 27, 2024
@arturcic arturcic added this to the 6.x milestone May 27, 2024
@arturcic
Copy link
Member

@f2calv do you mind to test with the rc.1 variants of the docker images? The latest tag is using an older version of the image and tool. https://hub.docker.com/r/gittools/gitversion/tags?page=&page_size=&ordering=&name=rc.1.

The latest will be moved to the 6.0 release soon and then the GitTools/build-images#34 will be included

@arturcic
Copy link
Member

arturcic commented Jun 10, 2024

Additionally on GitHub Actions you need to specify these env vars when executing docker run https://github.com/GitTools/GitVersion/blob/main/build/common/Utilities/DockerContextExtensions.cs#L263-L270

@f2calv
Copy link
Author

f2calv commented Jun 22, 2024

Thanks @arturcic for the pointers, sorry for delay, I have experimented with;

  • ENV vars OR no ENV vars
  • tag latest or 6-rc1
  • using my (default) GitVersion.yml config file OR no config file

Note: AFAIK this is just a default MainLine configuration file, I use the file mainly as an 'identifier' to let me/others know the repository versioning is managed by GitVersion;

mode: Mainline
branches: {}
ignore:
  sha: []
merge-message-formats: {}

Push request build;

Pull request build;

Conclusions;

  • ENV vars are most definitely needed to get success in a PR build (I didn't know this before)
  • Config file format is important
  • v6 has breaking changes in the config file

Did I miss anything?

@arturcic
Copy link
Member

arturcic commented Jun 22, 2024

Push request build;

Yes, please check https://github.com/GitTools/GitVersion/blob/main/BREAKING_CHANGES.md#configuration-changes

  • strangely the dotnet version fails now, when it worked a some weeks ago?

I checked the log, I suspect you should re-run the job as it seems an GH Actions issue

Conclusions;

  • ENV vars are most definitely needed to get success in a PR build (I didn't know this before)
  • Config file format is important
  • v6 has breaking changes in the config file

Yes, you got it right, I think we need to update the docs on DockerHub and specify the usage when running in a CI environment

@arturcic
Copy link
Member

🎉 This issue has been resolved in version 6.0.0-rc.2 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants