From 5e273577f9502c6d9e1a33d6c79fecf469a33a07 Mon Sep 17 00:00:00 2001 From: Todd Underwood Date: Tue, 17 Nov 2020 09:36:29 -0800 Subject: [PATCH] Feat/migrate to gh actions (#20) * Migrates to GH actions --- .github/workflows/build.yml | 47 +++++++++++++++++++ .github/workflows/release.yml | 47 +++++++++++++++++++ .travis.yml | 21 --------- README.md | 2 +- gradle.properties | 2 +- gradle/check.gradle | 4 ++ gradle/dependencies.gradle | 2 +- ...erusClientSpringBootConfigurationTest.java | 42 +++++++++++++++-- 8 files changed, 138 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..189c845 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,47 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Build + +on: + push: + branches: + - '*' + pull_request: + branches: + - master + schedule: + - cron: "0 22 * * 1" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v1 + with: + java-version: 8 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew assemble + - name: Test with Gradle + run: ./gradlew check + - name: Upload coverage report to CodeCov + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + file: ./build/reports/cobertura/coverage.xml # optional + fail_ci_if_error: true # optional (default = false) + verbose: true + - name: Slack notification when master build fails + if: ${{ failure() && github.ref == 'refs/heads/master'}} + uses: rtCamp/action-slack-notify@v2.1.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: cerberus-alerts + SLACK_MESSAGE: 'Cerberus main build has failed :build-failed:' + SLACK_ICON: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png + SLACK_TITLE: Cerberus Build Failure Notification + SLACK_USERNAME: GitHub Actions \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9df0fad --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,47 @@ +# This workflow will build a Java project with Gradle +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle + +name: Release + +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 +jobs: + Build-and-Release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 8 + uses: actions/setup-java@v1 + with: + java-version: 8 + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew assemble + - name: Test with Gradle + run: ./gradlew check + - name: Upload coverage report to CodeCov + uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos + file: ./build/reports/cobertura/coverage.xml # optional + fail_ci_if_error: true # optional (default = false) + verbose: true + - name: Release artifact to Bintray + env: + BINTRAY_USER: ${{ secrets.BINTRAY_USER }} + BINTRAY_KEY: ${{ secrets.BINTRAY_KEY}} + run: ./gradlew bintrayUpload + - name: Slack notification when release fails + if: ${{ failure() }} + uses: rtCamp/action-slack-notify@v2.1.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: cerberus-alerts + SLACK_MESSAGE: 'Cerberus release workflow has failed :build-failed:' + SLACK_ICON: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png + SLACK_TITLE: Cerberus Build Failure Notification + SLACK_USERNAME: GitHub Actions \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0cba136..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: java -jdk: -- openjdk8 -cache: - directories: - - "$HOME/.m2" -after_success: -- "./gradlew cobertura coveralls --stacktrace" -- test "${TRAVIS_PULL_REQUEST}" == "false" && test "${TRAVIS_TAG}" != "" && ./gradlew - bintrayUpload --stacktrace -env: - global: - - secure: fary8Fe2flDhSzdvNAZ7V5TcnyF+J4vB8ldkCuiH2dDFc3GVr60kdNwWmbkAgz9Rbc9niSYW9vL6bbzAyQCbTjVJ6U0nIwxr88Jdzg9gtgb9TZtgSkvL78Mds4h1N8o0nUAWmQWc/dcTNiZM0wqH95EfOcqeK/neruA/JCmIGdXOvUZUMV2KVvbpiozDjOqj4ErbRWDpDEkzE6nAR1HbjROnow4euTzH5i5SgVzyGfnI2D2ibnbbg12wktYqBUIJETNOw4Ct3WDvwmnCMKRLFAA4vtuUxOc5RbtehpHasqkPgt638zlNaVIXHIqJpwK4n5QQm+sMmFh+nUw/CSyNYEXWD/92fzvjfyqsQdDOcTvfGShLpHQgaCnzv+66D2QUrtBPvC/qi5aM48gNlKipUm9GvsFW3p4A4LMioQUZyl+F8F+UVl3IhqMjekR9iG/FgoksJSnFnMLIvYbDBNgN0My/GGk+AGQiWC8KSgfPKlk1j4pDbgs4VMSsB+yL3ar9RbqFqsj9oHqVB0TEhzfz84xiigUMNPWDauveuLZ5JpifR6RSvRc+l73B3WjXwIQTKYGY/OzoaHEMK128EH7zfMi1ElQpi9boQEWtNMckEJ8u6WAQB12hwMsSmL8SeLbf/ioK7YvoTAQ+YxLzty6RxGwo5SjGfPaMBPhzKP6LzK0= - - secure: TfOsrjuvfr64fuidsQ7WpqLNcX2Zv7/s1tCh9inbcuc3VEOHlMQgcE5soC9SxrlEFxYRlTSyz5eQhglnin3zMY9gaC697m0VOgGQdyqsoy0uyT4RGJT3M0ilm4OJL3gTWp1W0+qKqIjESW/CJVL6n9M9mD2E5wShQBUkTdK+J9PzDDCZ0sKfHaBfAFIGGao2WxwmUvE7HHjwfX8iVn9VoURy+LaA1gDLTwl7XWvQhw60yH5rsAFjSt2OHzd02xRUnlrxv7Z9sWV/GqQYWKj9m4x0AD7SV8ocsMAoJvi5KeN+yzOiC2HTAkC0VukOwYZJu+j/yHUBvgzHO48NRLjrTZweNGsGipCTJNUaH0W+4QOl2o8eok2nPnr79IIJGLzmz66PKFGMZtRhDD6cC09EVpVBOg6n1n+tRawtJtjnW3a3ehTAjTdaLd0sJmh7WspSiolQtFFIExBoNT1ter6C+p20yn2yKEP4hL+kyUOPgPGEIzUrsLwqgh1L+NlE0Wu7AM4weWM/PYv985sDA2k4vXplIFdgiaVdUB+R+nc0P0HWI9h8VK/yB/71QQIvKRIxYpjreemGsgtnRpAODdd003TytXonx+DJWiAuRgLOdC/bgcbAYmSyCdD/OU90ZQxO1haz97PmrwhMDOwsCSExUodCsaaQ8Xk2+9/QLIQuoGg= -notifications: - slack: - if: branch = master AND (type = push OR type=cron) - on_success: change - on_failure: always - rooms: - - secure: AQuc4HJzirVFs8/f9xIqno5oUOTHVOOoE+YM2hgsvrVUBz5vuSiRQ32on9LtP/mtwM4rvozmWowt+bwF8nR7y3WT7tU4fUn4aOXjSPF0qNjNQXO9XP/z3Ui8c6LvIdftq7Qvty53mRQaKcQoVW9/9mlhsYfZjwlWojZIFVnxQIfQyLuPKVUV4H/g8/sVrPoX6K3SS76D7OrxDGG9PUvtgodMgpVQ68B1UYIlIRlFS2asozuF3PVTReSl9YjW8iYGBuhtVvDZbcNB7fbMWbqARRYnZ2M8+9syxnf82t0AvCXvIgZgMmVdcg/MCCbiNkEPhCP461fxiWiqWhRTLIl1JkMJ7lukai5hdbBkhtC9pNQcmWfA6gfdPL54M7Cm0pI2kW4H99mfmi3IPK7qvEcvDdFEopscCPSjZ6IzZ22Y4lZTJkOlwSXFOlR1wAuYywms43G9GHOSHn/XMCYOCVHvZ0hJNgXjgYsgDx/4DqfKV4CTXBvgtqU9I/dSScDMBdaxNteCBXvZMIk1PNtahJWwbwIEy3rn+3yI7GmYb31ijArfRP11jfubj8lc1RiNBR90DyjYCLQUAF1aQzXq4MPZ0CdcbJsPecPVvhjNNiKu6tVmxie49jCDpe3eBwrMsf1LAzW4uRmHS+JIRJX1WRtcu4DZHkkTFte7lFsifCDeelU= diff --git a/README.md b/README.md index 6390916..4360ef8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [ ![Download](https://api.bintray.com/packages/nike/maven/cerberus-spring-boot-client/images/download.svg) ](https://bintray.com/nike/maven/cerberus-spring-boot-client/_latestVersion) [![][travis img]][travis] -[![Coverage Status](https://coveralls.io/repos/github/Nike-Inc/cerberus-spring-boot-client/badge.svg?branch=master)](https://coveralls.io/github/Nike-Inc/cerberus-spring-boot-client) +[![codecov](https://codecov.io/gh/Nike-Inc/cerberus-spring-boot-client/branch/master/graph/badge.svg)](https://codecov.io/gh/Nike-Inc/cerberus-spring-boot-client) [![][license img]][license] A Spring Boot client library for Cerberus for Spring Boot applications. diff --git a/gradle.properties b/gradle.properties index c4f435a..3dec845 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,6 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -version=3.2.1 +version=3.2.2 groupId=com.nike artifactId=cerberus-spring-boot-client diff --git a/gradle/check.gradle b/gradle/check.gradle index 4a2ab70..e09d581 100644 --- a/gradle/check.gradle +++ b/gradle/check.gradle @@ -43,6 +43,10 @@ cobertura { } test.finalizedBy(project.tasks.coberturaReport) +test { + useJUnitPlatform() +} + task findbugsHtml { group = "Verification" description = "Creates a human readable Findbugs report" diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 48d0a9e..986cdde 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -46,7 +46,7 @@ dependencies { // Test dependencies testRuntime 'org.slf4j:slf4j-simple:1.7.25' - testCompile "junit:junit:4.12" + testCompile "org.junit.jupiter:junit-jupiter:5.7.0" testCompile ("org.mockito:mockito-core:1.10.19") { exclude group: 'org.hamcrest' } diff --git a/src/test/java/com/nike/cerberus/springboot/CerberusClientSpringBootConfigurationTest.java b/src/test/java/com/nike/cerberus/springboot/CerberusClientSpringBootConfigurationTest.java index f9759e9..d781d82 100644 --- a/src/test/java/com/nike/cerberus/springboot/CerberusClientSpringBootConfigurationTest.java +++ b/src/test/java/com/nike/cerberus/springboot/CerberusClientSpringBootConfigurationTest.java @@ -16,13 +16,45 @@ package com.nike.cerberus.springboot; -import org.junit.Test; +import org.junit.jupiter.api.*; public class CerberusClientSpringBootConfigurationTest { - @Test(expected = IllegalArgumentException.class) - public void testForExceptionOnMissingRequiredProperty() throws Exception { - new CerberusClientSpringBootConfiguration(new CerberusClientSpringBootProperties()) - .cerberusClient(); + @Test + public void testForExceptionOnMissingMissingRegion() { + Assertions.assertThrows( + IllegalArgumentException.class, + () -> { + CerberusClientSpringBootProperties configProps = + new CerberusClientSpringBootProperties(); + configProps.setUrl("https://test.cerberus.example.com"); + + new CerberusClientSpringBootConfiguration(configProps).cerberusClient(); + }); + } + + @Test + public void testForExceptionOnMissingURL() { + Assertions.assertThrows( + IllegalArgumentException.class, + () -> { + CerberusClientSpringBootProperties configProps = + new CerberusClientSpringBootProperties(); + configProps.setRegion("us-west-2"); + + new CerberusClientSpringBootConfiguration(configProps).cerberusClient(); + }); + } + + @Test + public void testCerberusClientSpringBootConfiguration() { + Assertions.assertDoesNotThrow( + () -> { + CerberusClientSpringBootProperties configProps = + new CerberusClientSpringBootProperties(); + configProps.setRegion("us-west-2"); + configProps.setUrl("https://test.cerberus.example.com"); + new CerberusClientSpringBootConfiguration(configProps).cerberusClient(); + }); } }