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

Tags without Releases #26

Closed
shikokuchuo opened this issue Mar 6, 2024 · 39 comments
Closed

Tags without Releases #26

shikokuchuo opened this issue Mar 6, 2024 · 39 comments

Comments

@shikokuchuo
Copy link
Member

Need to investigate and handle e.g.

ERROR updating RcppSimdJson from https://github.com/cran/rcppsimdjson (Failed to find git reference '*release')

in the R-universe build logs.

Reverting this contribution in the meantime so the universe does not show a build warning.

@wlandau
Copy link
Member

wlandau commented Mar 6, 2024

Strange, I thought the CRAN mirror automatically created releases. Under what conditions does it just create tags?

@wlandau
Copy link
Member

wlandau commented Mar 6, 2024

Do you think we could post to https://github.com/metacran/metacranweb/issues?

@llrs
Copy link

llrs commented Mar 6, 2024

It seems that for some packages (I checked some others like experDesign, or rtweet) it only generates tags but not releases. It doesn't seem related to name of how old the package is...

Might be worth checking and see if there is also a way to request r-universe to build on tags & releases.

@wlandau
Copy link
Member

wlandau commented Mar 6, 2024

Might be worth checking and see if there is also a way to request r-universe to build on tags & releases.

I know it is possible to tag without a release, but is it possible to have a release without a tag? In the latter case, it might get ambiguous if we try to track both, or give the option of one or the other. But if releases always have tags, then it would be more inclusive to track the latest tag. We wouldn't have to rebrand, I don't think, but we could switch to tracking tags and it would solve this problem nicely.

@llrs
Copy link

llrs commented Mar 6, 2024

I recently made a release with usethis::usethis::use_github_release() and it creates both.
I think that git only allows tags but Github named them releases, but we would need to check it. Gitlab doesn't have releases but have tags, so I think this is Github specific.

@wlandau
Copy link
Member

wlandau commented Mar 6, 2024

https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases says releases are based on tags. I just tested it, and the web UI does not allow me to delete a tag without deleting the release. So I think it's safe to use tags on github.

gitlab also supports releases, and deleting the tag also deletes the release: https://docs.gitlab.com/ee/user/project/releases/

So I think it's safe to rely on tags for us. Unfortunately, I am not sure R-universe supports tracking the latest tag (yet).

@wlandau
Copy link
Member

wlandau commented Mar 6, 2024

Posted r-universe-org/help#378

@wlandau
Copy link
Member

wlandau commented Mar 6, 2024

On reflection... has anyone ever seen a Git tag used for a development version? I get the sense that Git tags are only ever used to mark release versions, but I want to be sure before we move in that direction.

@shikokuchuo
Copy link
Member Author

I mean it's up to the maintainer what they denote as 'release' or devt version. But I've only really seen them used for version numbers.

See https://git-scm.com/book/en/v2/Git-Basics-Tagging

Perhaps some of the tags were lightweight tags and not annotated and hence the discrepancy we're seeing in when they are translated to releases in the cran GitHub org.

@wlandau
Copy link
Member

wlandau commented Mar 6, 2024

I mean it's up to the maintainer what they denote as 'release' or devt version. But I've only really seen them used for version numbers.

Glad it wasn't just me.

See https://git-scm.com/book/en/v2/Git-Basics-Tagging

I think I'm now in favor of tags if we can track them automatically. Might have to ask for a feature in remotes because https://ropensci.org/blog/2021/06/22/setup-runiverse/#pro-tip-tracking-custom-branches-or-releasesis mentions it.

@wlandau
Copy link
Member

wlandau commented Mar 6, 2024

Just posted r-lib/remotes#200 (comment). Sounds like they talked about it before and in principle it would be an easy change in remotes (just a different API endpoint).

@shikokuchuo
Copy link
Member Author

I think I'm now in favor of tags if we can track them automatically. Might have to ask for a feature in remotes because https://ropensci.org/blog/2021/06/22/setup-runiverse/#pro-tip-tracking-custom-branches-or-releasesis mentions it.

Agree 100%. I'm finding as I'm adding more full dependency chains that especially some older packages only have tags, which I'm having to work round at the moment by using the CRAN mirror. Not too big an issue as these mostly seem to be mature packages and dependencies of actively-maintained and supported tidyverse packages etc.

@shikokuchuo
Copy link
Member Author

Also is Gitlab currently off-limits until we move to tags? E.g. for r-multiverse/contributions#101 do we need to use the CRAN mirror as an interim measure.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

IIRC R-universe does support GitLab releases. The only reason I flagged GitLab PRs for manual review is that ncurl() gets redirected to the sign-in page. We could do something more nuanced like calling the GitLab API with an access token, but I thought GitLab repos were not common enough to be worth automating.

@shikokuchuo
Copy link
Member Author

