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

Prepare PCT for workflow-cps becoming a multi-module project #383

Merged
merged 6 commits into from
Nov 4, 2022

Conversation

dwnusbaum
Copy link
Member

@dwnusbaum dwnusbaum commented Nov 2, 2022

jenkinsci/workflow-cps-plugin#612 refactors workflow-cps into a multi-module project that contains groovy-cps and groovy-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.

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Comment on lines -50 to -52
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");
Copy link
Member Author

@dwnusbaum dwnusbaum Nov 2, 2022

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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)

Copy link
Member Author

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.

@@ -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?
Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Comment on lines 57 to 58
args.add("-pl");
args.add("plugin");
Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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?
Copy link
Member

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.

Comment on lines 57 to 58
args.add("-pl");
args.add("plugin");
Copy link
Member

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

@dwnusbaum dwnusbaum marked this pull request as ready for review November 3, 2022 17:41
@dwnusbaum dwnusbaum requested a review from a team as a code owner November 3, 2022 17:41
Copy link
Member

@jglick jglick left a 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?

Comment on lines -50 to -52
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");
Copy link
Member

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?

@dwnusbaum
Copy link
Member Author

Do you need this released?

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.

@jglick
Copy link
Member

jglick commented Nov 3, 2022

Releases would not matter for submodule usage. bom can accept an incremental version for pretesting; it would be a good idea to open a bom draft PR with this and jenkinsci/workflow-cps-plugin#612.

@dwnusbaum
Copy link
Member Author

See jenkinsci/bom#1553.

@dwnusbaum
Copy link
Member Author

@jglick jenkinsci/bom#1553 is passing with the antisamy-markup-formatter update, so I think this can be merged now.

@jglick jglick merged commit b2c7632 into jenkinsci:master Nov 4, 2022
@dwnusbaum dwnusbaum deleted the workflow-cps branch November 4, 2022 18:32
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.

2 participants