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

Use metadata to reconcile go-github with GitHub's OpenAPI descriptions #2919

Merged
merged 38 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3083413
update doc urls
WillAbides Sep 8, 2023
11baddf
use metadata.yaml to reconcile source with OpenAPI descriptions
WillAbides Sep 8, 2023
462108e
trigger
WillAbides Sep 8, 2023
67d827b
minor refactor
WillAbides Sep 8, 2023
73e2220
go fmt
WillAbides Sep 8, 2023
d6360bd
update tools module
WillAbides Sep 8, 2023
7f4b553
revert script dir
WillAbides Sep 8, 2023
4aa1c11
restore gen-accessors.go and gen-stringify-test.go
WillAbides Sep 8, 2023
a1ba628
restore .gitignore
WillAbides Sep 8, 2023
7b7df59
go 1.20
WillAbides Sep 8, 2023
fa02527
update tooling and undocumented methods
WillAbides Sep 9, 2023
d855286
leave existing doc links in place
WillAbides Sep 10, 2023
43c3216
restore github dir
WillAbides Sep 10, 2023
ae5fd84
update regex
WillAbides Sep 10, 2023
000231c
update-urls
WillAbides Sep 10, 2023
e21c51b
include enterprise-server version in doc links
WillAbides Sep 10, 2023
1bf8fd6
add copyright notice
WillAbides Sep 10, 2023
0137f71
use ast in update-urls
WillAbides Sep 15, 2023
0f657ae
use ast in getServiceMethodsFromFile
WillAbides Sep 15, 2023
dfb3c8c
go fmt
WillAbides Sep 15, 2023
9a85b69
Use enterprise-cloud links
WillAbides Sep 15, 2023
63190e9
Merge branch 'master' into meta11
WillAbides Oct 14, 2023
b0ad415
refactor
WillAbides Oct 14, 2023
fcd94b3
fix comment
WillAbides Oct 14, 2023
cf4795b
start on CONTRIBUTING.md
WillAbides Oct 15, 2023
8e8cef8
rename metadata sub-commands
WillAbides Oct 15, 2023
b9b5e6f
make canonize more flexible
WillAbides Oct 15, 2023
b2b2e71
use //meta:operation directives
WillAbides Oct 19, 2023
54443b7
Merge branch 'master' into meta4
WillAbides Oct 19, 2023
ffd73b6
revert accidental test changes
WillAbides Oct 19, 2023
a2bff7b
Apply suggestions from code review
WillAbides Oct 19, 2023
4183cf5
Apply suggestions from code review
WillAbides Oct 19, 2023
b6d3af6
return AtoI errors
WillAbides Oct 19, 2023
6e4d263
update CONTRIBUTING.md
WillAbides Oct 19, 2023
0204952
Merge branch 'master' into meta4
WillAbides Oct 23, 2023
66a2035
add meta for RateLimitService.Get
WillAbides Oct 23, 2023
d72f064
Merge branch 'master' into meta4
WillAbides Nov 3, 2023
4a065a9
fix .golangci.yml exclusion for tools
WillAbides Nov 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ updates:
schedule:
interval: weekly
- package-ecosystem: gomod
directory: update-urls
directory: tools
schedule:
interval: weekly
- package-ecosystem: github-actions
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- ""
- example
- scrape
- update-urls
- tools
runs-on: ${{ matrix.platform }}

steps:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ jobs:
if: ${{ matrix.update-coverage }}
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d #v3.1.4

- name: Ensure go generate produces a zero diff for update-urls
shell: bash
run: cd update-urls && go generate -x ./... && git diff --exit-code; code=$?; git checkout -- .; (exit $code)
- name: Run go test for tools
run: cd tools && go test -v -race ./...

- name: Run go test for update-urls
run: cd update-urls && go test -v -race ./...
- name: Validate metadata.yaml
working-directory: tools
run: go run ./cmd/metadata validate
10 changes: 5 additions & 5 deletions github/actions_artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type ArtifactList struct {

// ListArtifacts lists all artifacts that belong to a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#list-artifacts-for-a-repository
// GitHub API docs: https://docs.github.com/rest/actions/artifacts#list-artifacts-for-a-repository
func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string, opts *ListOptions) (*ArtifactList, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/artifacts", owner, repo)
u, err := addOptions(u, opts)
Expand All @@ -76,7 +76,7 @@ func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string,

// ListWorkflowRunArtifacts lists all artifacts that belong to a workflow run.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#list-workflow-run-artifacts
// GitHub API docs: https://docs.github.com/rest/actions/artifacts#list-workflow-run-artifacts
func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, repo string, runID int64, opts *ListOptions) (*ArtifactList, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/runs/%v/artifacts", owner, repo, runID)
u, err := addOptions(u, opts)
Expand All @@ -100,7 +100,7 @@ func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, re

// GetArtifact gets a specific artifact for a workflow run.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#get-an-artifact
// GitHub API docs: https://docs.github.com/rest/actions/artifacts#get-an-artifact
func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Artifact, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)