R-universe fails, see the logs at: https://github.com/r-universe/r-releases/actions/runs/8185714017/job/22382597652#step:3:372

Failed to find *release for: https://gitlab.com/luke-tierney/codetools: A "branch":"*release" is only supported github.com URLs

Switching to tags will probably allow us to better support Gitlab.

Gitlab requires a user authentication token for API use, which in the absence of a technical solution, means continuing to rely on manual review. I'm ok with this as Gitlab is an important platform to support.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

Hmmm that does pose a problem. I wonder how R-universe authenticates into GitLab.

I definitely agree we want to support tags on GitHub and GitLab (and Bitbucket if we can).

I will try and see if a "branch": "*tag" feature can be developed in remotes. Otherwise, I think it may be time for r.releases.internals::build_universe() to automatically fetch the latest tag using the APIs. I hesitate because that's tens of thousands of API calls, but we might have no other choice.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

Just posted a new issue: r-lib/remotes#786.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

A couple potential caveats with tags, c.f. r-universe-org/help#378 (comment):

  1. The concept of "latest" might not make sense for tags. We will need to investigate.
  2. How do we detect and deal with tags on non-default branches?

@eitsupi
Copy link
Member

eitsupi commented Mar 7, 2024

Note that the latest tag is not necessarily the latest release. That is, things like rc versions may also be tagged, and such tags are usually newer than the latest release.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

Great point. And in those case, a release is a stronger endorsement than a tag.

So one path forward would be to continue tracking releases, but ask for support for GitLab.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

I see there is already an issue: r-lib/remotes#570

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

I wonder if another workaround is to mirror GitLab projects on GitHub and create releases there?

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

To test how tags are listed in the GitHub API, I did an experiment using https://github.com/wlandau/tag-test. Here is what I did, in order:

  1. Create tag v-feature in a non-default feature branch.
  2. Create tag v1 in an upstream commit in the default branch main.
  3. Create a tag v2 in a commit directly downstream of v1 in main.
  4. Merge branch feature into main and create a new tag v-main-merge-feature.

Here is what I see in https://api.github.com/repos/wlandau/tag-test/tags:

[
  {
    "name": "v-main-merge-feature",
    "zipball_url": "https://api.github.com/repos/wlandau/tag-test/zipball/refs/tags/v-main-merge-feature",
    "tarball_url": "https://api.github.com/repos/wlandau/tag-test/tarball/refs/tags/v-main-merge-feature",
    "commit": {
      "sha": "66b8e213cbc61c7e3fe2f610352d964653d91476",
      "url": "https://api.github.com/repos/wlandau/tag-test/commits/66b8e213cbc61c7e3fe2f610352d964653d91476"
    },
    "node_id": "REF_kwDOLdESA75yZWZzL3RhZ3Mvdi1tYWluLW1lcmdlLWZlYXR1cmU"
  },
  {
    "name": "v-feature",
    "zipball_url": "https://api.github.com/repos/wlandau/tag-test/zipball/refs/tags/v-feature",
    "tarball_url": "https://api.github.com/repos/wlandau/tag-test/tarball/refs/tags/v-feature",
    "commit": {
      "sha": "36e3c382d87d9a1a44ed33777762f50e27aed4df",
      "url": "https://api.github.com/repos/wlandau/tag-test/commits/36e3c382d87d9a1a44ed33777762f50e27aed4df"
    },
    "node_id": "REF_kwDOLdESA7NyZWZzL3RhZ3Mvdi1mZWF0dXJl"
  },
  {
    "name": "v2",
    "zipball_url": "https://api.github.com/repos/wlandau/tag-test/zipball/refs/tags/v2",
    "tarball_url": "https://api.github.com/repos/wlandau/tag-test/tarball/refs/tags/v2",
    "commit": {
      "sha": "9b76abd0ee94afe8d0ac14faba504a40ddbfe817",
      "url": "https://api.github.com/repos/wlandau/tag-test/commits/9b76abd0ee94afe8d0ac14faba504a40ddbfe817"
    },
    "node_id": "REF_kwDOLdESA6xyZWZzL3RhZ3MvdjI"
  },
  {
    "name": "v1",
    "zipball_url": "https://api.github.com/repos/wlandau/tag-test/zipball/refs/tags/v1",
    "tarball_url": "https://api.github.com/repos/wlandau/tag-test/tarball/refs/tags/v1",
    "commit": {
      "sha": "f0862df449ab839b3c23adea2b35e9210209d9d2",
      "url": "https://api.github.com/repos/wlandau/tag-test/commits/f0862df449ab839b3c23adea2b35e9210209d9d2"
    },
    "node_id": "REF_kwDOLdESA6xyZWZzL3RhZ3MvdjE"
  }
]

