Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Tags are not fetched if workflow is not triggered by tag #351

Closed
bartekpacia opened this issue Mar 27, 2024 · 6 comments · Fixed by cirruslabs/cirrus-ci-docs#1270 or #354
Closed

Comments

@bartekpacia
Copy link

bartekpacia commented Mar 27, 2024

I would like to always have my git tags, so I can use them for things like deploying releases etc. Currently, when my Cirrus CI workflow is not triggered by pushing a tag, no tags are fetched (i.e. git tag -l returns nothing).

I think it's confusing and not documented. For example GitHub's actions/checkout fetches all tags when fetch-depth: 0 is specified. On the other hand, Cirrus CI does not fetch tags at all, even if CIRRUS_CLONE_DEPTH=0 is specified (in fact, it's the default).

Seems like the offending code is:

  • here (in case of workflow triggered by a PR)
  • here (in case of workflow not triggered by a PR)

Current workaround is to run git fetch --tags as a script step, but this is not ideal since the container/VM might not have git installed. In other words, I want to use Cirrus Agent's builtin go-git.

@bartekpacia
Copy link
Author

To provide a bit more context that might be useful:

actions/checkout had this problem -> actions/checkout#701.

Apparently it was solved by actions/checkout#579.

So IIUC, this would fetch tags "reachable" from the last 5 commits:

- name: Clone repository
  uses: actions/checkout@v4
  with:
    fetch-depth: 5
    fetch-tags: true

@fkorotkov
Copy link
Contributor

I think if your workflow needs tag information than your VM/container has git pre-installed and you can explicitly run git fetch --tags. I see the confusion coming from GHA but IMO subtle differences are OK if they are documented. What do you think of cirruslabs/cirrus-ci-docs#1270?

I also have a gut feeling that if you limited clone depth and then do fetch tags than you'll fetch the whole history.

@bartekpacia
Copy link
Author

bartekpacia commented Mar 27, 2024

This docs update is greatly appreciated, thank you.

BTW I edited my original post to include this:

Current workaround is to run git fetch --tags as a script step, but this is not ideal since the container/VM might not have git installed (if I understand correctly). In other words, I want to use Cirrus Agent's builtin go-git.

Maybe additional env var CIRRUS_FETCH_TAGS could be added to control git.FetchOptions.Tags?

@bartekpacia
Copy link
Author

ping @fkorotkov - this issue was automatically closed becuase cirruslabs/cirrus-ci-docs#1270 was merged. I still would like to hear what you think about this.

I understand you're very busy, so I'd be happy to contribute this small feature myself if you agree.

@fkorotkov
Copy link
Contributor

I don't have strong opinion on that. Checked sources and seems not a big change so let's introduce it along other CIRRUS_CLONE_* option. See #354

@bartekpacia
Copy link
Author

Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants