8000 Add conditional workflow for test-poc by stianst · Pull Request #31406 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Add conditional workflow for test-poc - #31406

Merged
stianst merged 1 commit into
keycloak:mainfrom
stianst:testpoc-github-action
Jul 19, 2024
Merged

stianst merged 1 commit into
keycloak:mainfrom
stianst:testpoc-github-action

Conversation

@stianst
@stianst stianst commented Jul 18, 2024
Copy link
Copy Markdown
Contributor

Signed-off-by: stianst stianst@gmail.com

@stianst
stianst requested a review from a team as a code owner July 18, 2024 12:30
@stianst
stianst force-pushed the testpoc-github-action branch 2 times, most recently from f43629e to 80e5949 Compare July 18, 2024 13:30
@lhanusov lhanusov left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

here are few suggestions, otherwise it looks good to me 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will help to find Selenium Web elements properly:
ChromeOptions options = new ChromeOptions();
options.setImplicitWaitTimeout(Duration.ofMillis(1000));
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
return new ChromeDriver(options);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added to AbstractWebDriverSupplier

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as for chrome:
FirefoxOptions options = new FirefoxOptions();
options.setImplicitWaitTimeout(Duration.ofMillis(1000));
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
return new `FirefoxDriver(options);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added to AbstractWebDriverSupplier

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should be also defined as abstract in AbstractWebDriverSupplier

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, alias is optional, the default name for a supplier will be class.getSimpleName

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this should be also defined as abstract in AbstractWebDriverSupplier

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, alias is optional, the default name for a supplier will be class.getSimpleName

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Once Chrome and Firefox options are in place this can be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the difference between lifecycle and getDefaultLifecycle? In AbstractWebDriverSupplier is lifecycle and in AbstractKeycloakServerSupplier only getDefaultLifecycle.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Registry calls getLifeCycle(annotation) to get the life cycle a given instance should have, by default that will look for a method lifecycle on the annotation and use that value if present, otherwise it will call getDefaultLifeCycle. That basically means we can have a consistent approach to the lifecycle in annotations.

An alternative approach would just be to let the suppliers handle it all; and return the lifecycle from the annotation if present, or the default lifecycle. Then we'd only have getLifeCycle (without a default implementation) and remove getDefaultLifecycle.

Signed-off-by: stianst <stianst@gmail.com>
@stianst
stianst force-pushed the testpoc-github-action branch from 6d6de67 to abdc736 Compare July 19, 2024 08:24
Comment thread .github/workflows/ci.yml Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can omit the id if you are not referencing it anywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup, just copy/paste from elsewhere though. Having id/name makes the run a bit more readable though as the output with reusable actions is not very elegant without it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, I'd just add a human readable name to it and call it a day

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not a fan of my optionals? 😢

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They have their place, but found it easier to not have it in this case, as it's both simpler to just return null, and found the checks when setting the values simpler without optional stuff ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, it's a matter of personal preference I guess. However using optionals forces you to handle nullability, whereas nulls do not. Also:

serverConfig.adminUserName().ifPresentOrElse(
  username -> System.setProperty("keycloakAdmin", username),
  () -> System.getProperties().remove("keycloakAdmin")
);

return getValue(registry, annotation);
T getValue(InstanceContext<T, S> instanceContext);

default LifeCycle getLifeCycle(S annotation) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd do:

if (annotation == null) {
  return getDefaultLifecycle();
}

// The rest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Don't think it matters too much - down to personal preference I guess ;)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh for sure, you know how much I hate nesting, this is just a prime example of an early return pattern.

@stianst
stianst merged commit 7216967 into keycloak:main Jul 19, 2024
@stianst
stianst deleted the testpoc-github-action branch July 19, 2024 10:23
stianst added a commit to stianst/keycloak that referenced this pull request Jul 25, 2024
Signed-off-by: stianst <stianst@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0