cake-contrib / Cake.AddinDiscoverer

Tool to aid with discovering information about Cake Addins
MIT License
5 stars 6 forks source link

Include Author GitHub profile (when available) in the extension YAML #219

Closed augustoproiete closed 1 year ago

augustoproiete commented 1 year ago

So that we can add a hyperlink to the author's GitHub profile on the website https://github.com/cake-build/website/issues/2550

Jericho commented 1 year ago

The YAML file (and the json file also) contain the name of contributors, a link to their avatar and a link to their github profile. Like this:

 {
    "Name": "augustoproiete",
    "AvatarUrl": "https://avatars.githubusercontent.com/u/177608?v=4",
    "HtmlUrl": "https://github.com/augustoproiete"
  },

Unless I misunderstand what you are asking for, the info you want is already in the YAML file

augustoproiete commented 1 year ago

Hey @Jericho I should have made the description above more clear. What I mean is to add the URL of the GitHub profile in each of extensions\Cake.*.yml files so that we can add a hyperlink to the author of the extension.

For example: https://github.com/cake-build/website/blob/ddee00276fe77d7ca3dddab1dc51015e0a842eb9/extensions/Cake.7zip.yml

image

I'd like an AuthorUrl pointing to the GitHub profile of the author - though thinking about it again, it would be tricky to get 🤔

Jericho commented 1 year ago

Oh I see. For some reason I thought you were talking about the contributors yaml file.

Let me think about this. I'm pretty sure I can figure something out.

Jericho commented 1 year ago

Isn't the profile URL as simple as concatenating a well known constant (in this case https://github.com/) with the user name?

The GitHub user name already being included in the YAML file, that gives you all the information you need to add the hyperlink you want.

augustoproiete commented 1 year ago

Hmmm 🤔 maybe - is Author guaranteed to be a GitHub username? I assumed Author either the Author metadata from the NuGet package or the user from the nuget.org

Jericho commented 1 year ago

Most of the time, the Author indeed is a GitHub user but it's not guaranteed. Let me explain:

Jericho commented 1 year ago

I have a solution that should allow getting the profile URL and avatar URL in MOST cases but not guaranteed to work in 100% of cases. Here is the logic:

  1. Attempt to fetch the GitHub user specified in the nuspec author field. This will work in cases where the specified author matches the GitHub username (for example: jericho, gep13, augustoproiete and cake-contrib) but it will fail in cases where the specified author is something like Bob Smith, Augusto and contributors or when multiple authors are specified.
  2. If step 1 failed, we try to infer the GitHub user name by inspecting the repository URL specified in the nuspec. This will work in cases where the specified URL looks like this: https://github.com/augustoproiete/Cake.MyAddin.git but it will fail if the URL is omitted or is not a GitHub URL (such as BitBucket for example).

This would allow AddinDisco to update YAML files like so: image

Please note that, if we go ahead with this improvement, every single YAML file will need to be updated. Fortunately, AddinDisco has logic to detect when a large number of files are modified and will submit a single PR to update the first 25 YAML files and wait until this PR is merged. When the PR is merged, another PR will be submitted for modify the next 25 YAML files and wait until this PR is merged. This process will be repeated until all YAML files have been updated. This is better than 300+ individual PRs.

Jericho commented 1 year ago

Here's a sample what it would look like: https://github.com/cake-build/website/compare/master...Jericho:dryrun_2023_07_03_20_37_28

In some cases AddinDisco was able to find the GitHub user: image

In some case it was not able to find the GitHub user but the repo was transferred to cake-contrib, therefore the profile URL and the avatar URL point to the cake-contrib org: image

In some cases the YAML file was manually created before AddinDisco was created and the author username appears to contains a typo (I believe the GitHub username is RichieCoder, but I'm not 100% certain): image

In some cases, there are multiple authors which we can't correlate to a single GitHub user (in this particular example, the repo was transferred to cake-contrib, so we were able to fallback on the cake-contrib org): image

The bottom line is: I can definitely implement this new feature but we must understand that it's not 100% perfect.

pascalberger commented 1 year ago

Considering the use case, for which this issue was opened, I would suggest to use mappings to support multiple authors:

Authors:
  - Name: agc93
    AuthorProfileUrl: https://github.com/agc93
    AuthorAvatarUrl: https://avatars.githubusercontent.com/u/1369269?v=4
  - Name: cake-contrib
    AuthorProfileUrl: https://github.com/cake-contrib
    AuthorAvatarUrl: https://avatars.githubusercontent.com/u/21088753?v=4

While this is a breaking change and needs to have website code also updated, it is IMHO a much cleaner structure longtermn.

Jericho commented 1 year ago

@pascal One major problem is the source of this information is the 'Authors' property in the nuspec which contains an unstructured string. What I mean by "unstructured" is that the person editing the nuspec is free to enter whatever they want and they don't have to follow any rules. This makes it very difficult for me to use any kind of logic to parse this string and detect if there are multiple names.

Here are a few examples to illustrate the difficulty: jericho, jericho, gep13, cake-contrib, agc93 cake-contrib, Bob Smith and Augusto and collaborators.

I can't think of a way to reliably parse this information.

pascalberger commented 1 year ago

I see the issue.

When we want to have links on the author in the extension list as mentioned in https://github.com/cake-build/website/issues/2550, the only solution I see would be to use the owner of the package as defined on nuget.org, instead of the author metdata field, and then have it linking to the nuget.org profile. But then the question is if a nuget.org profile really provides any value for users of Cake website.

If we can't provide a consistent behavior I don't think it will be an improvement, and users probably have a better experience without this feature at all.

Jericho commented 1 year ago

The more I think about this discussion, the less confident I become about adding GitHub profile URL based on parsing the nuspec "Author" field. I am not confident (for reasons explained previously) that I can reliably parse this string and therefore we wouldn't be able to rely on the resulting URL.

All this to say that I am considering abandoning this effort.

Do you guys agree?

pascalberger commented 1 year ago

I agree. With the repo information to the contributors we can add a list of all contributors on the extension page, which we can also link to the GitHub profile. No need to link the author field too IMHO

Jericho commented 1 year ago

Thanks for the discussion. I'll go ahead and abandon my effort related to this issue.