From 093c818e916c3a699a182e05d2cf89d657aa3e1e Mon Sep 17 00:00:00 2001 From: Chanseok Oh Date: Tue, 9 Feb 2021 11:50:27 -0500 Subject: [PATCH] Migrate to GitHub Actions for unit tests and set up code coverage (#396) * Set up GitHub Actions unit tests and code coverage * fetch-depth: 2 * Specify JaCoCo version --- .github/workflows/unit-tests.yaml | 43 +++++++++++++++++++++++++++++++ .travis.yml | 38 --------------------------- build.gradle | 16 +++++++++++- 3 files changed, 58 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/unit-tests.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml new file mode 100644 index 00000000..ac5adb2e --- /dev/null +++ b/.github/workflows/unit-tests.yaml @@ -0,0 +1,43 @@ +name: Unit Tests +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + +jobs: + unit-tests: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [8, 11] + env: + CLOUDSDK_CORE_DISABLE_USAGE_REPORTING: true + CLOUDSDK_CORE_DISABLE_PROMPTS: true + # for Gradle + TERM: dumb + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 2 + - uses: actions/setup-java@v1 + with: + java-version: ${{ matrix.java }} + - uses: actions/cache@v2 + with: + path: | + ~/.m2/repository + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Run tests + run: | + ./gradlew clean build jacocoTestReport --stacktrace + - name: Test Coverage + uses: codecov/codecov-action@v1 + with: + name: actions ${{matrix.java}} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e758db0b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,38 +0,0 @@ -language: java -matrix: - include: - - name: OpenJDK 8 - jdk: openjdk8 - - name: OpenJDK 11 - jdk: openjdk11 - -before_cache: - - rm -rf $HOME/.gradle/caches/modules-2/modules-2.lock -cache: - directories: - - $HOME/.gradle/caches - - $HOME/.gradle/wrapper - - $HOME/google-cloud-sdk -env: - global: - - CLOUDSDK_CORE_DISABLE_USAGE_REPORTING=true - - CLOUDSDK_CORE_DISABLE_PROMPTS=true -install: - # https://github.com/travis-ci/travis-ci/issues/8408 - - unset _JAVA_OPTIONS - - # check if cloud SDK was installed (/bin exists) - # travis auto creates cache directories, so remove it before install - - if [ ! -d $HOME/google-cloud-sdk/bin ]; then - rm -rf $HOME/google-cloud-sdk; - curl https://sdk.cloud.google.com | bash; - fi - # make our installed cloud sdk take precedence - - source $HOME/google-cloud-sdk/path.bash.inc - # update gcloud - - gcloud components update --quiet - # add App Engine component to Cloud SDK - - gcloud components install app-engine-java --quiet - -script: - - ./gradlew clean check diff --git a/build.gradle b/build.gradle index 9136eb41..e2f15453 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,7 @@ plugins { id 'net.researchgate.release' version '2.6.0' id 'com.github.sherter.google-java-format' version '0.8' id 'checkstyle' + id 'jacoco' } repositories { @@ -164,7 +165,7 @@ check.dependsOn verifyGoogleJavaFormat // to auto-format run ./gradlew googleJavaFormat checkstyle { - toolVersion = "8.18" + toolVersion = '8.18' // get the google_checks.xml file from the actual tool we're invoking config = resources.text.fromArchiveEntry(configurations.checkstyle[0], 'google_checks.xml') maxErrors = 0 @@ -172,3 +173,16 @@ checkstyle { checkstyleTest.enabled = false } /* FORMATTING */ + +/* TEST COVERAGE */ +jacoco { + toolVersion = '0.8.6' +} + +jacocoTestReport { + reports { + xml.enabled true + html.enabled false + } +} +/* TEST COVERAGE */