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

Do we need to fetch the complete git history? #120

Closed
chances opened this issue Jan 11, 2021 · 9 comments
Closed

Do we need to fetch the complete git history? #120

chances opened this issue Jan 11, 2021 · 9 comments
Assignees
Labels
enhancement New feature or request

Comments

@chances
Copy link

chances commented Jan 11, 2021

Describe the bug
Checking out existing branch fails in my CI workflow.

To Reproduce
My workflow file: https://github.com/chances/descartes-d/actions/runs/477666176/workflow

Failing CI build: https://github.com/chances/descartes-d/pull/2/checks?check_run_id=1681534009

Expected behavior
Your license year task is skipped because the license/2021 branch already exists with license updates.

Screenshots
N/A

Additional context
Failing CI build: https://github.com/chances/descartes-d/pull/2/checks?check_run_id=1681534009

@chances chances added the bug Something isn't working label Jan 11, 2021
@github-actions
Copy link
Contributor

Hi there and welcome to this repository!

A maintainer will be with you shortly, but first and foremost I would like to thank you for taking the time to report this issue. Quality is of the highest priority for us, and we would never release anything with known defects. We aim to do our best but unfortunately you are here because you encountered something we didn't expect. Lets see if we can figure out what went wrong and provide a remedy for it.

chances added a commit to chances/descartes-d that referenced this issue Jan 11, 2021
@FantasticFiasco
Copy link
Owner

Hi @chances!

I think replacing

- uses: actions/checkout@v2

with

- uses: actions/checkout@v2
  with:
    fetch-depth: 0

should fix your problem. Can you try it out and report back?

@chances
Copy link
Author

chances commented Jan 11, 2021

@FantasticFiasco Hm, that seems to resolve it.

Why is fetch-depth: 0 required?

chances added a commit to chances/descartes-d that referenced this issue Jan 11, 2021
@FantasticFiasco
Copy link
Owner

FantasticFiasco commented Jan 11, 2021

It seems that actions/checkout@v2, due to an optimization, only gets the lates commit by default. That operation will not get the tags, nor the branches of the repository. I can understand their decision, because most often in CI you only get the files to run the tests or what not, but we need more of the repo, and its history, thus the necessity to set fetch-depth: 0.

You can read more about their reasoning here.

@chances
Copy link
Author

chances commented Jan 12, 2021

Other GitHub actions that play with Git don't require this flag on the checkout action, e.g. crazy-max/ghaction-github-pages@v2.

Can your action not workaround it like these other actions?

@FantasticFiasco
Copy link
Owner

crazy-max/ghaction-github-pages@v2 and this action doesn't share the same behaviour, thus you cannot compare them.

Where we in this action run git operations on the same repository checked out by the preceding actions/checkout@v2, crazy-max/ghaction-github-pages@v2 doesn't. They clone the specific branch of the target repository into a temp directory, and doesn't do any changes at all in the source repository that was checked out by their preceding actions/checkout@v2.

I'm quite sure that you could have found that out by comparing the source code in this repo with the source code in their repo. So let me turn the table. If removing fetch-depth: 0 is important to you, I challenge you to find a solution where we don't have to specify it using this action, and still remain with the same functionality.

@chances
Copy link
Author

chances commented Jan 21, 2021

I'm well aware of the actions' differing behavior. My intention in bringing up the crazy-max/ghaction-github-pages action was with regard to its implicit recognition of the fetch depth optimization.

The fetch-depth requirement your action imposes wastes CI resources. The optimization is important, especially for large repos with heavy branch churn.

Your action could, instead of expecting the entire history of the target repo, git fetch the branch refs of interest.

@FantasticFiasco
Copy link
Owner

You are correct, the change would be for a better one. One could play around with fetch depth, one could also remove the dependency towards actions/checkout@v2 altogether and clone the repo ourselves.

I'll leave the issue open. Let's see if it gets some traction.

@FantasticFiasco FantasticFiasco changed the title Checking out existing branch fails Do we need to fetch the complete git history? Jan 22, 2022
@FantasticFiasco FantasticFiasco added enhancement New feature or request and removed bug Something isn't working labels Jan 22, 2022
@FantasticFiasco
Copy link
Owner

I've come to the conclusion that depending on composability, where we depend on actions/checkout@v3, isn't a bad thing.

Closing issue.

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

No branches or pull requests

2 participants