Expand All @@ -120,7 +120,7 @@ func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, ar

// DownloadArtifact gets a redirect URL to download an archive for a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#download-an-artifact
// GitHub API docs: https://docs.github.com/rest/actions/artifacts#download-an-artifact
func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, followRedirects bool) (*url.URL, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v/zip", owner, repo, artifactID)

Expand All @@ -144,7 +144,7 @@ func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo strin

// DeleteArtifact deletes a workflow run artifact.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/artifacts#delete-an-artifact
// GitHub API docs: https://docs.github.com/rest/actions/artifacts#delete-an-artifact
func (s *ActionsService) DeleteArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/artifacts/%v", owner, repo, artifactID)

Expand Down
14 changes: 7 additions & 7 deletions github/actions_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type ActionsCacheListOptions struct {
//
// Permissions: must have the actions:read permission to use this endpoint.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#list-github-actions-caches-for-a-repository
// GitHub API docs: https://docs.github.com/rest/actions/cache#list-github-actions-caches-for-a-repository
func (s *ActionsService) ListCaches(ctx context.Context, owner, repo string, opts *ActionsCacheListOptions) (*ActionsCacheList, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/caches", owner, repo)
u, err := addOptions(u, opts)
Expand Down Expand Up @@ -107,7 +107,7 @@ func (s *ActionsService) ListCaches(ctx context.Context, owner, repo string, opt
//
// Permissions: You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the actions:write permission to use this endpoint.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-github-actions-caches-for-a-repository-using-a-cache-key
// GitHub API docs: https://docs.github.com/rest/actions/cache#delete-github-actions-caches-for-a-repository-using-a-cache-key
func (s *ActionsService) DeleteCachesByKey(ctx context.Context, owner, repo, key string, ref *string) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/caches", owner, repo)
u, err := addOptions(u, ActionsCache{Key: &key, Ref: ref})
Expand All @@ -127,7 +127,7 @@ func (s *ActionsService) DeleteCachesByKey(ctx context.Context, owner, repo, key
//
// Permissions: You must authenticate using an access token with the repo scope to use this endpoint. GitHub Apps must have the actions:write permission to use this endpoint.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
// GitHub API docs: https://docs.github.com/rest/actions/cache#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
func (s *ActionsService) DeleteCachesByID(ctx context.Context, owner, repo string, cacheID int64) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/caches/%v", owner, repo, cacheID)
req, err := s.client.NewRequest("DELETE", u, nil)
Expand All @@ -144,7 +144,7 @@ func (s *ActionsService) DeleteCachesByID(ctx context.Context, owner, repo strin
// Permissions: Anyone with read access to the repository can use this endpoint. If the repository is private, you must use an
// access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-a-repository
// GitHub API docs: https://docs.github.com/rest/actions/cache#get-github-actions-cache-usage-for-a-repository
func (s *ActionsService) GetCacheUsageForRepo(ctx context.Context, owner, repo string) (*ActionsCacheUsage, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/cache/usage", owner, repo)
req, err := s.client.NewRequest("GET", u, nil)
Expand All @@ -167,7 +167,7 @@ func (s *ActionsService) GetCacheUsageForRepo(ctx context.Context, owner, repo s
// Permissions: You must authenticate using an access token with the read:org scope to use this endpoint.
// GitHub Apps must have the organization_admistration:read permission to use this endpoint.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#list-repositories-with-github-actions-cache-usage-for-an-organization
// GitHub API docs: https://docs.github.com/rest/actions/cache#list-repositories-with-github-actions-cache-usage-for-an-organization
func (s *ActionsService) ListCacheUsageByRepoForOrg(ctx context.Context, org string, opts *ListOptions) (*ActionsCacheUsageList, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/cache/usage-by-repository", org)
u, err := addOptions(u, opts)
Expand Down Expand Up @@ -195,7 +195,7 @@ func (s *ActionsService) ListCacheUsageByRepoForOrg(ctx context.Context, org str
// Permissions: You must authenticate using an access token with the read:org scope to use this endpoint.
// GitHub Apps must have the organization_admistration:read permission to use this endpoint.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-an-organization
// GitHub API docs: https://docs.github.com/rest/actions/cache#get-github-actions-cache-usage-for-an-organization
func (s *ActionsService) GetTotalCacheUsageForOrg(ctx context.Context, org string) (*TotalCacheUsage, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/cache/usage", org)
req, err := s.client.NewRequest("GET", u, nil)
Expand All @@ -217,7 +217,7 @@ func (s *ActionsService) GetTotalCacheUsageForOrg(ctx context.Context, org strin
//
// Permissions: You must authenticate using an access token with the "admin:enterprise" scope to use this endpoint.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-an-enterprise
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest//rest/actions/cache#get-github-actions-cache-usage-for-an-enterprise
func (s *ActionsService) GetTotalCacheUsageForEnterprise(ctx context.Context, enterprise string) (*TotalCacheUsage, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/cache/usage", enterprise)
req, err := s.client.NewRequest("GET", u, nil)
Expand Down
8 changes: 4 additions & 4 deletions github/actions_oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ type OIDCSubjectClaimCustomTemplate struct {

// GetOrgOIDCSubjectClaimCustomTemplate gets the subject claim customization template for an organization.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-an-organization
// GitHub API docs: https://docs.github.com/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-an-organization
func (s *ActionsService) GetOrgOIDCSubjectClaimCustomTemplate(ctx context.Context, org string) (*OIDCSubjectClaimCustomTemplate, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/oidc/customization/sub", org)
return s.getOIDCSubjectClaimCustomTemplate(ctx, u)
}

// GetRepoOIDCSubjectClaimCustomTemplate gets the subject claim customization template for a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-a-repository
// GitHub API docs: https://docs.github.com/rest/actions/oidc#get-the-customization-template-for-an-oidc-subject-claim-for-a-repository
func (s *ActionsService) GetRepoOIDCSubjectClaimCustomTemplate(ctx context.Context, owner, repo string) (*OIDCSubjectClaimCustomTemplate, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/oidc/customization/sub", owner, repo)
return s.getOIDCSubjectClaimCustomTemplate(ctx, u)
Expand All @@ -49,15 +49,15 @@ func (s *ActionsService) getOIDCSubjectClaimCustomTemplate(ctx context.Context,

// SetOrgOIDCSubjectClaimCustomTemplate sets the subject claim customization for an organization.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-an-organization
// GitHub API docs: https://docs.github.com/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-an-organization
func (s *ActionsService) SetOrgOIDCSubjectClaimCustomTemplate(ctx context.Context, org string, template *OIDCSubjectClaimCustomTemplate) (*Response, error) {
u := fmt.Sprintf("orgs/%v/actions/oidc/customization/sub", org)
return s.setOIDCSubjectClaimCustomTemplate(ctx, u, template)
}

// SetRepoOIDCSubjectClaimCustomTemplate sets the subject claim customization for a repository.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-a-repository
// GitHub API docs: https://docs.github.com/rest/actions/oidc#set-the-customization-template-for-an-oidc-subject-claim-for-a-repository
func (s *ActionsService) SetRepoOIDCSubjectClaimCustomTemplate(ctx context.Context, owner, repo string, template *OIDCSubjectClaimCustomTemplate) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/oidc/customization/sub", owner, repo)
return s.setOIDCSubjectClaimCustomTemplate(ctx, u, template)
Expand Down
20 changes: 0 additions & 20 deletions github/actions_required_workflows.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ type RepoRequiredWorkflows struct {
}

// ListOrgRequiredWorkflows lists the RequiredWorkflows for an org.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#list-required-workflows
func (s *ActionsService) ListOrgRequiredWorkflows(ctx context.Context, org string, opts *ListOptions) (*OrgRequiredWorkflows, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows", org)
u, err := addOptions(url, opts)
Expand All @@ -90,8 +88,6 @@ func (s *ActionsService) ListOrgRequiredWorkflows(ctx context.Context, org strin
}

// CreateRequiredWorkflow creates the required workflow in an org.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#create-a-required-workflow
func (s *ActionsService) CreateRequiredWorkflow(ctx context.Context, org string, createRequiredWorkflowOptions *CreateUpdateRequiredWorkflowOptions) (*OrgRequiredWorkflow, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows", org)
req, err := s.client.NewRequest("POST", url, createRequiredWorkflowOptions)
Expand All @@ -109,8 +105,6 @@ func (s *ActionsService) CreateRequiredWorkflow(ctx context.Context, org string,
}

// GetRequiredWorkflowByID get the RequiredWorkflows for an org by its ID.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#list-required-workflows
func (s *ActionsService) GetRequiredWorkflowByID(ctx context.Context, owner string, requiredWorkflowID int64) (*OrgRequiredWorkflow, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/required_workflows/%v", owner, requiredWorkflowID)

Expand All @@ -129,8 +123,6 @@ func (s *ActionsService) GetRequiredWorkflowByID(ctx context.Context, owner stri
}

// UpdateRequiredWorkflow updates a required workflow in an org.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#update-a-required-workflow
func (s *ActionsService) UpdateRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID int64, updateRequiredWorkflowOptions *CreateUpdateRequiredWorkflowOptions) (*OrgRequiredWorkflow, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v", org, requiredWorkflowID)
req, err := s.client.NewRequest("PATCH", url, updateRequiredWorkflowOptions)
Expand All @@ -148,8 +140,6 @@ func (s *ActionsService) UpdateRequiredWorkflow(ctx context.Context, org string,
}

// DeleteRequiredWorkflow deletes a required workflow in an org.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#update-a-required-workflow
func (s *ActionsService) DeleteRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID int64) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v", org, requiredWorkflowID)
req, err := s.client.NewRequest("DELETE", url, nil)
Expand All @@ -160,8 +150,6 @@ func (s *ActionsService) DeleteRequiredWorkflow(ctx context.Context, org string,
}

// ListRequiredWorkflowSelectedRepos lists the Repositories selected for a workflow.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#list-selected-repositories-for-a-required-workflow
func (s *ActionsService) ListRequiredWorkflowSelectedRepos(ctx context.Context, org string, requiredWorkflowID int64, opts *ListOptions) (*RequiredWorkflowSelectedRepos, *Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v/repositories", org, requiredWorkflowID)
u, err := addOptions(url, opts)
Expand All @@ -183,8 +171,6 @@ func (s *ActionsService) ListRequiredWorkflowSelectedRepos(ctx context.Context,
}

// SetRequiredWorkflowSelectedRepos sets the Repositories selected for a workflow.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#sets-repositories-for-a-required-workflow
func (s *ActionsService) SetRequiredWorkflowSelectedRepos(ctx context.Context, org string, requiredWorkflowID int64, ids SelectedRepoIDs) (*Response, error) {
type repoIDs struct {
SelectedIDs SelectedRepoIDs `json:"selected_repository_ids"`
Expand All @@ -199,8 +185,6 @@ func (s *ActionsService) SetRequiredWorkflowSelectedRepos(ctx context.Context, o
}

// AddRepoToRequiredWorkflow adds the Repository to a required workflow.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#add-a-repository-to-a-required-workflow
func (s *ActionsService) AddRepoToRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID, repoID int64) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v/repositories/%v", org, requiredWorkflowID, repoID)
req, err := s.client.NewRequest("PUT", url, nil)
Expand All @@ -211,8 +195,6 @@ func (s *ActionsService) AddRepoToRequiredWorkflow(ctx context.Context, org stri
}

// RemoveRepoFromRequiredWorkflow removes the Repository from a required workflow.
//
// GitHub API docs: https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#add-a-repository-to-a-required-workflow
func (s *ActionsService) RemoveRepoFromRequiredWorkflow(ctx context.Context, org string, requiredWorkflowID, repoID int64) (*Response, error) {
url := fmt.Sprintf("orgs/%v/actions/required_workflows/%v/repositories/%v", org, requiredWorkflowID, repoID)
req, err := s.client.NewRequest("DELETE", url, nil)
Expand All @@ -223,8 +205,6 @@ func (s *ActionsService) RemoveRepoFromRequiredWorkflow(ctx context.Context, org
}

// ListRepoRequiredWorkflows lists the RequiredWorkflows for a repo.
//
// Github API docs:https://docs.github.com/en/rest/actions/required-workflows?apiVersion=2022-11-28#list-repository-required-workflows
func (s *ActionsService) ListRepoRequiredWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*RepoRequiredWorkflows, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/actions/required_workflows", owner, repo)
u, err := addOptions(url, opts)
Expand Down
Loading
Loading