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

Gitlab generic packages #45

Merged
merged 14 commits into from
Mar 16, 2021

Conversation

sirlatrom
Copy link
Collaborator

Prefer GitLab Package if found for release version

This allows downloads from private repositories where goreleaser/goreleaser#2002 and goreleaser/goreleaser#2005 are used to upload generic packages for a release.

On private repositories, the uploaded project files made by goreleaser without additional generic uploads are not accessible through the API but only through a web browser session.

@sirlatrom
Copy link
Collaborator Author

@marcosnils What do you think about this approach?

@marcosnils
Copy link
Owner

marcosnils commented Mar 5, 2021 via email

Copy link
Owner

@marcosnils marcosnils left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the uploaded project files made by goreleaser without additional generic uploads

Is this a goreleaser thing? Or still related to the original gitlab issue?

I think the overall PR is ok. However, for public repos with generic packages, there's no way to force bin to download Assets if required, right?

Shall we consider both packages and assets as candidates for public repos?

pkg/providers/gitlab.go Outdated Show resolved Hide resolved
pkg/providers/gitlab.go Outdated Show resolved Hide resolved
@sirlatrom
Copy link
Collaborator Author

Merge at will?

@marcosnils
Copy link
Owner

Hey @sirlatrom I'm doing some preliminary tests and I'm getting some weird results. I'm running this command./bin --debug install gitlab.com/graphviz/graphviz I get the following outputs:

Multiple matches found, please select one:

 [1] stable_ubuntu_19.10_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [2] stable_ubuntu_19.10_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [3] stable_ubuntu_20.04_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [4] stable_ubuntu_20.04_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [5] stable_ubuntu_18.04_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [6] stable_ubuntu_18.04_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [7] stable_ubuntu_20.10_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [8] stable_ubuntu_20.10_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)

This is strange, just stable_ubuntu packages and only from the assets link, no generic packages at all.

Another thing that I was thinking that seems the current gitlab provider doesn't support is fectching generic packages from a single release, i.e: bin install gitlab.com/graphviz/graphviz/-/packages/1325470 and it still outputs the same as the first command.

@sirlatrom
Copy link
Collaborator Author

Hey @sirlatrom I'm doing some preliminary tests and I'm getting some weird results. I'm running this command./bin --debug install gitlab.com/graphviz/graphviz I get the following outputs:

Multiple matches found, please select one:

 [1] stable_ubuntu_19.10_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [2] stable_ubuntu_19.10_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [3] stable_ubuntu_20.04_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [4] stable_ubuntu_20.04_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [5] stable_ubuntu_18.04_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [6] stable_ubuntu_18.04_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [7] stable_ubuntu_20.10_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [8] stable_ubuntu_20.10_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)

This is strange, just stable_ubuntu packages and only from the assets link, no generic packages at all.

@marcosnils There are no generic packages because they've chosen not to version their generic packages the same as their tags, e.g. the latest release is v0.0.1110734215291781187721198496291116006578054937833, except from v2.46.1, which looks like the only one. I'll try and change the search order_by to get the largest versions first.

Another thing that I was thinking that seems the current gitlab provider doesn't support is fectching generic packages from a single release, i.e: bin install gitlab.com/graphviz/graphviz/-/packages/1325470 and it still outputs the same as the first command.

That's an interesting idea, and I think that should be possible to support as well.

@marcosnils
Copy link
Owner

I'll try and change the search order_by to get the largest versions first.

SGTM!

@sirlatrom
Copy link
Collaborator Author

@marcosnils There are no generic packages because they've chosen not to version their generic packages the same as their tags, e.g. the latest release is v0.0.1110734215291781187721198496291116006578054937833, except from v2.46.1, which looks like the only one. I'll try and change the search order_by to get the largest versions first.

Turns out that works, and v2.46.1 comes up first, leading to matched packages.

I'm doing some preliminary tests and I'm getting some weird results. I'm running this command./bin --debug install gitlab.com/graphviz/graphviz I get the following outputs:

Multiple matches found, please select one:

 [1] stable_ubuntu_19.10_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [2] stable_ubuntu_19.10_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [3] stable_ubuntu_20.04_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [4] stable_ubuntu_20.04_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [5] stable_ubuntu_18.04_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [6] stable_ubuntu_18.04_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [7] stable_ubuntu_20.10_debug_x86_64_libgraphviz4-dbgsym_2.46.1-1_amd64.ddeb (asset link)
 [8] stable_ubuntu_20.10_debug_x86_64_graphviz-dbgsym_2.46.1-1_amd64.ddeb (asset link)

This, it turns out after debugging, is because filetype.GetType("ddeb") matches the types.Unknown case - otherwise there would be 0 results to choose between, which is really the correct answer, as there are no single file static binaries in the package file list or asset link list.

@sirlatrom sirlatrom self-assigned this Mar 12, 2021
@sirlatrom sirlatrom added the enhancement New feature or request label Mar 12, 2021
@marcosnils
Copy link
Owner

