From fcb15583d9f568e492fbca0b2c2c5e393adc0fca Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Mon, 23 Nov 2020 16:10:58 -0600 Subject: [PATCH 1/7] Add CI to GitHub --- .github/workflows/ci.yml | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..c8139a6dc3 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,62 @@ +# DSpace Continuous Integration via GitHub Actions +# Concepts borrowed from +# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-java-with-maven +name: CI + +# Run this CI only for pushes / PRs to main branch +on: + push: + branches: main + pull_request: + branches: main + +jobs: + build: + runs-on: ubuntu-latest + env: + # Give Maven 1GB of memory to work with + # Suppress all Maven "downloading" messages in Travis logs (see https://stackoverflow.com/a/35653426) + # This also slightly speeds builds, as there is less logging + MAVEN_OPTS: "-Xmx1024M -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn" + strategy: + # Create a matrix of two separate configurations for Unit vs Integration Tests + # This will ensure those tasks are run in parallel + matrix: + include: + # NOTE: Unit Tests include deprecated REST API v6 (as it has unit tests) + - type: "Unit Tests" + mvnflags: "-DskipUnitTests=false -Pdspace-rest" + # NOTE: ITs skip all code validation checks, as they are already done by Unit Test job. + # - 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 + - type: "Integration Tests" + mvnflags: "-DskipIntegrationTests=false -Denforcer.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -Dxml.skip=true" + # Do NOT exit immediately if one matrix job fails + # This ensures ITs continue running even if Unit Tests fail, or visa versa + fail-fast: false + # These are the actual CI steps to perform per job + steps: + - name: Checkout codebase + # https://github.com/actions/checkout + uses: actions/checkout@v2 + - name: Install JDK 11 + # https://github.com/actions/setup-java + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache Maven dependencies + # https://github.com/actions/cache + uses: actions/cache@v2 + with: + # Cache entire ~/.m2/repository + path: ~/.m2/repository + # Cache key is hash of all pom.xml files. Therefore any changes to POMs will invalidate cache + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: ${{ runner.os }}-maven- + # Run parallel Maven builds based on the above 'strategy.matrix' + - name: Run Maven ${{ matrix.type }} + env: + TEST_FLAGS: ${{ matrix.mvnflags }} + run: mvn install -B -V -P-assembly -Pcoverage-report $TEST_FLAGS From 97a14fb5a027408bb30f4dffde798f30642fab65 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 24 Nov 2020 08:57:59 -0600 Subject: [PATCH 2/7] Send coverage reports to Codecov. Move comments above each step. --- .github/workflows/ci.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8139a6dc3..dea49003bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,16 +38,16 @@ jobs: fail-fast: false # These are the actual CI steps to perform per job steps: + # https://github.com/actions/checkout - name: Checkout codebase - # https://github.com/actions/checkout uses: actions/checkout@v2 + # https://github.com/actions/setup-java - name: Install JDK 11 - # https://github.com/actions/setup-java uses: actions/setup-java@v1 with: java-version: 11 + # https://github.com/actions/cache - name: Cache Maven dependencies - # https://github.com/actions/cache uses: actions/cache@v2 with: # Cache entire ~/.m2/repository @@ -60,3 +60,6 @@ jobs: env: TEST_FLAGS: ${{ matrix.mvnflags }} run: mvn install -B -V -P-assembly -Pcoverage-report $TEST_FLAGS + # https://github.com/codecov/codecov-action + - name: Upload coverage to Codecov.io + uses: codecov/codecov-action@v1 From ac73d148f9b1d961025045a5028a56bc608558b6 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 24 Nov 2020 09:46:46 -0600 Subject: [PATCH 3/7] Rename ci.yml to build.yml. Tweak Codecov configs to wait for 2 builds to complete before sending back coverage notifications. --- .codecov.yml | 7 +++++++ .github/workflows/{ci.yml => build.yml} | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) rename .github/workflows/{ci.yml => build.yml} (95%) diff --git a/.codecov.yml b/.codecov.yml index 326dd3e0b2..a628d33cbe 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -4,6 +4,13 @@ # Can be validated via instructions at: # https://docs.codecov.io/docs/codecov-yaml#validate-your-repository-yaml +# Tell Codecov not to send a coverage notification until (at least) 2 builds are completed +# Since we run Unit & Integration tests in parallel, this lets Codecov know that coverage +# needs to be merged across those builds +codecov: + notify: + after_n_builds: 2 + # Settings related to code coverage analysis coverage: status: diff --git a/.github/workflows/ci.yml b/.github/workflows/build.yml similarity index 95% rename from .github/workflows/ci.yml rename to .github/workflows/build.yml index dea49003bf..e2f85fcf4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,9 @@ -# DSpace Continuous Integration via GitHub Actions +# DSpace Continuous Integration/Build via GitHub Actions # Concepts borrowed from # https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-java-with-maven -name: CI +name: Build -# Run this CI only for pushes / PRs to main branch +# Run this Build only for pushes / PRs to main branch on: push: branches: main From d58a69cb3f7de50df8c82b36f2de4dfc11405c4c Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 24 Nov 2020 10:12:54 -0600 Subject: [PATCH 4/7] Delete Travis CI configuration --- .travis.yml | 55 ----------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 89cb443597..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -# 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 -# TODO: Upgrade to Bionic -dist: trusty -os: linux - -jdk: - # DS-3384 Oracle JDK has DocLint enabled by default. - # Let's use this to catch any newly introduced DocLint issues. - - oraclejdk11 - -# 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" - -# 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' process to save time. We build/install/test all at once in "script" below. -install: skip - -# 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 aggregate code coverage reports -# (generated by -Pcoverage-report above) to CodeCov.io -after_success: bash <(curl -s https://codecov.io/bash) From 088c77bd1fbfab97191156dc72383dd20116ca6b Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Tue, 24 Nov 2020 17:06:43 -0600 Subject: [PATCH 5/7] Switch to using codecov bash script (more stable) --- .github/workflows/build.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e2f85fcf4a..eedf43dddf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,6 +60,5 @@ jobs: env: TEST_FLAGS: ${{ matrix.mvnflags }} run: mvn install -B -V -P-assembly -Pcoverage-report $TEST_FLAGS - # https://github.com/codecov/codecov-action - name: Upload coverage to Codecov.io - uses: codecov/codecov-action@v1 + run: bash <(curl -s https://codecov.io/bash) From c7d8a9b2596bb76358bdd80b4c47a3ac13ba6fce Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Wed, 25 Nov 2020 07:54:41 -0600 Subject: [PATCH 6/7] Revert to checkout@v1 per https://community.codecov.io/t/codecov-status-stuck-at-waiting-for-status-to-be-reported-on-github/341/40 --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eedf43dddf..e6856df251 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: steps: # https://github.com/actions/checkout - name: Checkout codebase - uses: actions/checkout@v2 + uses: actions/checkout@v1 # https://github.com/actions/setup-java - name: Install JDK 11 uses: actions/setup-java@v1 @@ -60,5 +60,6 @@ jobs: env: TEST_FLAGS: ${{ matrix.mvnflags }} run: mvn install -B -V -P-assembly -Pcoverage-report $TEST_FLAGS + # https://github.com/codecov/codecov-action - name: Upload coverage to Codecov.io - run: bash <(curl -s https://codecov.io/bash) + uses: codecov/codecov-action@v1 From 463c473c2b218dbb067896574c43f963bc41cbd5 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Wed, 25 Nov 2020 09:16:11 -0600 Subject: [PATCH 7/7] Rename job to "tests". Space out steps for easier readability --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e6856df251..76148f3435 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: branches: main jobs: - build: + tests: runs-on: ubuntu-latest env: # Give Maven 1GB of memory to work with @@ -41,11 +41,13 @@ jobs: # https://github.com/actions/checkout - name: Checkout codebase uses: actions/checkout@v1 + # https://github.com/actions/setup-java - name: Install JDK 11 uses: actions/setup-java@v1 with: java-version: 11 + # https://github.com/actions/cache - name: Cache Maven dependencies uses: actions/cache@v2 @@ -55,11 +57,13 @@ jobs: # Cache key is hash of all pom.xml files. Therefore any changes to POMs will invalidate cache key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-maven- + # Run parallel Maven builds based on the above 'strategy.matrix' - name: Run Maven ${{ matrix.type }} env: TEST_FLAGS: ${{ matrix.mvnflags }} run: mvn install -B -V -P-assembly -Pcoverage-report $TEST_FLAGS + # https://github.com/codecov/codecov-action - name: Upload coverage to Codecov.io uses: codecov/codecov-action@v1