From 230d7279fcd8340f74e6e654b100ab5019bd559a Mon Sep 17 00:00:00 2001 From: Stephen Duncan Jr Date: Thu, 3 Dec 2020 16:37:33 -0800 Subject: [PATCH] Replace TravisCI build with GitHub actions build workflow and update build. (#17) --- .github/workflows/build.yml | 33 +++++++++++++++++++++++++++++++++ .travis.yml | 9 --------- README.md | 16 +++++++--------- build.sbt | 10 ++++------ project/Dependencies.scala | 2 +- project/build.properties | 2 +- project/plugins.sbt | 4 ++-- 7 files changed, 48 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..966b7e6 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build + +on: + pull_request: + branches: ['*'] + push: + branches: ['master'] + +jobs: + build: + name: Build and Test + strategy: + matrix: + java: + - adopt@1.8 + - adopt@1.11 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Java and SBT + uses: olafurpg/setup-scala@v10 + with: + java-version: ${{ matrix.java }} + - name: Cache SBT + uses: coursier/cache-action@v5 + - name: Run tests and coverage + run: sbt jacocoAggregate + - name: Upload coverage report to CodeCov + uses: codecov/codecov-action@v1 + if: matrix.java == 'adopt@1.8' + with: + file: ./target/jacoco/report/aggregate/jacoco.xml + fail_ci_if_error: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2dbc625..0000000 --- a/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: scala -scala: - - 2.12.8 -jdk: - - openjdk8 -script: - - sbt jacocoAggregate -after_success: - - bash <(curl -s https://codecov.io/bash) -f target/jacoco/report/aggregate/jacoco.xml diff --git a/README.md b/README.md index d3bdc42..2eb0f29 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Moirai -[ ![Download](https://api.bintray.com/packages/nike/maven/moirai-core/images/download.svg) ](https://bintray.com/nike/maven/moirai-core/_latestVersion) -[![][travis img]][travis] +[![Download](https://api.bintray.com/packages/nike/maven/moirai-core/images/download.svg)](https://bintray.com/nike/maven/moirai-core/_latestVersion) +![Build](https://github.com/jrduncans/moirai/workflows/Build/badge.svg) [![Code Coverage](https://img.shields.io/codecov/c/github/Nike-Inc/moirai/master.svg)](https://codecov.io/github/Nike-Inc/moirai?branch=master) - [![][license img]][license] + [![License][license img]][license] [Moirai](https://en.wikipedia.org/wiki/Moirai) (or: the Fates) controls people's destiny. Moirai is a feature-flag and resource-reloading library for the JVM (requires Java 8 or above). @@ -18,6 +18,7 @@ The resource reloading can be used independently of the feature-flagging as a li The provided example is in Java, but Moirai should be easy to use in any JVM language. Creates a `FeatureFlagChecker` that reloads a Typesafe config file that controls whether `getNumber` returns a hard-coded number or calls `calculateRealNumber`: + ```java import com.nike.moirai.ConfigFeatureFlagChecker; import com.nike.moirai.FeatureCheckInput; @@ -47,7 +48,7 @@ public class Usage { resourceReloader, TypesafeConfigDecider.ENABLED_USERS.or(TypesafeConfigDecider.PROPORTION_OF_USERS) ); - + public int getNumber(String userIdentity) { if (featureFlagChecker.isFeatureEnabled("random.calculatenumber", FeatureCheckInput.forUser(userIdentity))) { return calculateRealNumber(); @@ -55,7 +56,7 @@ public class Usage { return 42; } } - + public int calculateRealNumber() { // calculate a value ... @@ -64,6 +65,7 @@ public class Usage { ``` Example config file: + ``` moirai { random.calculatenumber { @@ -116,13 +118,9 @@ Another method for making a feature flag decision based on a boolean value in th While the example from the Usage section demonstrates the intended common pattern for combining these components together, Moirai is designed to be flexible and composable. So you can build your `ResourceReloader`/`Supplier` and your `Predicate` however you want, including with custom implementations, or you can even implement `FeatureFlagChecker` directly if desired. - ## License Moirai is released under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) -[travis]:https://travis-ci.org/Nike-Inc/moirai -[travis img]:https://api.travis-ci.org/Nike-Inc/moirai.svg?branch=master - [license]:LICENSE.txt [license img]:https://img.shields.io/badge/License-Apache%202-blue.svg diff --git a/build.sbt b/build.sbt index 8f639d0..a38cebd 100644 --- a/build.sbt +++ b/build.sbt @@ -36,10 +36,6 @@ lazy val moirai = (project in file(".")) .settings(commonSettings) .settings( skip in publish := true, - // Replace tasks to work around https://github.com/sbt/sbt-bintray/issues/93 - bintrayRelease := (), - bintrayEnsureBintrayPackageExists := (), - bintrayEnsureLicenses := (), jacocoAggregateReportSettings := JacocoReportSettings( title = "Moirai Project Coverage", formats = Seq(JacocoReportFormats.ScalaHTML, JacocoReportFormats.XML) @@ -76,7 +72,8 @@ lazy val `moirai-s3` = project libraryDependencies ++= Seq( awsS3, scalaTest, - scalaMock + scalaMock, + logback ) ) @@ -87,7 +84,8 @@ lazy val `moirai-typesafeconfig` = project description := "Support for reading Moirai configuration using Typesafe Config", libraryDependencies ++= Seq( typesafeConfig, - scalaTest + scalaTest, + logback ) ) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index b766251..bbcc21d 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -7,7 +7,7 @@ object Dependencies { lazy val typesafeConfig = "com.typesafe" % "config" % "1.3.3" lazy val scalaTest = "org.scalatest" %% "scalatest" % "3.0.5" % Test - lazy val equalsVerifier = "nl.jqno.equalsverifier" % "equalsverifier" % "2.4.3" % Test + lazy val equalsVerifier = "nl.jqno.equalsverifier" % "equalsverifier" % "3.5" % Test lazy val scalaJava8Compat = "org.scala-lang.modules" %% "scala-java8-compat" % "0.8.0" % Test lazy val scalaCheck = "org.scalacheck" %% "scalacheck" % "1.13.5" % Test lazy val logback = "ch.qos.logback" % "logback-classic" % logbackVersion % Test diff --git a/project/build.properties b/project/build.properties index 133a8f1..7de0a93 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.17 +sbt.version=1.4.4 diff --git a/project/plugins.sbt b/project/plugins.sbt index 89e8a11..3fd779d 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,3 @@ -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.7") -addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.3") +addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13") +addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.6.1") addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.2.0")