hey @sirlatrom I was checking the last PR against this repository https://gitlab.com/tezos/tezos/-/releases which has both releases with the same version number and still I'm not seeing the generic package assets in the results.

Multiple matches found, please select one:

 [1] x86_64-linux-tezos-binaries.tar.gz (asset link)
 [2] tezos-endorser-alpha (x86_64 Linux) (asset link)
 [3] tezos-baker-alpha (x86_64 Linux) (asset link)
 [4] tezos-accuser-alpha (x86_64 Linux) (asset link)
 [5] tezos-endorser-008-PtEdo2Zk (x86_64 Linux) (asset link)
 [6] tezos-baker-008-PtEdo2Zk (x86_64 Linux) (asset link)
 [7] tezos-accuser-008-PtEdo2Zk (x86_64 Linux) (asset link)
 [8] tezos-endorser-007-PsDELPH1 (x86_64 Linux) (asset link)
 [9] tezos-baker-007-PsDELPH1 (x86_64 Linux) (asset link)
 [10] tezos-accuser-007-PsDELPH1 (x86_64 Linux) (asset link)
 [11] tezos-endorser-006-PsCARTHA (x86_64 Linux) (asset link)
 [12] tezos-baker-006-PsCARTHA (x86_64 Linux) (asset link)
 [13] tezos-accuser-006-PsCARTHA (x86_64 Linux) (asset link)
 [14] tezos-codec (x86_64 Linux) (asset link)
 [15] tezos-signer (x86_64 Linux) (asset link)
 [16] tezos-node (x86_64 Linux) (asset link)
 [17] tezos-client (x86_64 Linux) (asset link)
 [18] tezos-admin-client (x86_64 Linux) (asset link)

This allows downloads from private repositories where goreleaser/goreleaser#2002 and goreleaser/goreleaser#2005 are used to upload generic packages for a release.

On private repositories, the uploaded project files made by goreleaser without additional generic uploads are not accessible through the API but only through a web browser session.

Signed-off-by: Sune Keller <absukl@almbrand.dk>
Signed-off-by: Sune Keller <absukl@almbrand.dk>
Also ensures an URL is only added once. Duplicate names are allowed
in the GitLab Generic Packages API.

Furthermore makes the score of the asset name and URL considered on
equal footing, rather than favoritising assets with matches in both name
and URL.

Signed-off-by: Sune Keller <absukl@almbrand.dk>
Signed-off-by: Sune Keller <absukl@almbrand.dk>
Signed-off-by: Sune Keller <absukl@almbrand.dk>
Maybe this got reverted due to a bad rebase? Who knows.

Signed-off-by: Sune Keller <absukl@almbrand.dk>
Signed-off-by: Sune Keller <absukl@almbrand.dk>
Signed-off-by: Sune Keller <absukl@almbrand.dk>
Signed-off-by: Sune Keller <absukl@almbrand.dk>
Also considers when release tags don't include a leading 'v'.

Signed-off-by: Sune Keller <absukl@almbrand.dk>
…omponent

Signed-off-by: Sune Keller <absukl@almbrand.dk>
Signed-off-by: Sune Keller <absukl@almbrand.dk>
Signed-off-by: Sune Keller <absukl@almbrand.dk>
The PackagesEnabled field is always false when no token is used to get it.

Signed-off-by: Sune Keller <absukl@almbrand.dk>
@sirlatrom
Copy link
Collaborator Author

hey @sirlatrom I was checking the last PR against this repository https://gitlab.com/tezos/tezos/-/releases which has both releases with the same version number and still I'm not seeing the generic package assets in the results.

Multiple matches found, please select one:

 [1] x86_64-linux-tezos-binaries.tar.gz (asset link)
...
 [18] tezos-admin-client (x86_64 Linux) (asset link)

@marcosnils First of all, kudos for finding a GitLab project that actually has both releases and generic packages! I've been searching through public projects for a while without finding one 😄

It looks like there are more fields that are not set when getting a public project through the API without a token, including the "packages_enabled" field, which then defaults to false. In 234e422 that is handled as a special case.

Through 8670d0c I found out that the generic package files in https://gitlab.com/tezos/tezos/-/releases/8.2.0 score lower than the asset links due to the asset links having "Linux" in the name, which adds some extra score points for the OS, which is missing in the generic package file names.

@marcosnils
Copy link
Owner

Through 8670d0c I found out that the generic package files in https://gitlab.com/tezos/tezos/-/releases/8.2.0 score lower than the asset links due to the asset links having "Linux" in the name, which adds some extra score points for the OS, which is missing in the generic package file names.

Hmm makes sense. I guess we're ok now.

We can merge this PR and then open issue to support the install with a specific package version URL. WDYT?

@sirlatrom sirlatrom merged commit ea50803 into marcosnils:master Mar 16, 2021
@sirlatrom sirlatrom deleted the gitlab-generic-packages branch March 16, 2021 07:22
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

Successfully merging this pull request may close these issues.

2 participants