-
Notifications
You must be signed in to change notification settings - Fork 17
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
Workspace Gradle conversion #676
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #676 +/- ##
=============================================
+ Coverage 86.70% 86.78% +0.08%
Complexity 5399 5399
=============================================
Files 242 242
Lines 18288 18271 -17
Branches 2677 2674 -3
=============================================
Hits 15857 15857
+ Misses 1962 1945 -17
Partials 469 469 |
57a9e4c
to
081c3ea
Compare
Goal is to completely remove ant and make from the build and have a single build tool to rule them all, namely gradle Currently the build compiles but tests don't pass. Will also need a lot of doc updates.
…ile. Fix error in build.xml
b87b5b7
to
22ee5c3
Compare
.github/workflows/test.yml
Outdated
wired_tiger: 'false' | ||
ant_test: 'test_quick_coverage' | ||
mongo: ['3.6.13', '3.6.23'] | ||
test_cmd: ['test_quick_coverage', 'NoLongTests'] |
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.
test_quick_coverage
is the old ant tests, NoLongTests
is the new gradle tests
.github/workflows/test.yml
Outdated
export MINIO_VER='2019-05-23T00-29-34Z' | ||
export MONGO_VER='mongodb-linux-x86_64-${{matrix.mongo}}' | ||
# 3.6.13 has wired_tiger set to 'false', 3.6.23 has wired_tiger 'true' | ||
if [ "${{matrix.mongo}}" = "3.6.13" ]; then | ||
export WIRED_TIGER="false" | ||
else | ||
export WIRED_TIGER="true" | ||
fi | ||
export ARANGODB_VER=3.9.1 | ||
export ARANGODB_V=39 | ||
export HS_COMMIT=08e18379817e16db920501b66ba62b66598f506c | ||
export LOG_COMMIT=b549c557e3c519e0a55eadf7863a93db25cd6806 | ||
export SAMPLE_COMMIT=6813fb148e95db2b11db6eea04f4d1d45cbb7119 |
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.
put all the version stuff at the top so it's easy to change
.github/workflows/test.yml
Outdated
- name: build the war file (requires compileJava, javadoc) | ||
run: gradle war --info |
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.
This step is to ensure that the gradle build processes are working properly
.github/workflows/test.yml
Outdated
- name: upload jacoco report | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ matrix.test_cmd }} != 'test_quick_coverage' | ||
with: | ||
name: coverage${{matrix.test_cmd}}-${{matrix.mongo}}.exec | ||
path: build/ | ||
if-no-files-found: warn |
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.
temporarily add a step to make the build
directory available for download so that the test and coverage reports can be seen
} | ||
} | ||
|
||
tasks.withType(JavaCompile) { |
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.
Compilation
Run gradle compileJava
to compile the source code excluding tests for the workspace, or gradle compileTestJava
to compile everything. The results can be found in the directory build/classes/
.
destinationDirectory = file("$dist") | ||
} | ||
|
||
task buildJars { |
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.
Build the Jar files
The client and service jars can be built individually or can be built at the same time using the task gradle buildJars
.
build the client jar:
gradle clientJar
resulting file in dist/client/WorkspaceClient.jar
build the service jar:
gradle serviceJar
resulting file in dist/WorkspaceService.jar
to test:
run ant clean && ant compile
move or rename the resultant jar files in the dist
directory so that they don't get overwritten by the gradle task
run gradle clean buildJars
download jarcomp_03.jar from https://activityworkshop.net/software/jarcomp/index.html
compare each of the jar files to the ant equivalent, e.g.
java -jar jarcomp_03.jar ant_WorkspaceClient.jar dist/client/WorkspaceClient.jar
Client jar is almost identical apart from the manifest file
Service jar: the ant service jar contains the test classes and their resources, plus a couple of package-info.class files
} | ||
|
||
// by default, the files go into build/docs/javadoc | ||
tasks.javadoc { |
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.
Build the Javadocs
This task is run by the Gradle Java plugin. It compiles the main
source set, adds classes from the kbase-common
jar, and then generates javadocs for a select set of classes. The resulting documentation can be found in the directory build/docs/javadoc
.
to test:
run ant clean
run ant javadoc
, which will generate documentation in the directory docs/javadoc
run gradle clean javadoc
run diff -r docs build/docs
Note any differences
"https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-core/2.9.9/", | ||
"https://www.javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/2.9.9/" |
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.
updated URLs
} | ||
} | ||
|
||
tasks.war { |
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.
Build the war file
Building the war file involves compiling the main classes, generating documentation, packaging everything into the appropriate directories, and then generating the war file from that.
to test:
run ant clean && ant compile && ant buildwar
run gradle expandWar
to expand the resultant file into its constituent parts, and rename the directory war_contents
to something like ant_war_contents
run gradle clean buildWar
then expand the war file with gradle expandWar
The ant version of the war contains the test classes and dependencies.
❯ diff -r war_contents/WEB-INF/lib war_contents_ant/WEB-INF/lib
Only in war_contents_ant/WEB-INF/lib: arangodb-java-driver-6.7.2.jar
Only in war_contents_ant/WEB-INF/lib: byte-buddy-1.9.10.jar
Only in war_contents_ant/WEB-INF/lib: byte-buddy-agent-1.9.10.jar
Only in war_contents_ant/WEB-INF/lib: commons-collections-3.2.1.jar
Only in war_contents_ant/WEB-INF/lib: commons-lang-2.4.jar
Only in war_contents_ant/WEB-INF/lib: equalsverifier-3.1.10.jar
Only in war_contents_ant/WEB-INF/lib: java-semver-0.9.0.jar
Only in war_contents_ant/WEB-INF/lib: kbase-auth2test-0.2.4.jar
Only in war_contents_ant/WEB-INF/lib: mockito-core-3.0.0.jar
Only in war_contents_ant/WEB-INF/lib: objenesis-2.6.jar
Only in war_contents_ant/WEB-INF/lib: velocity-1.7.jar
Only in war_contents_ant/WEB-INF/lib: velocypack-2.4.0.jar
❯ diff -r war_contents/WEB-INF/classes/us war_contents_ant/WEB-INF/classes/us
Only in war_contents_ant/WEB-INF/classes/us/kbase/common: test
Only in war_contents_ant/WEB-INF/classes/us/kbase/typedobj/db: test
Only in war_contents_ant/WEB-INF/classes/us/kbase/typedobj: test
Only in war_contents_ant/WEB-INF/classes/us/kbase/workspace/listener: package-info.class
Only in war_contents_ant/WEB-INF/classes/us/kbase/workspace/modules: package-info.class
Only in war_contents_ant/WEB-INF/classes/us/kbase/workspace: test
} | ||
|
||
// test reports are saved to build/reports/tests/<testName> | ||
tasks.withType(Test) { |
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 Tests
Currently there is a single test task that runs all tests except the *LongTest
tests. To execute it, run gradle testNoLongTests
(or gradle coverageNoLongTests
to generate coverage files). HTML test results are saved to the directory build/reports/tests/<testName>
and coverage data (in CSV, XML, and HTML formats) goes to build/reports/jacoco/<taskName>
.
to test:
download one of the coverageNoLongTests-3.6.n3
archives from GitHub Actions to see an example of the resulting build directory and the test results/coverage.
NOTE
Gradle is currently set to fork for each test run as there are two tests that fail if that setting is NOT on. To be continued!
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.
Assuming I'm reading this correctly we'll def want a target that runs all the tests, long tests included
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 have it set up so that in GitHub Actions, we would run the long tests, the mongo tests, and the quick tests (all tests minus long tests and mongo tests) in parallel, and then combine the coverage data. Locally it would be possible to run any of those sets on their own or all tests.
executionData(testNoLongTests) | ||
} | ||
|
||
task createScript { |
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.
Create the CLI script
Run the gradle command gradle createScript
to generate the CLI script.
to test:
run ant clean && ant script
rename the resulting file (update_workspace_database_schema
)
run gradle clean createScript
replace :
with \n
and sort lines in both files:
sed 's/:/\n/g' update_workspace_database_schema_ant | sort > script_ant.txt
sed 's/:/\n/g' update_workspace_database_schema | sort > script_gradle.txt
diff the two files
diff script_ant.txt script_gradle.txt
1d0
<
@@ -242,7 +242,8 @@ | |||
<javadoc access="protected" author="false" classpathref="compile.classpath" | |||
destdir="${doc}" nodeprecated="false" nodeprecatedlist="false" | |||
noindex="false" nonavbar="false" notree="false" | |||
source="11" splitindex="true" use="true" version="true"> | |||
source="11" splitindex="true" use="true" Windowtitle="Workspace 0.14.1 API" |
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.
add in the window title to make the output from this command more similar to the settings that that the gradle javadoc task uses.
I'd like to review at a point when The other thing that, IMO, needs to be in the first PR is that test classes and individual tests need to be runnable in Eclipse (or whatever). Right now that's done by maintaining the
I already did this in 6bde7be ? |
940c1a8
to
da6ec77
Compare
@MrCreosote which |
I think the deploy endpoints can all go, as well as the undeploy endpoint. The rest need to stay (or at least their functionality needs to stay) but they might be able to be simplified, possibly? Obviously test that the docker image can build and run without those endpoints though. In particular any |
useJUnit() | ||
systemProperty "test.cfg", testConfig | ||
maxHeapSize = "3G" | ||
testLogging { |
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.
test logging
add gradle to dockerfile use gradle for GHA tests/builds remove unused server admin scripts
add in workflow caching adding minio since it is not always available from minio server fix incorrect if statements
8ef4bc1
to
cefbfec
Compare
To make things easier, I intend to do the conversion in stages -- it can either be done in separate PRs or as commits in this PR.
Proposed steps:
1: recapitulate ant tasks. (this one)
2: replace local archives with jars from Maven.
3: trim down dependency list as some deps are supplied as part of other deps
4. ensure that test files are not being included in the ServiceJar build (as is currently the case with the ant-built jar)
5. split out tests into Mongo vs non-Mongo tests
6. debug test failures when junit is not set to fork each process
7. etc.
I've been writing up some documentation as I've gone along; I've included it as comments on this PR and will move it all into the appropriate doc files.