So it looks like GitHub is trying to sort commits in topological order, which could allow tags in non-default branches to supersede ones in the main branch. This makes me think tags are no longer feasible for R-releases because they do not necessarily indicate production releases.

On the bright side, the order that tags are created does not seem to matter. It just matters the order the underlying commits are created.

I suspect that the reason people forget to put out formal releases is that there really hasn't been a need historically. People just submit to CRAN. This may change when we reach critical mass.

@shikokuchuo
Copy link
Member Author

On the bright side, the order that tags are created does not seem to matter. It just matters the order the underlying commits are created.

Yes, this is an important property.

I suspect that the reason people forget to put out formal releases is that there really hasn't been a need historically. People just submit to CRAN. This may change when we reach critical mass.

Good point. Not just for this issue, but more broadly. Rather than a technological solution, sometimes it makes more sense to seek a human behavioural solution.

@shikokuchuo
Copy link
Member Author

I wonder if another workaround is to mirror GitLab projects on GitHub and create releases there?

On this, I wouldn't mind if it were just the one repo. Otherwise doesn't seem to scale. We've only encountered one so far, and it's from R Core... I'd say let's prioritise the solution for Github first.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

So I propose:

  1. Stick with releases.
  2. Pursue Allow install of latest gitlab release (equivalent to github) r-lib/remotes#570. Could use help on that.
  3. Ask for releases in https://github.com/cran

Sound good?

@shikokuchuo
Copy link
Member Author

Do we know who maintains MetaCRAN? That might give us an estimate if 3 would be feasible.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

Jeroen said Gabor does, and I have seen his name a lot in the commit history

@shikokuchuo
Copy link
Member Author

Oh then definitely feasible :) Just if he has time or not...

@eitsupi
Copy link
Member

eitsupi commented Mar 7, 2024

I think it is common for package repositories using Git (such as Homebrew) to register a pattern of tags (or URLs) for each package and track them automatically.

But here it is overkill and the easiest thing to do is to get metacran to create GitHub releases.

@eitsupi
Copy link
Member

eitsupi commented Mar 7, 2024

Note that if you want to track Git tags from R, you can use something like the following using the gert package. This code has been tracking RStudio tags for several years on CI.

https://github.com/rocker-org/rocker-versioned2/blob/2db571dc64e401936ee14f64e454eaaba4f3d16f/build/make-stacks.R#L125-L134

.latest_version_of_git_repo <- function(remote_repo) {
  gert::git_remote_ls(remote = remote_repo) |>
    dplyr::pull(ref) |>
    stringr::str_subset(r"(^refs/tags/v?(\d+\.){2}\d+$)") |>
    stringr::str_extract(r"((\d+\.)*\d+$)") |>
    package_version() |>
    sort() |>
    utils::tail(1) |>
    as.character()
}

@shikokuchuo
Copy link
Member Author

Thanks for the suggestion @eitsupi indeed gert is a great package - will have a dig in there to see what else might be useful for us.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

Thanks for the pointers on tags, @eitsupi. I think the branch ambiguity issue makes tags without releases a risky proposition, but it's still good for me to learn this stuff.

I just posted r-universe-org/help#379 because I think it would be simple for R-universe to track GitLab releases. My post explains the specific API calls I found, and presumably R-universe can already authenticate into GitLab if it already gets commits and tags.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

As for the CRAN mirror, it might be easier to make an exception for this one instance and remove "branch": "*release" just for CRAN packages. The documentation says each separate commit is its own CRAN version: https://docs.r-hub.io/#cran-source-code-mirror. Indeed, https://github.com/cran/codetools has no releases (only tags) and versions in the commit history track with the CRAN archive.

@shikokuchuo
Copy link
Member Author

Very good. This is the obvious solution that we've managed to overlook until now! Everything in the CRAN mirror is by definition a release, so we just need to take the latest one i.e. the R-universe default. We would just need to modify the internal utils package to accept this pattern when writing the packages.json.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

Sounds good. I am working on an update to r.releases.internals to:

  1. Omit "branch": "*release" from https://github.com/cran repos.
  2. Check GitLab releases. Making good progress on that, c.f. GitLab releases r-universe-org/help#379

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

Great news: we now have support for GitLab releases on R-universe! @jeroen really came to the rescue in r-universe-org/help#379.

wlandau added a commit to r-multiverse/multiverse.internals that referenced this issue Mar 7, 2024
wlandau added a commit to r-multiverse/multiverse.internals that referenced this issue Mar 7, 2024
@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

Added support in r-multiverse/multiverse.internals#12 to automatically merge GitLab contributions if they have releases.

@wlandau
Copy link
Member

wlandau commented Mar 7, 2024

I think we have resolved our tags-vs-releases discussion for the time being.

@wlandau wlandau closed this as completed Mar 7, 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

No branches or pull requests

4 participants