-
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
Implement support for actions artifacts #1414
Conversation
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
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, @Atorr. This is a good start but needs more work. Please see below.
github/actions_artifacts.go
Outdated
Name *string `json:"name,omitempty"` | ||
SizeInBytes *int64 `json:"size_in_bytes,omitempty"` | ||
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"` | ||
Expired *bool `json:"expired,omitempty"` |
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.
Can you please contact GitHub tech support at support@github.com and ask if they are actually sending the expired
field as a string
or as a JSON boolean
? Their docs show a string, but I would think they should be a boolean.
If they say these are indeed strings like the example shows, we may need to change this field to a *string
instead of a *bool
. You can report their reply back here, please.
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.
Sure thing.
github/actions_artifacts.go
Outdated
SizeInBytes *int64 `json:"size_in_bytes,omitempty"` | ||
ArchiveDownloadURL *string `json:"archive_download_url,omitempty"` | ||
Expired *bool `json:"expired,omitempty"` | ||
CreatedAt *string `json:"created_at,omitempty"` |
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 and the next field need to be of type *Timestamp
, please.
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.
Fixed.
github/actions_artifacts.go
Outdated
// ListWorkflowRunArtifacts lists all artifacts that belong to a workflow run. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/actions/artifacts/#list-workflow-run-artifacts | ||
func (s *ActionsService) ListWorkflowRunArtifacts(ctx context.Context, owner, repo string, runID int64, opt *ListOptions) (*ArtifactList, *Response, error) { |
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.
Can you please change opt
to opts
? I know the repo is inconsistent in this regard, and it is probably mostly my fault, but I would like to standardize on opts
because I think it makes more sense (as the type is ListOptions
).
So while I'm maintaining the repo, I figure I can ask for what I prefer. 😄 Thanks.
Maybe I should file an issue to change all "opt" to "opts" to make it consistent, then I don't have to ramble on and on like this. 😄 OK, done: #1415.
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.
#1417 is already merged, so please change this from opt
to opts
. Thank you!
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.
Fixed.
github/actions_artifacts.go
Outdated
// DownloadArtifact gets a redirect URL to download an archive for a repository. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/actions/artifacts/#download-an-artifact | ||
func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, archiveType string) (*Response, error) { |
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.
First, I was going to ask archiveType
to be renamed to archiveFormat
to match the GitHub documentation.
But then I realized that this value must be "zip"
and thought about hard-coding it.
However, since they made it a parameter, let's go ahead and rename the variable... and add a comment that its value currently must be "zip".
Thoughts?
I could actually go either way on this one since we have semver we could hard-code the value until it changes later, then bump the version.
Ah, now I see below on line 87 that you reject the call if the value is not "zip"... I'm heavily leaning toward removing the parameter and hard-coding the value in the URL path on line 85.
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 agree with hard-coding it. Will make the change.
Not sure where I got archiveType
, as I had intended to keep the naming the same as the documentation. 😅
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.
Fixed.
github/actions_artifacts.go
Outdated
return nil, err | ||
} | ||
|
||
location := String("") |
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.
No, I don't think this is what we want. We want to either return the URL or follow the redirect URL and return the actual ZIP file.
I think this whole function needs to be modeled after RepositoriesService.GetArchiveLink
located here:
https://github.com/google/go-github/blob/master/github/repos_contents.go#L242-L288
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.
Whoops I had meant to get rid of that. Will have it return the URL. Will model it after RepositoriesService.GetArchiveLink
.
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.
Fixed.
github/actions_artifacts_test.go
Outdated
client, _, _, teardown := setup() | ||
defer teardown() | ||
|
||
_, _, err := client.Actions.GetArtifact(context.Background(), "%", "r", 1) |
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.
What is this actually testing? I think it can be deleted.
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 saw other test files have cases to sanity check parameters (for example). This is just to make sure whatever is given for either the owner
or repo
can be URL-parsed. Looks like I forgot to switch the parameter for some of the test functions, thus why they look like duplicates. Given that, do you still prefer to have these tests removed?
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.
Given that, do you still prefer to have these tests removed?
I'm totally fine to keep the tests if they are not duplicates and they are testing something. 😄
Thanks!
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.
Sure thing.
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.
Fixed.
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.
OK, I'm not actually sure what changed here. Are all the tests actually testing something?
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.
Yes. These are sanity checks for the owner
and repo
parameters in each function. They should not longer be duplicates as they were all updated in my latest commit.
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.
Here is a link to each test case in the file view:
ListWorkflowRunArtifacts_invalidOwner
ListWorkflowRunArtifacts_invalidRepo
GetArtifact_invalidOwner
GetArtifact_invalidRepo
DownloadArtifact_invalidOwner
DownloadArtifact_invalidRepo
DeleteArtifact_invalidOwner
DeleteArtifact_invalidRepo
github/actions_artifacts_test.go
Outdated
client, _, _, teardown := setup() | ||
defer teardown() | ||
|
||
_, err := client.Actions.DownloadArtifact(context.Background(), "%", "r", 1, "zip") |
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.
What is this actually testing? I think it can be deleted.
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.
github/actions_artifacts_test.go
Outdated
client, _, _, teardown := setup() | ||
defer teardown() | ||
|
||
_, err := client.Actions.DownloadArtifact(context.Background(), "%", "r", 1, "zip") |
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.
What is this actually testing? I think it can be deleted.
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.
client, _, _, teardown := setup() | ||
defer teardown() | ||
|
||
_, err := client.Actions.DeleteArtifact(context.Background(), "%", "r", 1) |
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.
What is this actually testing? I think it can be deleted.
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.
github/actions_artifacts_test.go
Outdated
client, _, _, teardown := setup() | ||
defer teardown() | ||
|
||
_, err := client.Actions.DeleteArtifact(context.Background(), "%", "r", 1) |
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.
What is this actually testing? I think it can be deleted.
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.
github/actions_artifacts_test.go
Outdated
) | ||
}) | ||
|
||
opt := &ListOptions{Page: 2} |
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.
When you get a chance, could you please change opt
to opts
to be consistent with #1417?
(Here and anywhere else you find it in this PR, please.)
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.
Fixed.
github/actions_secrets.go
Outdated
// without revealing their encrypted values. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/actions/secrets/#list-secrets-for-a-repository | ||
func (s *ActionsService) ListSecrets(ctx context.Context, owner, repo string, opt *ListOptions) (*Secrets, *Response, error) { |
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.
When you get a chance, could you please change opt
to opts
to be consistent with #1417?
(Here and anywhere else you find it in this PR, please.)
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.
Fixed.
github/actions_secrets_test.go
Outdated
fmt.Fprint(w, `{"total_count":4,"secrets":[{"name":"A","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`) | ||
}) | ||
|
||
opt := &ListOptions{Page: 2, PerPage: 2} |
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.
When you get a chance, could you please change opt
to opts
to be consistent with #1417?
(Here and anywhere else you find it in this PR, please.)
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.
Fixed.
…ue-1399/actions-artifacts
@googlebot I consent. |
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
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, @Atorr!
LGTM.
Awaiting second LGTM before merging.
Thanks @gmlewis! I am still waiting to hear back from Github support regarding the Artifact expired field. I have not gotten any word back from them as of yet. Should we wait for their reply to merge? |
Ah, right... I had forgotten about this. Can you actually test out your implementation and see if a string is truly being sent like the documentation shows or if an unquoted JSON bool ( Actually, if a string ( Thanks, @Atorr! |
It looks as though the
|
Excellent! Full steam ahead then... GitHub can fix their documented examples when they get around to it and we can continue on. |
Friendly ping for a second LGTM - @gauntface or @wesleimp. |
@wesleimp or @martinssipenko - if you approve this, we could merge it. Thanks. |
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.
LGTM
Thank you, @martinssipenko! |
Support for the actions artifacts plus tests.
Relates to #1399 .