apache / maven-mvnd

Apache Maven Daemon
https://maven.apache.org/
Apache License 2.0
2.94k stars 212 forks source link

mvnd for Github Actions #714

Open adamretter opened 2 years ago

adamretter commented 2 years ago

Is there a known/recommended way of using mvnd with GitHub Actions?

mthmulders commented 2 years ago

TL;DR: Not yet, as far as I know.

My $0.02: mvnd is most suitable for use on a developer machine, and less suitable for stateless build services like GitHub Actions. Why? Granted, you can benefit from parallel builds - but you don't need mvnd for that. The faster startup because of having the JVM and plugins 'hot' makes less sense when the container that runs your build gets destroyed after the build is completed.

gzm55 commented 2 years ago

some action or ci stage consist of more than one time of running maven, such as compute meta info, do reproducible check, prepare and preform a release, etc.

adamretter commented 2 years ago

We use multi-threaded Maven builds, so the output from Maven Daemon is much preferable as it sanitises the order.

We also have multiple steps within a step, so we may see some improvements perhaps, e.g.:

gnodet commented 2 years ago

mvnd is already used on GitHub actions, see: https://github.com/apache/camel/blob/main/.github/workflows/pr-build.yml and the installation action: https://github.com/apache/camel/blob/main/.github/actions/install-mvnd/action.yml

adamretter commented 2 years ago

@gnodet That's neat :-) Am I reading correctly that it looks like it only supports Linux? I was wondering if there was a desire from the apache/maven-mvnd project to publish a GitHub action to the GitHub marketplace for everyone to use - if so, perhaps your code could form the basis of that?

adamretter commented 1 year ago

@gnodet I have taken your action and extended it to support Linux, macOS, and Windows. I also incorporated the idea of using the Cache Action from @bowenliang123's PR. See https://github.com/eXist-db/exist/pull/4859/files#diff-fbabc4c33727e60ae5a15c24611fdf4f74126e38144bf0e0ef40b4499bdcc781

bowenliang123 commented 1 year ago

Hi, I would like to highlight some points in mvnd action used in apache/kyuubi's build script(https://github.com/apache/kyuubi/blob/master/build/mvnd) and ci workflow (https://github.com/apache/kyuubi/blob/master/.github/actions/setup-mvnd/action.yaml).

  1. the versions of mvn and mvnd are checked in runtime by scripts to make sure the embeded maven version is the same as mvn used solely (bump maven and mvnd at the same time)
  2. use maven properties to manage versions of mvn and mvnd, rather than manual setting in workflow alone
  3. with 1 and 2, the mvn and mvnd can be used on CI builds and local machines
  4. run mvn -v in the installing step to activate the mvnd daemon for faster startup response for later build steps
  5. already updated to maven 3.9.1 and mvnd 1.0.0-m6
adamretter commented 1 year ago

@bowenliang123 I have seen timeouts connecting to the mvnd daemon on Windows runners, would you know if your step (4) helps with that - https://github.com/eXist-db/exist/actions/runs/4653885083/jobs/8235148689?pr=4859

Run C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64\bin/mvnd -V -B -T 1C compile test-compile -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
  C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64\bin/mvnd -V -B -T 1C compile test-compile -DtrimStackTrace=false -D'dependency-check.skip' -D'license.skip'
  shell: C:\Program Files\PowerShell\7\pwsh.EXE -command ". '{0}'"
  env:
    MAVEN_OPTS: -XX:StartFlightRecording=maxsize=5g,disk=true,dumponexit=true,settings=default,filename=./ -DtrimStackTrace=false -D'maven.resolver.transport=wagon'
    DEV_JDK: 17
    JAVA_HOME: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\17.0.6-10\x64
    JAVA_HOME_17_X64: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\17.0.6-10\x64
    MVND_PLATFORM: windows
    MVND_ARCHITECTURE: amd64
    MVND_NAME: maven-mvnd-0.9.0-windows-amd64
Apache Maven Daemon (mvnd) 0.9.0 windows-amd64 native client (fa3cc5d66458a85[2](https://github.com/eXist-db/exist/actions/runs/4653885083/jobs/8235148689?pr=4859#step:5:2)6bd54[3](https://github.com/eXist-db/exist/actions/runs/4653885083/jobs/8235148689?pr=4859#step:5:3)de85566293113dacc[4](https://github.com/eXist-db/exist/actions/runs/4653885083/jobs/8235148689?pr=4859#step:5:4))
Terminal: org.jline.terminal.impl.DumbTerminal
Error: Exception in thread "main" org.mvndaemon.mvnd.common.DaemonException$ConnectException: Timeout waiting to connect to the Maven daemon.
Daemon id: 36b7860f
  no log file at: C:\Users\runneradmin\.m2\mvnd\registry\0.9.0\daemon-36b7860f.log
  output: C:\Users\runneradmin\.m2\mvnd\registry\0.9.0\daemon-36b7860f.out.log
----- Last  200 lines from daemon output - C:\Users\runneradmin\.m2\mvnd\registry\0.9.0\daemon-36b7860f.out.log -----
Starting daemon process: id = 36b7860f, workingDir = D:\a\exist\exist, daemonArgs: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\17.0.6-10\x64\bin\java.exe -classpath C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64\lib\mvnd-common-0.9.0.jar;C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64\lib\mvnd-agent-0.9.0.jar -javaagent:C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64\lib\mvnd-agent-0.9.0.jar -Dmvnd.home=C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64 -Dmaven.home=C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64 -Dmaven.conf=C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64\conf -Dmvnd.java.home=C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\17.0.6-10\x64 -Dlogback.configurationFile=C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64\conf\logging\logback-mvnd.xml -Dmvnd.id=36b7860f -Dmvnd.daemonStorage=C:\Users\runneradmin\.m2\mvnd\registry\0.9.0 -Dmvnd.registry=C:\Users\runneradmin\.m2\mvnd\registry\0.9.0\registry.bin -Dmvnd.socketFamily=inet -Dmvnd.home=C:\Users\runneradmin\AppData\Local\Temp\maven-mvnd-0.9.0-windows-amd64 -Djdk.java.options=--add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-opens java.base/sun.nio.fs=ALL-UNNAMED -Dmvnd.noDaemon=false -Dmvnd.debug=false -Dmvnd.debug.address=8000 -Dmvnd.idleTimeout=3h -Dmvnd.keepAlive=100ms -Dmvnd.extClasspath= -Dmvnd.coreExtensions= -Dmvnd.enableAssertions=false -Dmvnd.expirationCheckDelay=10s -Dmvnd.duplicateDaemonGracePeriod=10s -Dmvnd.socketFamily=inet org.mvndaemon.mvnd.common.MavenDaemonNOTE: Picked up JDK_JAVA_OPTIONS: --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.jar=ALL-UNNAMED --add-opens java.base/sun.nio.fs=ALL-UNNAMED
----- End of the daemon output -----

    at org.mvndaemon.mvnd.client.DaemonConnector.startDaemon(DaemonConnector.java:331)
    at org.mvndaemon.mvnd.client.DaemonConnector.connect(DaemonConnector.java:124)
    at org.mvndaemon.mvnd.client.DefaultClient.execute(DefaultClient.java:327)
    at org.mvndaemon.mvnd.client.DefaultClient.main(DefaultClient.java:1[5](https://github.com/eXist-db/exist/actions/runs/4653885083/jobs/8235148689?pr=4859#step:5:5)3)
Error: Process completed with exit code 1.