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

feat: automatic fallback to tags for GitHub #275

Closed
ThinkChaos opened this issue Jun 27, 2023 · 5 comments
Closed

feat: automatic fallback to tags for GitHub #275

ThinkChaos opened this issue Jun 27, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@ThinkChaos
Copy link

Is your feature request related to a problem? Please describe.

Having to manually specify url_commands for GitHub repos that use tags, but not releases is slightly inconvenient.

Describe the solution you'd like

It would be nice if Argus could automatically fall back to tags if no releases exist for the service.
To do this without counting towards the API rate limit, the ETag could default to "1202860668f8cc09802a90038fa4ff8cdc642644697a3ef85aace4bd6ed91973" which is what GitHub returns for an empty list.
In case of 304 Not Modified, Argus should query the tags API and match the default regex against each ref stripped from the refs/tags/ prefix.

Here's an example tags API response:

[
  {
    "ref": "refs/tags/v0.1",
    "node_id": "MDM6UmVmMTU5NTU2Nzk0OnJlZnMvdGFncy92MC4x",
    "url": "https://api.github.com/repos/go-vikunja/api/git/refs/tags/v0.1",
    "object": {
      "sha": "0bf5a9412e9da205b118517f5e2844e7850b7661",
      "type": "tag",
      "url": "https://api.github.com/repos/go-vikunja/api/git/tags/0bf5a9412e9da205b118517f5e2844e7850b7661"
    }
  },
  {
    "ref": "refs/tags/v0.2",
    "node_id": "MDM6UmVmMTU5NTU2Nzk0OnJlZnMvdGFncy92MC4y",
    "url": "https://api.github.com/repos/go-vikunja/api/git/refs/tags/v0.2",
    "object": {
      "sha": "5f695c2af8871b303e8b76bac888d8d57d16a6fd",
      "type": "tag",
      "url": "https://api.github.com/repos/go-vikunja/api/git/tags/5f695c2af8871b303e8b76bac888d8d57d16a6fd"
    }
  }
]

I believe this would make almost any GitHub project work out of the box.

Describe alternatives you've considered

Manually specifying the url_commands for each such service works.

@ThinkChaos ThinkChaos added the enhancement New feature or request label Jun 27, 2023
@JosephKav
Copy link
Collaborator

JosephKav commented Jul 1, 2023

Doing queries now on https://api.github.com/repos/go-vikunja/frontend/releases, https://api.github.com/repos/go-vikunja/frontend/releases and https://api.github.com/repos/allinurl/goaccess/releases gives me the 992aaf92b487506974e4305db4a64326866f3ed48b2ba424cef8fbe4e28f72b0 ETag. Was it giving you 1202860668f8cc09802a90038fa4ff8cdc642644697a3ef85aace4bd6ed91973 when you tried last week?

I'm thinking that the ETag for empty releases isn't constant, so just do the first query with no ETag, and if that query on /releases gives an empty list, then switch that Service to /tags. Would double the API calls for repos using tags instead of releases, but only on the very first queries for each Service on startup

@ThinkChaos
Copy link
Author

Trying again with Firefox I get the same ETag I had last week (1202...), but with curl I get the same one you do 992a....
Using Firefox's dev tools "copy as curl" I get a third ETag: 40d7791495f98777a75dd6d73d7794658c7df79d296af9c37bf97c9c3aa11ecc.
Hardcoding one of the "empty" ETags doesn't seem to have a downside so, if simple, why not? But as you said the cost is very low, so it's definitely not a big deal without either.
I just mentioned the ETag since I saw other requests use them :)

@JosephKav
Copy link
Collaborator

JosephKav commented Jul 3, 2023

Ah, good that it's not changed in a week.
I'll add this as a default, and on startup, do a query with that default and update the default if that's changed. I'm also adding a check for a 200 response being an empty list (incase that etag changes whilst the app is running), and having that update the default and trigger the fallback query

JosephKav added a commit that referenced this issue Jul 4, 2023
some repositories use tags and not releases.
switch a service to the tags api if /releases gives []

closes #275
JosephKav added a commit that referenced this issue Jul 4, 2023
some repositories use tags and not releases.
switch a service to the tags api if /releases gives []

closes #275
JosephKav added a commit that referenced this issue Jul 4, 2023
some repositories use tags and not releases.
switch a service to the tags api if /releases gives []

closes #275
JosephKav added a commit that referenced this issue Jul 4, 2023
some repositories use tags and not releases.
switch a service to the tags api if /releases gives []

closes #275
JosephKav added a commit that referenced this issue Jul 4, 2023
some repositories use tags and not releases.
switch a service to the tags api if /releases gives []

closes #275
JosephKav added a commit that referenced this issue Jul 4, 2023
some repositories use tags and not releases.
switch a service to the tags api if /releases gives []

closes #275
JosephKav added a commit that referenced this issue Jul 5, 2023
some repositories use tags and not releases.
switch a service to the tags api if /releases gives []

closes #275
JosephKav added a commit that referenced this issue Jul 6, 2023
some repositories use tags and not releases.
switch a service to the tags api if /releases gives []

closes #275
JosephKav added a commit that referenced this issue Jul 11, 2023
Features
* service: add /tags fallback to GitHub services (207e610), closes #275
* service: default service notify/command/webhook (08eb05f)
* service: support leading "v" in versions (e.g. v1.2.3) (bdab68d)
* web: lv url-commands, add regex index field (#274) (7def08c)

Bug Fixes
* db: switch to text for versions to keep trailing 0's (7289ce9)
* notify: missing defaults for shoutrrr type (4bdbf17)
* web: allow skip when command/webhook blocked by delay (4436d38)
* web: compare previous semantic_version state in version refreshes (3414a24), closes #279

master
JosephKav added a commit that referenced this issue Jul 11, 2023
Features
* service: add /tags fallback to GitHub services (207e610), closes #275
* service: default service notify/command/webhook (08eb05f)
* service: support leading "v" in versions (e.g. v1.2.3) (bdab68d)
* web: lv url-commands, add regex index field (#274) (7def08c)

Bug Fixes
* db: switch to text for versions to keep trailing 0's (7289ce9)
* notify: missing defaults for shoutrrr type (4bdbf17)
* web: allow skip when command/webhook blocked by delay (4436d38)
* web: compare previous semantic_version state in version refreshes (3414a24), closes #279
@ThinkChaos
Copy link
Author

Amazing, thanks!

I'll update and test later today :)
(Didn't get notified by the PRs, would've tested then otherwise!)

@ThinkChaos
Copy link
Author

Works great, thanks!

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