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

Implement support for actions workflow jobs #1421

Merged
merged 13 commits into from
Feb 27, 2020

Conversation

joshuabezaleel
Copy link
Contributor

This PR adds support for managing the most recent update of Action Workflow Jobs.

Relates to: #1399

By the way, there are several things that I am still not sure of:

  • The action in the original GitHub documentation is "List workflow job logs" thus I name the function ListWorkflowJobLogs but since it basically retrieve a URL to download a text file that contain the logs I think it would be better to name it GetLogsFileURL.
  • I am still not sure of perhaps how go-github would implement this particular function since the URL of the file is in the header of the response. Do you have any example of other functions that implement this kind of response?

Thank you very much beforehand 🙂

@googlebot googlebot added the cla: yes Indication that the PR author has signed a Google Contributor License Agreement. label Feb 10, 2020
@joshuabezaleel
Copy link
Contributor Author

Apparently I pasted the wrong test, I am sorry.

@gmlewis
Copy link
Collaborator

gmlewis commented Feb 10, 2020

Thanks, @joshuabezaleel!

By the way, there are several things that I am still not sure of:

Yes, I think this one should probably be treated like we treat GetArchiveLink where the client can either get the URL or get the actual text file using the followRedirects bool parameter.

Does that make sense?

@joshuabezaleel
Copy link
Contributor Author

Yes, the function that you mentioned was really helpful, thank you very much @gmlewis !! Looking forward to your review 🙂

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @joshuabezaleel!

One tiny nit, otherwise LGTM.

Were you able to try this out to see if it worked?
I ask because I know we recently added a different followRedirectsClient mechanism to RepositoriesService.DownloadReleaseAsset and am not sure which is the better implementation, actually.

If it turns out you try this one and it doesn't work, then maybe we could try the other mechanism which I know was tested and might be a better solution.

Either way, awaiting second LGTM before merging.

return job, resp, nil
}

// GetWorkflowJobLogs gets a redirect URL to a download a plain text file of logs for a workflow job.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: s/to a download/to download/

@gmlewis gmlewis requested a review from gauntface February 11, 2020 02:55
@joshuabezaleel
Copy link
Contributor Author

I tried to use the ActionsService from a constructed client to try it but I couldn't find it. Do you have any idea why? .... 😕
imageedit_3_3260833938

@marcofranssen
Copy link

@joshuabezaleel

probably you need to do

go get github.com/google/go-github@thebranch-containing-the-code

or you should add a replace in your go.mod

replace github.com/google/go-github => ./the-path-to-your-checkout-of-the-repo-branch

@joshuabezaleel
Copy link
Contributor Author

@marcofranssen The main.go that I wrote to try the ActionsService is in the go-github folder itself. And I already fetch the latest commits that contains the updates of including ActionsService when initiating a new Client so that should already be included though. 😕

@gmlewis
Copy link
Collaborator

gmlewis commented Feb 11, 2020

Can you please start with a super-simple example like this: #1176 (comment)
and tweak it to call client.Actions.YourMethodYouWantToTest and share it here, and we can help you debug it?

I'm betting that you are trying to call client.ActionsService instead of client.Actions and that is the problem.

}

// Job represents a repository action workflow job.
type Job struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I think about this, the more I'm thinking that all fields in Job and Step should be pointers and add the ,omitempty tag, just for consistency with the rest of the repo.

I'd like to hear what @gauntface thinks about this, specifically.

Technically, I don't think they are needed... but it might be an odd experience for a user of this repo to find this pair of structs not follow the pattern set by the rest of the repo.


// Jobs represents a slice of repository action workflow job.
type Jobs struct {
TotalCount int `json:"total_count"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here:

TotalCount *int `json:"total_count,omitempty"`

StartedAt Timestamp `json:"started_at"`
CompletedAt Timestamp `json:"completed_at"`
Name string `json:"name"`
Steps []*Step `json:"steps"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps would be the only exception and is fine as it is currently written, being a slice of pointers.

)

// Step represents a single task from a sequence of tasks of a job.
type Step struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In light of #1429, #79, #45, and #19, I'm going to make the executive decision and say that these two structs (Job and Step) should all use pointers.

In addition, please rename Step to be TaskStep to make it more clear when seeing it by itself.

And let's please change Job to WorkflowJob to make it more descriptive as well.

Thank you!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Friendly ping, @joshuabezaleel to switch these fields to pointers, please.

@gmlewis
Copy link
Collaborator

gmlewis commented Feb 27, 2020

Thank you, @joshuabezaleel.
Please run go generate ./... again and then the tests should pass.

@joshuabezaleel
Copy link
Contributor Author

Hi @gmlewis , I ran the go generate ./... command but I think it still yield error on the go test and go vet command 😕

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that if you accept my two suggestions, that the tests should be fixed.

I'm going to go ahead and try it out.

github/actions_workflow_jobs_test.go Outdated Show resolved Hide resolved
github/actions_workflow_jobs_test.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those commits fixed it. LGTM.

@wesleimp or @martinssipenko - if you could approve please, we can go ahead and merge this.

Copy link
Contributor

@martinssipenko martinssipenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joshuabezaleel
Copy link
Contributor Author

Truly sorry for the hassle and thank you for fixing it up for me, @gmlewis ! Truly appreciate it 🙂

@gmlewis
Copy link
Collaborator

gmlewis commented Feb 27, 2020

Truly sorry for the hassle and thank you for fixing it up for me, @gmlewis ! Truly appreciate it slightly_smiling_face

No problem, @joshuabezaleel - you did a great job, and it was my fault for waffling on the pointers. 😄

Thank you, @martinssipenko!
Merging.

@gmlewis gmlewis merged commit 300f887 into google:master Feb 27, 2020
n1lesh pushed a commit to n1lesh/go-github that referenced this pull request Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indication that the PR author has signed a Google Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants