-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Use metadata to reconcile go-github with GitHub's OpenAPI descriptions #2919
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2919 +/- ##
=======================================
Coverage 98.11% 98.11%
=======================================
Files 149 149
Lines 12796 12796
=======================================
Hits 12555 12555
Misses 166 166
Partials 75 75
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll be OOO for one week, but before I go, I just wanted to point out that some of the new URLs have double slashes next to each other, e.g. https://docs.github.com/enterprise-cloud@latest//rest/actions/cache#get-github-actions-cache-usage-for-an-enterprise
.
Also, in cases where URLs have been completely removed, it might be nice to point
to explanations as to why they are being removed, such as:
- https://docs.github.com/en/actions/using-workflows/required-workflows
- https://docs.github.com/en/webhooks/replacing-github-services
- etc.
Have a great week, and thanks for doing this, @WillAbides !
@gmlewis enjoy your time away. Those double slashed URLs are the same way in the OpenAPI description. They work as-is, but I wouldn't mind normalizing the path for aesthetic reasons. That's a good point about adding explanations to the ones that lost their doc links. I'll go through those and add some notes. |
I updated update-urls to only modify links that don't resolve to the same docs. This makes the change set for this PR more manageable. |
# Conflicts: # .github/workflows/linter.yml # .github/workflows/tests.yml # github/misc.go # github/repos.go # github/repos_contents.go # update-urls/go.mod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, @WillAbides - very nice.
I'm looking forward to using it.
It looks like the PR is still a "Draft" but looks pretty complete to me. What's missing?
Maybe more instructions for maintainers? It looks pretty automated, though.
@gmlewis You're right about instructions. After I started to work on CONTRIBUTING.md I realized that this adds complexity for new contributors by asking them to edit a large yaml file. I also suspect that most new contributors don't do much more than skim CONTRIBUTING.md before making their first PR. I know I'm often guilty of that for new projects. A typical new contribution would be:
I gave it a little more thought and came up with a change I think will help. People tend to copy and adapt existing code. We can move the operation mapping to method a directive comment so that new contributors will see it on other methods as they write their code. The code comment for
I started coding this up thinking it would add complexity, but it actually simplifies the tooling code quite a bit. What do you think of moving the mapping to a directive comment? |
I think that is a great idea, @WillAbides. This is super obvious when I ask for a change in a PR and their reply is "it was done this way over here". Sometimes my response is, fine, keep it, but sometimes I say "can you please fix it over there too?" 😄 So having this with each method will probably make the maintenance burden much lower moving forward, as it will be obvious that it is needed for each method. I like it. |
I'm glad you like that idea. I have it mostly working, but it might be a few days before I have time to finish it up. |
# Conflicts: # update-urls/go.mod # update-urls/go.sum
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, @WillAbides !
Just a few minor tweaks, please, then we'll be ready for a second LGTM+Approval before merging.
CONTRIBUTING.md
Outdated
in `openapi_commit`. `update-openapi --validate` is called | ||
by `script/lint.sh`. | ||
|
||
- `update-go` - updates go files with documentation urls and formats comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"go" => "Go" or maybe ".go
" here?
Also, "urls" => "URLs".
tools/metadata/openapi.go
Outdated
major, _ := strconv.Atoi(m[pattern.SubexpIndex("major")]) | ||
minor, _ := strconv.Atoi(m[pattern.SubexpIndex("minor")]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really not care here if the major and/or minor versions are not supplied?
If so, could you please add a comment before line 132 stating that we don't care?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated it to return errors
Co-authored-by: Glenn Lewis <[email protected]>
Co-authored-by: Glenn Lewis <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @WillAbides !
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.
# Conflicts: # github/github.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if my approval helps here (won't be offended if we decide to wait for another approval), but I have gone through some the changes and LGTM.
Hoping this moves things along a bit.
# Conflicts: # github/rate_limit.go
Thank you, @vandanrohatgi and @valbeat ! |
see #2908
TODO before submitting for review:
This PR introduces a file called openapi_operations.yaml that contains details of GitHub's endpoints as described in https://github.com/github/rest-api-description. When combined with the
//meta:operation
directive, this allows us to automatically keep documentation links up to date, but more importantly it allows us to track endpoints as they are added and removed.The change set is huge, but it is primarily made up of openapi_operations.yaml itself and changes to godoc.
"tools/cmd/metadata" is a tool to manage metadata.yaml. I'll paste its help output here for convenience:
I'm trying to limit the scope of this PR because its line count is already pretty high. I will make a follow-up PR with a daily scheduled workflow that runs "update-openapi" and "update-go" and creates a PR if there are changes.