diff --git a/.travis.yml b/.travis.yml index fc8680671b..89cb443597 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,46 +1,55 @@ +# DSpace's Travis CI Configuration +# Builds: https://travis-ci.com/github/DSpace/DSpace +# Travis configuration guide/validation: https://config.travis-ci.com/explore language: java -sudo: false +# TODO: Upgrade to Bionic dist: trusty - -env: - # Give Maven 1GB of memory to work with - - MAVEN_OPTS=-Xmx1024M +os: linux jdk: # DS-3384 Oracle JDK has DocLint enabled by default. # Let's use this to catch any newly introduced DocLint issues. - oraclejdk11 -## Should we run into any problems with oraclejdk8 on Travis, we may try the following workaround. -## https://docs.travis-ci.com/user/languages/java#Testing-Against-Multiple-JDKs -## https://github.com/travis-ci/travis-ci/issues/3259#issuecomment-130860338 -#addons: -# apt: -# packages: -# - oracle-java8-installer +# Define global environment variables (shared across all jobs) +env: + global: + # Suppress all Maven "downloading" messages in Travis logs (see https://stackoverflow.com/a/35653426) + # This also slightly speeds builds in Travis, as there is less logging + - HIDE_MAVEN_DOWNLOADS="-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" + # Give Maven 1GB of memory to work with + - MAVEN_OPTS="-Xmx1024M $HIDE_MAVEN_DOWNLOADS" + # Maven options which will skip ALL code validation checks. Includes skipping: + # - enforcer.skip => Skip maven-enforcer-plugin rules + # - checkstyle.skip => Skip all checkstyle checks by maven-checkstyle-plugin + # - license.skip => Skip all license header checks by license-maven-plugin + # - xml.skip => Skip all XML/XSLT validation by xml-maven-plugin + # (Useful for builds which don't need to repeat code checks) + - SKIP_CODE_CHECKS="-Denforcer.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -Dxml.skip=true" -before_install: - # Remove outdated settings.xml from Travis builds. Workaround for https://github.com/travis-ci/travis-ci/issues/4629 - - rm ~/.m2/settings.xml +# Create two jobs to run Unit & Integration tests in parallel. +# These jobs only differ in the TEST_FLAGS defined below, +# and otherwise share all the other configs in this file +jobs: + include: + - name: "Run Unit Tests & Check Code" + # NOTE: unit tests include deprecated REST API v6 (as it has unit tests) + env: TEST_FLAGS="-DskipUnitTests=false -Pdspace-rest" + - name: "Run Integration Tests" + # NOTE: skips code checks, as they are already done by Unit Test job + env: TEST_FLAGS="-DskipIntegrationTests=false $SKIP_CODE_CHECKS" -# Skip install stage, as we'll do it below -install: "echo 'Skipping install stage, dependencies will be downloaded during build and test stages.'" +# Skip 'install' process to save time. We build/install/test all at once in "script" below. +install: skip -# Build DSpace and run both Unit and Integration Tests -script: - # Summary of flags used (below): - # license:check => Validate all source code license headers - # -DskipTests=false => Enable DSpace Unit Tests - # -DskipITs=false => Enable DSpace Integration Tests - # -Pdspace-rest => Enable optional dspace-rest module as part of build - # -P !assembly => Skip assembly of "dspace-installer" directory (as it can be memory intensive) - # -B => Maven batch/non-interactive mode (recommended for CI) - # -V => Display Maven version info before build - # -Dsurefire.rerunFailingTestsCount=2 => try again for flakey tests, and keep track of/report on number of retries - - "mvn clean install license:check -DskipTests=false -DskipITs=false -Pdspace-rest -P !assembly -B -V -Dsurefire.rerunFailingTestsCount=2" +# Build DSpace and run configured tests (see 'jobs' above) +# Notes on flags used: +# -B => Maven batch/non-interactive mode (recommended for CI) +# -V => Display Maven version info before build +# -P-assembly => Disable build of dspace-installer in [src]/dspace/, as it can be memory intensive +# -Pcoverage-report => Enable aggregate code coverage report (across all modules) via JaCoCo +script: mvn install -B -V -P-assembly -Pcoverage-report $TEST_FLAGS -# After a successful build and test (see 'script'), send code coverage reports to coveralls.io -# These code coverage reports are generated by jacoco-maven-plugin (during test process above). -after_success: - # Run "verify", enabling the "coveralls" profile. This sends our reports to coveralls.io (see coveralls-maven-plugin) - - "cd dspace && mvn verify -P coveralls" +# After a successful build and test (see 'script'), send aggregate code coverage reports +# (generated by -Pcoverage-report above) to CodeCov.io +after_success: bash <(curl -s https://codecov.io/bash) diff --git a/README.md b/README.md index 32849d9e30..4842058c8b 100644 --- a/README.md +++ b/README.md @@ -90,33 +90,33 @@ run automatically by [Travis CI](https://travis-ci.com/DSpace/DSpace/) for all P * How to run both Unit Tests (via `maven-surefire-plugin`) and Integration Tests (via `maven-failsafe-plugin`): ``` - mvn clean test -DskipTests=false -DskipITs=false + mvn install -DskipUnitTests=false -DskipIntegrationTests=false ``` -* How to run just Unit Tests: +* How to run _only_ Unit Tests: ``` - mvn test -DskipTests=false + mvn test -DskipUnitTests=false ``` * How to run a *single* Unit Test ``` # Run all tests in a specific test class # NOTE: failIfNoTests=false is required to skip tests in other modules - mvn test -DskipTests=false -Dtest=[full.package.testClassName] -DfailIfNoTests=false + mvn test -DskipUnitTests=false -Dtest=[full.package.testClassName] -DfailIfNoTests=false # Run one test method in a specific test class - mvn test -DskipTests=false -Dtest=[full.package.testClassName]#[testMethodName] -DfailIfNoTests=false + mvn test -DskipUnitTests=false -Dtest=[full.package.testClassName]#[testMethodName] -DfailIfNoTests=false ``` -* How to run Integration Tests (requires enabling Unit tests too) +* How to run _only_ Integration Tests ``` - mvn verify -DskipTests=false -DskipITs=false + mvn install -DskipIntegrationTests=false ``` -* How to run a *single* Integration Test (requires enabling Unit tests too) +* How to run a *single* Integration Test ``` # Run all integration tests in a specific test class # NOTE: failIfNoTests=false is required to skip tests in other modules - mvn test -DskipTests=false -DskipITs=false -Dtest=[full.package.testClassName] -DfailIfNoTests=false + mvn install -DskipIntegrationTests=false -Dtest=[full.package.testClassName] -DfailIfNoTests=false # Run one test method in a specific test class - mvn test -DskipTests=false -DskipITs=false -Dtest=[full.package.testClassName]#[testMethodName] -DfailIfNoTests=false + mvn install -DskipIntegrationTests=false -Dtest=[full.package.testClassName]#[testMethodName] -DfailIfNoTests=false ``` * How to run only tests of a specific DSpace module ``` diff --git a/dspace-api/pom.xml b/dspace-api/pom.xml index 41ad956d82..7f5307a502 100644 --- a/dspace-api/pom.xml +++ b/dspace-api/pom.xml @@ -127,6 +127,36 @@ + + + org.codehaus.gmaven + groovy-maven-plugin + + + setproperty + initialize + + execute + + + + project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/'); + log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']); + + + + + + @@ -136,10 +166,6 @@ findbugs false - @@ -151,20 +177,19 @@ - + - test-environment + unit-test-environment false - skipTests + skipUnitTests false - @@ -184,53 +209,16 @@ - setupTestEnvironment + setupUnitTestEnvironment generate-test-resources unpack - - setupIntegrationTestEnvironment - pre-integration-test - - unpack - - - - - org.codehaus.gmaven - groovy-maven-plugin - - - setproperty - initialize - - execute - - - - project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/'); - log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']); - - - - - - - + maven-surefire-plugin @@ -245,8 +233,52 @@ + + + - + + + integration-test-environment + + false + + skipIntegrationTests + false + + + + + + + maven-dependency-plugin + + ${project.build.directory}/testing + + + org.dspace + dspace-parent + ${project.version} + zip + testEnvironment + + + + + + setupIntegrationTestEnvironment + pre-integration-test + + unpack + + + + + + maven-failsafe-plugin @@ -262,7 +294,6 @@ - @@ -332,7 +363,7 @@ jersey-hk2 ${jersey.version} - + commons-cli commons-cli diff --git a/dspace-server-webapp/pom.xml b/dspace-server-webapp/pom.xml index 96ed8bd2d3..edd4b55210 100644 --- a/dspace-server-webapp/pom.xml +++ b/dspace-server-webapp/pom.xml @@ -29,121 +29,6 @@ org.dspace.app.rest.Application - - - - test-environment - - false - - skipTests - false - - - - - - - maven-dependency-plugin - - ${project.build.directory}/testing - - - org.dspace - dspace-parent - ${project.version} - zip - testEnvironment - - - - - - setupTestEnvironment - generate-test-resources - - unpack - - - - setupIntegrationTestEnvironment - pre-integration-test - - unpack - - - - - - - - org.codehaus.gmaven - groovy-maven-plugin - - - setproperty - generate-test-resources - - - execute - - - - project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/'); - println("Initializing Maven property 'agnostic.build.dir' to: " + project.properties['agnostic.build.dir']); - - - - - - - - - maven-surefire-plugin - - - - - ${agnostic.build.dir}/testing/dspace/ - - true - ${agnostic.build.dir}/testing/dspace/solr/ - - - - - - - maven-failsafe-plugin - - - - ${agnostic.build.dir}/testing/dspace/ - - true - ${agnostic.build.dir}/testing/dspace/solr/ - - - - - - - - - @@ -187,9 +72,160 @@ + + + org.codehaus.gmaven + groovy-maven-plugin + + + setproperty + initialize + + execute + + + + project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/'); + log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']); + + + + + + + + + unit-test-environment + + false + + skipUnitTests + false + + + + + + + maven-dependency-plugin + + ${project.build.directory}/testing + + + org.dspace + dspace-parent + ${project.version} + zip + testEnvironment + + + + + + setupUnitTestEnvironment + generate-test-resources + + unpack + + + + + + + + maven-surefire-plugin + + + + + ${agnostic.build.dir}/testing/dspace/ + + true + ${agnostic.build.dir}/testing/dspace/solr/ + + + + + + + + + + + integration-test-environment + + false + + skipIntegrationTests + false + + + + + + + maven-dependency-plugin + + ${project.build.directory}/testing + + + org.dspace + dspace-parent + ${project.version} + zip + testEnvironment + + + + + + setupIntegrationTestEnvironment + pre-integration-test + + unpack + + + + + + + + maven-failsafe-plugin + + + + ${agnostic.build.dir}/testing/dspace/ + + true + ${agnostic.build.dir}/testing/dspace/solr/ + + + + + + + + + + diff --git a/dspace-services/pom.xml b/dspace-services/pom.xml index 1a355964d2..4b8003368b 100644 --- a/dspace-services/pom.xml +++ b/dspace-services/pom.xml @@ -18,21 +18,20 @@ - + - test-environment + unit-test-environment false - skipTests + skipUnitTests false - - + maven-surefire-plugin diff --git a/dspace/modules/additions/pom.xml b/dspace/modules/additions/pom.xml index fe2a181a40..5ec2a3d11c 100644 --- a/dspace/modules/additions/pom.xml +++ b/dspace/modules/additions/pom.xml @@ -26,6 +26,40 @@ ${basedir}/../../.. + + + + + org.codehaus.gmaven + groovy-maven-plugin + + + setproperty + initialize + + execute + + + + project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/'); + log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']); + + + + + + + + oracle-support @@ -42,20 +76,20 @@ - + + - test-environment + unit-test-environment false - skipTests + skipUnitTests false - @@ -75,50 +109,12 @@ - setupTestEnvironment + setupUnitTestEnvironment generate-test-resources unpack - - setupIntegrationTestEnvironment - pre-integration-test - - unpack - - - - - - - - org.codehaus.gmaven - groovy-maven-plugin - - - setproperty - generate-test-resources - - - execute - - - - project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/'); - println("Initializing Maven property 'agnostic.build.dir' to: " + project.properties['agnostic.build.dir']); - - - @@ -136,6 +132,60 @@ + + + + + + org.dspace + dspace-api + test-jar + test + + + + + + + integration-test-environment + + false + + skipIntegrationTests + false + + + + + + + maven-dependency-plugin + + ${project.build.directory}/testing + + + org.dspace + dspace-parent + ${project.version} + zip + testEnvironment + + + + + + setupIntegrationTestEnvironment + pre-integration-test + + unpack + + + + @@ -163,6 +213,7 @@ + + + org.codehaus.gmaven + groovy-maven-plugin + + + setproperty + initialize + + execute + + + + project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/'); + log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']); + + + + + - + - test-environment + unit-test-environment false - skipTests + skipUnitTests false - @@ -110,49 +138,12 @@ just adding new jar in the classloader - setupTestEnvironment + setupUnitTestEnvironment generate-test-resources unpack - - setupIntegrationTestEnvironment - pre-integration-test - - unpack - - - - - - - - org.codehaus.gmaven - groovy-maven-plugin - - - setproperty - initialize - - execute - - - - project.properties['agnostic.build.dir'] = project.build.directory.replace(File.separator, '/'); - log.info("Initializing Maven property 'agnostic.build.dir' to: {}", project.properties['agnostic.build.dir']); - - - @@ -171,6 +162,60 @@ just adding new jar in the classloader + + + + + + org.dspace + dspace-server-webapp + test-jar + test + + + + + + + integration-test-environment + + false + + skipIntegrationTests + false + + + + + + + maven-dependency-plugin + + ${project.build.directory}/testing + + + org.dspace + dspace-parent + ${project.version} + zip + testEnvironment + + + + + + setupIntegrationTestEnvironment + pre-integration-test + + unpack + + + + @@ -199,6 +244,7 @@ just adding new jar in the classloader + oracle-support diff --git a/dspace/pom.xml b/dspace/pom.xml index 58f1af66b5..00a6ec7fb2 100644 --- a/dspace/pom.xml +++ b/dspace/pom.xml @@ -148,30 +148,28 @@ - + settings generate the module-specific reports that are aggregated here. --> - test-coverage-report + coverage-report false - - skipTests - false - - + org.jacoco jacoco-maven-plugin aggregate-test-report - post-integration-test + verify report-aggregate @@ -182,8 +180,6 @@ **/jacoco-ut.exec **/jacoco-it.exec - - ${project.reporting.outputDirectory}/jacoco-aggregated @@ -231,50 +227,6 @@ - - - - coveralls - - false - - - - - org.eluder.coveralls - coveralls-maven-plugin - - - report-test-coverage - verify - - report - - - false - - ${project.reporting.outputDirectory}/jacoco-aggregated/jacoco.xml - - - ${project.parent.basedir}/dspace-api/src/main/java - ${project.parent.basedir}/dspace-api/target/generated-sources/annotations - ${project.parent.basedir}/dspace-oai/src/main/java - ${project.parent.basedir}/dspace-rdf/src/main/java - ${project.parent.basedir}/dspace-rest/src/main/java - ${project.parent.basedir}/dspace-services/src/main/java - ${project.parent.basedir}/dspace-server-webapp/src/main/java - ${project.parent.basedir}/dspace-sword/src/main/java - ${project.parent.basedir}/dspace-swordv2/src/main/java - - - - - - - - diff --git a/pom.xml b/pom.xml index f0b3158982..9e5cea3ba4 100644 --- a/pom.xml +++ b/pom.xml @@ -61,6 +61,17 @@ UTF-8 ${project.build.sourceEncoding} + + + + true + true + ${basedir} @@ -160,7 +171,7 @@ - + org.apache.maven.plugins maven-surefire-plugin @@ -177,13 +188,15 @@ true false + + ${skipUnitTests} - + maven-failsafe-plugin 2.22.2 @@ -198,10 +211,11 @@ true false + + ${skipIntegrationTests} - integration-test integration-test verify @@ -343,21 +357,6 @@ jacoco-maven-plugin 0.8.5 - - - org.eluder.coveralls - coveralls-maven-plugin - 4.3.0 - - - - javax.xml.bind - jaxb-api - ${jaxb-api.version} - - - @@ -475,42 +474,6 @@ - - - skiptests - - - - !skipTests - - - - true - - - - - - skipits - - - - !skipITs - - - - true - - - + - generate-test-env + test-environment - false - - skipTests - false - src/main/assembly/testEnvironment.xml @@ -571,12 +527,13 @@ + - measure-test-coverage + measure-unit-test-coverage false - skipTests + skipUnitTests false @@ -606,7 +563,29 @@ surefireJacoco + + + + + + + + measure-integration-test-coverage + + false + + skipIntegrationTests + false + + + + + + + org.jacoco + jacoco-maven-plugin +