-
-
Notifications
You must be signed in to change notification settings - Fork 15
Speed up the gradle test invocation #37
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# === Build builder image === | ||
|
||
FROM gradle:6.8.3-jdk11 AS build | ||
FROM gradle:7.1-jdk11 AS build | ||
|
||
WORKDIR /home/builder | ||
|
||
|
@@ -20,7 +20,7 @@ RUN gradle build | |
|
||
# === Build runtime image === | ||
|
||
FROM gradle:6.8.3-jdk11 | ||
FROM gradle:7.1-jdk11 | ||
WORKDIR /opt/test-runner | ||
|
||
# Copy binary and launcher script | ||
|
@@ -30,4 +30,9 @@ COPY --from=build /home/builder/autotest-runner.jar ./ | |
# Copy cached dependencies | ||
COPY --from=build /home/gradle /home/gradle | ||
|
||
RUN pkill -f '.*GradleDaemon.*' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is one stopped |
||
RUN rm -rf ~/.gradle/daemon | ||
|
||
ENV GRADLE_OPTS="--add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xms256m -Xmx2048M -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is one core change, basically, the This is ugly and weak (especially maintenance-wise) but is the only thing that actually works. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, my investigations pointed out that no daemon was used, but I didn't know how to fix it. Great work! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @andreaTP It looks like in the above changes you're killing all Gradle daemons, right? If so, would a running Gradle daemon that can be re-used when running the tests be faster than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
do you mind elaborating or providing a link? might be interesting to investigate further this path! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! For Purescript, we have a regular exercise https://github.com/exercism/purescript-test-runner/tree/main/pre-compiled that we copy into the Docker image and then build/compile https://github.com/exercism/purescript-test-runner/blob/main/Dockerfile#L14. Doing a build/compile forces the Docker container to at least have loaded all the infrastructure once. Whether that is beneficial depends on the runtime that is used. I tried using this approach with the Java test runner too, as I hoped that being able to re-use an existing Daemon that had already done some work might allow things to be sped up later. I couldn't get the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
correct but it doesn't seem to produce great results ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, that could be because there actually isn't any Gradle daemon already running, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct |
||
|
||
ENTRYPOINT ["sh", "/opt/test-runner/bin/run.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,7 @@ cp -R $input_folder/* . | |
|
||
find . -mindepth 1 -type f | grep 'Test.java' | xargs -I file sed -i "s/@Ignore(.*)//g;s/@Ignore//g;" file | ||
|
||
java -jar /opt/test-runner/autotest-runner.jar $problem_slug | ||
echo "test {\n maxHeapSize = '2G'\n reports.html.required = false\n}" >> build.gradle | ||
timeout 20 gradle test --offline --no-daemon --warning-mode=none --no-watch-fs --console=plain 2> gradle-test.err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved the external process execution from Java to the command line for a couple of reasons:
I think that I prefer this here, but I can revert this change if required, not fussy about it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think those are all good arguments in favor of running this in bash. |
||
java -jar /opt/test-runner/autotest-runner.jar $? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
mv results.json $output_folder |
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.
Align version with the version used in the exercises