-
Notifications
You must be signed in to change notification settings - Fork 724
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 GHWorkflow, GHWorkflowRun and associated payloads #1064
Conversation
@bitwiseman interested with your wisdom on this one. I added some comments for the big remaining issues from my point of view. |
@bitwiseman ok, the situation is a bit better: I was able to get the tests to run in both modes. So that lets us with the 2 design decisions:
Let me know your take on these two and I'll adjust. In the meantime, I will work on the payloads. |
No, it's fine, leave it.
I think you could add a bridge method annotation to bring consistency. And we don't need to create class - we can do the same as EnumUtils.getEnum(Class, String, E). We can't update the version of commons-lang due to downstream limitations, but we can use the same behavior. I would even be fine with not having a Final call is yours. Either is acceptable and can be iterated in a future release. |
Most of the actions are implemented but not all. Looks like a good first step.
Provide bridge methods for compatibility.
I implemented a method similar to this except it returns null when the value is null. I used it for I just pushed these changes. I'm going to work on the payloads next, and also take care of the pull requests potentially attached. In passing, I'll fix a bug in |
@bitwiseman I implemented the payloads in my last commit. From my side, this PR is ready to go. I'll let you review it. There's still something we need to fix with pull requests for check suites and workflow runs but I'll do it in a separate PR once this is in as it's a preexisting issue and a totally different discussion. |
Also, is there a way to test bridge methods? |
Not really. There is a test to verify they are created, but executing them no. ... I suppose we could add a facility for it using reflection? |
|
||
public final class EnumUtils { | ||
|
||
public static <E extends Enum<E>> E getEnum(Class<E> enumClass, String value, E defaultEnum) { |
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.
JavaDoc needed.
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.
Added.
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.
Great work on this! The only remaining feedback I have is on tests. Sorry for the multiple rounds, this is the last one and I'll try to do a better job of batching for future PRs.
workflow.dispatch("main"); | ||
workflow.dispatch("main", Collections.singletonMap("parameter", "value")); | ||
|
||
// if we implement the logs API at some point, it might be a good idea to validate all this |
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.
With wiremock you can verify that specific requests were made. Would that work for validation?
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 you have an example in the code base?
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 haven't used it in this project.
Here's the docs for it: http://wiremock.org/docs/verifying/
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.
Thanks for the pointer. Done.
Awaitility.await().atLeast(atLeast).pollInterval(pollInterval).atMost(atMost).until(() -> { | ||
List<GHWorkflowRun> workflowRuns = getLatestWorkflowRuns(MAIN_BRANCH, Status.IN_PROGRESS); | ||
for (GHWorkflowRun workflowRun : workflowRuns) { | ||
if (workflowRun.getName().equals(SLOW_WORKFLOW_NAME) | ||
&& workflowRun.getId() > latestPreexistingWorkflowRunId) { | ||
assertNotNull(workflowRun.getId()); | ||
|
||
workflowRun.cancel(); | ||
cancelledWorkflowRunId = workflowRun.getId(); | ||
return true; | ||
} | ||
} | ||
return false; | ||
}); |
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.
A few requests applying to all the await
sections:
- I'd prefer if the
until
only polled for the state change and the asserts are called after, outside theuntil
. - Let's use
getGitHubBeforeAfter()
for polling. That way the tests don't need to record the polling. That way when running CI, the test do effectively no waiting. - With (2) we can remove the special polling interval values in
setup()
. Maybe use a fibonacci polling interval with milliseconds? Recording will burn a few extra requests but they won't be recorded.
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.
- yeah that was my inclination as well first and I thought it would be better to reduce the number of API calls. I changed it. I agree it's more readable this way.
- ah, yes, good idea, I was looking for a way to do exactly that
- I removed the polling when we don't use a proxy. I tried the fibonacci thingy but it doesn't work very well, don't know why but it was just running forever and I don't really have the cycles to dig more into it. Using a fixed poll interval works so I am sticking with that.
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.
Thanks, looks great. Bummer about the polling interval, but oh well.
We don't record the polling requests and we avoid any polling when not recording.
@bitwiseman I think I addressed all your comments. I would be interested in you releasing a new version once this is in so that I can implement this in my Quarkus GitHub App framework for Jeff! |
@gsmet Great work! I'll release today. |
@bitwiseman thanks for the reviews and release! Glad we could get this one in. |
This is a draft for now.
I have several questions and there is at least one big issue with the tests.