-
Notifications
You must be signed in to change notification settings - Fork 55
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
Prepare PCT for workflow-cps becoming a multi-module project #383
Conversation
System.out.println("Compile plugin log in " + path); | ||
File compilePomLogfile = new File(path + "/compilePluginLog.log"); | ||
runner.run(mavenConfig, path, compilePomLogfile, "clean", "process-test-classes", "-Dmaven.javadoc.skip"); |
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.
As far as I can tell, this was just a bug in #247 which caused sse-gateway
and workflow-cps
to be compiled twice. My understanding is that if you want to override the default compilation from a hook, you need to add the OVERRIDE_DEFAULT_COMPILE
flag to the info
map passed to action
.
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.
Did you check that sse-gateway
is still OK?
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, but that was before 6f446ae. I confirmed that previously it got compiled twice. I will check again though. I'm not really sure why this hook even exists, because I don't think these are the only two plugins that use frontend-maven-plugin
, and a quick look at #247 did not clarify the underlying issue.
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 am retesting sse-gateway
now, but NPM is extremely slow, maybe because sse-gateway
is using very old versions of node
and npm
and so everything is running via Rosetta on my machine)
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 confirmed that sse-gateway
still works.
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/WorkflowCpsHooks.java
Outdated
Show resolved
Hide resolved
@@ -117,7 +117,11 @@ private MavenRunner.Config getMavenConfig(PluginCompatTesterConfig config) throw | |||
} | |||
|
|||
private void compile(MavenRunner.Config mavenConfig, File path, File localCheckoutDir, String parentFolder, String pluginName) throws PomExecutionException, IOException { | |||
if (isSnapshotMultiParentPlugin(parentFolder, path, localCheckoutDir)) { | |||
if (pluginName.equals("workflow-cps")) { | |||
// TODO: Why does the following condition not work for workflow-cps? Is it only broken for local checkouts? |
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 am not sure about this. Maybe it is just the case that -localCheckoutDir
has never worked correctly with multi-module projects? I will look into this a bit more to understand if this is something that should be more general or if there is something that should be changed in the isSnapshotMultiParentPlugin
and/or getMavenModule
methods.
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.
Maybe it is just the case that
-localCheckoutDir
has never worked correctly with multi-module projects?
I would not be surprised. Everything about MultiParentCompileHook
is dumb. This part of PCT should be rewritten so that no hooks are needed—should collect repos corresponding to selected plugins, then run mvn
commands from repo root.
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, yeah it looks like this is a bit of a mess. You need this and WorkflowCpsHooks$OnlyTestPluginHook
when you are using -localCheckoutDir
. However, when you do not use -localCheckoutDir
, this new code and OnlyTestPluginHook
make the PCT fail and must be skipped!
My takeaway is that -localCheckoutDir
does not work for multi-module projects right now. Since that option is not used in typical workflows, I will revert the changes related to it and just file an issue about the behavior of -localCheckoutDir
with multi-module projects.
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.
6f446ae simplifies things to only work when not using -localCheckoutDir
.
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.
#384 tracks the -localCheckoutDir
issue.
args.add("-pl"); | ||
args.add("plugin"); |
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.
Running groovy-cps's tests is quick and relatively harmless, but since it doesn't have plugin dependencies, testing it in the PCT is not very useful. The main reason for this is that without it, testing groovy-cps
fails because groovy-cps-dgm-builder
cannot be found in the local Maven repository due to jenkinsci/workflow-cps-plugin@1b01482. Another option would be be to modify the goal to install
and recompile the plugin and the libraries a second time so that we can test everything.
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.
modify the goal to
install
I thought that was what you were already doing in this PR. 🤷 whatever works
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.
The PCT compiles the plugin with one invocation of Maven and then runs tests separately with another. Compilation typically runs process-test-classes
, but for multi-module projects (and workflow-cps
as of the new logic in this PR) runs install
. Tests are normally run using individual test goals like surefire:test
(and this PR tweaks that invocation to add -pl plugin
for workflow-cps
). I am not sure why compilation and testing is split like this, but I do not work with the PCT very much.
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 am not sure why compilation and testing is split like this
It is mostly a relic of the old mode of PCT predating jenkinsci/maven-hpi-plugin#336. The idea was to be able to mvn test
or mvn install
in one pass with suitable properties. Unfortunately for technical reasons you need to define jenkins.version
during at least the test phase, meaning that the compilation would also be against the new version, which we do not want. So we would want a PCT run (incl. multimodule) to look like
mvn -Pquick-build install
mvn -Djenkins.version=… -Dwhatever.war.arg=… hpi:resolve-test-dependencies surefire:test
(so that the second command does not recompile anything).
@@ -117,7 +117,11 @@ private MavenRunner.Config getMavenConfig(PluginCompatTesterConfig config) throw | |||
} | |||
|
|||
private void compile(MavenRunner.Config mavenConfig, File path, File localCheckoutDir, String parentFolder, String pluginName) throws PomExecutionException, IOException { | |||
if (isSnapshotMultiParentPlugin(parentFolder, path, localCheckoutDir)) { | |||
if (pluginName.equals("workflow-cps")) { | |||
// TODO: Why does the following condition not work for workflow-cps? Is it only broken for local checkouts? |
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.
Maybe it is just the case that
-localCheckoutDir
has never worked correctly with multi-module projects?
I would not be surprised. Everything about MultiParentCompileHook
is dumb. This part of PCT should be rewritten so that no hooks are needed—should collect repos corresponding to selected plugins, then run mvn
commands from repo root.
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/MultiParentCompileHook.java
Outdated
Show resolved
Hide resolved
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/WorkflowCpsHooks.java
Outdated
Show resolved
Hide resolved
args.add("-pl"); | ||
args.add("plugin"); |
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.
modify the goal to
install
I thought that was what you were already doing in this PR. 🤷 whatever works
…ust use AbstractMultiParentHook
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.
Looks fine. Do you need this released?
System.out.println("Compile plugin log in " + path); | ||
File compilePomLogfile = new File(path + "/compilePluginLog.log"); | ||
runner.run(mavenConfig, path, compilePomLogfile, "clean", "process-test-classes", "-Dmaven.javadoc.skip"); |
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.
Did you check that sse-gateway
is still OK?
plugins-compat-tester/src/main/java/org/jenkins/tools/test/hook/WorkflowCpsHook.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Jesse Glick <[email protected]>
I think so? I know of one usage of this repository as a Git submodule, so IDK if releases matter in that context. Not sure about https://github.com/jenkinsci/bom. |
Releases would not matter for submodule usage. |
See jenkinsci/bom#1553. |
@jglick jenkinsci/bom#1553 is passing with the |
jenkinsci/workflow-cps-plugin#612 refactors
workflow-cps
into a multi-module project that containsgroovy-cps
andgroovy-cps-dgm-builder
. Without any other changes, this breaks the PCT, so this PR tries to keep things working.Once jenkins-infra/repository-permissions-updater#2917 is merged we will be able to test this without
-localCheckoutDir
to make sure things still work correctly.