diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9ea11f8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,115 @@ +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Continuous Integration + +on: + pull_request: + branches: ['*'] + push: + branches: ['*'] + tags: [v*] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + build: + name: Build and Test + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.12.13] + java: [adopt@1.8] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java and Scala + uses: olafurpg/setup-scala@v10 + with: + java-version: ${{ matrix.java }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Check that workflows are up to date + run: sbt ++${{ matrix.scala }} githubWorkflowCheck + + - name: Build project + run: sbt ++${{ matrix.scala }} test + + - name: Compress target directories + run: tar cf targets.tar app-common/target consul-app/target target core/target file-watcher-app/target project/target + + - name: Upload target directories + uses: actions/upload-artifact@v2 + with: + name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }} + path: targets.tar + + publish: + name: Publish Artifacts + needs: [build] + if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v')) + strategy: + matrix: + os: [ubuntu-latest] + scala: [2.12.13] + java: [adopt@1.8] + runs-on: ${{ matrix.os }} + steps: + - name: Checkout current branch (full) + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Java and Scala + uses: olafurpg/setup-scala@v10 + with: + java-version: ${{ matrix.java }} + + - name: Cache sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier/cache/v1 + ~/.cache/coursier/v1 + ~/AppData/Local/Coursier/Cache/v1 + ~/Library/Caches/Coursier/v1 + key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} + + - name: Download target directories (2.12.13) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-2.12.13-${{ matrix.java }} + + - name: Inflate target directories (2.12.13) + run: | + tar xf targets.tar + rm targets.tar + + - env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + run: sbt ++${{ matrix.scala }} ci-release \ No newline at end of file diff --git a/.github/workflows/clean.yml b/.github/workflows/clean.yml new file mode 100644 index 0000000..b535fcc --- /dev/null +++ b/.github/workflows/clean.yml @@ -0,0 +1,59 @@ +# This file was automatically generated by sbt-github-actions using the +# githubWorkflowGenerate task. You should add and commit this file to +# your git repository. It goes without saying that you shouldn't edit +# this file by hand! Instead, if you wish to make changes, you should +# change your sbt build configuration to revise the workflow description +# to meet your needs, then regenerate this file. + +name: Clean + +on: push + +jobs: + delete-artifacts: + name: Delete Artifacts + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Delete artifacts + run: | + # Customize those three lines with your repository and credentials: + REPO=${GITHUB_API_URL}/repos/${{ github.repository }} + + # A shortcut to call GitHub API. + ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; } + + # A temporary file which receives HTTP response headers. + TMPFILE=/tmp/tmp.$$ + + # An associative array, key: artifact name, value: number of artifacts of that name. + declare -A ARTCOUNT + + # Process all artifacts on this repository, loop on returned "pages". + URL=$REPO/actions/artifacts + while [[ -n "$URL" ]]; do + + # Get current page, get response headers in a temporary file. + JSON=$(ghapi --dump-header $TMPFILE "$URL") + + # Get URL of next page. Will be empty if we are at the last page. + URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*.*//') + rm -f $TMPFILE + + # Number of artifacts on this page: + COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') )) + + # Loop on all artifacts on this page. + for ((i=0; $i < $COUNT; i++)); do + + # Get name of artifact and count instances of this name. + name=$(jq <<<$JSON -r ".artifacts[$i].name?") + ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1)) + + id=$(jq <<<$JSON -r ".artifacts[$i].id?") + size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") )) + printf "Deleting '%s' #%d, %'d bytes\n" $name ${ARTCOUNT[$name]} $size + ghapi -X DELETE $REPO/actions/artifacts/$id + done + done \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1503434..0000000 --- a/.travis.yml +++ /dev/null @@ -1,36 +0,0 @@ -sudo: false -language: scala -scala: -- 2.12.6 -jdk: -- openjdk8 - -stages: - - name: build - - name: publish - if: ((branch = master) AND (type != pull_request)) OR (tag IS present) - -jobs: - include: - - stage: build - script: sbt ++$TRAVIS_SCALA_VERSION test - - stage: publish - script: sbt ++$TRAVIS_SCALA_VERSION releaseEarly; - -before_install: -- if [ $TRAVIS_PULL_REQUEST = 'false' ]; then - openssl aes-256-cbc -K $encrypted_054593f98bbe_key -iv $encrypted_054593f98bbe_iv -in travis/secrets.tar.enc -out travis/secrets.tar -d; - tar xv -C travis -f travis/secrets.tar; - fi - -env: - global: - - secure: "G/L9IDrk12lD5W4+j9V/h3/B0OcHengZUC16yR8hpqVvbgPJaslWfcVY/9T4KURAC8UHW2miVC2VHYrVM+JIshdFSfu9f1V+oD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jK431+J2DhnunBVQXugBEFRoSpeeYlJAsr6AxiQz5MC8hmm8v1g8fh5AnapISgM3Fo0UTjnXHQEs2N95vFMKsJ3TordikEJCSRMBT2awIMDAfQ0zvOI+2p5J2dffin3DB4T4v7Y2zRmoF68F/Ds6wOMikarkBj2Sm8xoWk7aOTIqn8bL/9IBLprddYt+DbHFa81BCCOXHB4LRX0=" - - secure: "INV8I90M3Csci1166fJyj5Fa2Qxevgv+JdkSbiTERPg5EYQEAL8UYKBqJcEgfmA3uFBOCVIuNO9uYgFHvzIAB5yeFhEd2GfyFfIPyT3bLLLmkuE5wAXGUZVO4i3KKeEtGUUxuauvlBd8ZLMSZqXTigYxoAjFRYCAFCCSjNRMf7zE06zi2a4M5hu8Qzj+YJlKigTtRVs69zsH5OokRqVCa8V7+iDdVs3U3tMEPXu7/Z5YgDfYUw35GrVsDluj3NJzSz+tWoHWh4/Kis1ZgPLbuQybQZIcCm8PXcKMakoDuYYbXpDXC8hwbyHcIA9HaOQSVfhmb+J9KynFEIcpmZuvEU85lBw9OFC7e7a2l8hY2AD72vm8kzS8mV5ecg3uA4UDMa1CFaXkVdV+VALOClyLuQjKVk00DXLC5rlZEqV7pri+9FfoRT5UAQ0Xe6qMou3GGe4Cp7TvhsKlcjeGZ7H8rUu562Z8fZ2sXRKMj+BPZDoM6Z/2GV1aKR7UZNn+TRpj7eey+JI8mZg1HveNpaF86ruoMMh85lxUTbEpsMn4IysCzyVolYKGZgZlZ5rSu65fwmLXOKthd/xWgt1rKYnQDvKLf1LgV1RPGhxkMaRTyiFBxcsc+c+52D+5I/V0sCe2JVxz9C2t9IiHUWutUjWp8FLABPD0Zk/U3+CdQv+zk14=" - -cache: - directories: - - $HOME/.ivy2/cache - - $HOME/.sbt - - $HOME/.coursier diff --git a/build.sbt b/build.sbt index cdf532f..790ac97 100644 --- a/build.sbt +++ b/build.sbt @@ -37,7 +37,7 @@ lazy val `consul-app` = .settings(name := "kafka-snow-white-consul-app") .settings(baseSettings: _*) .settings(libraryDependencies ++= (consulAppDependencies ++ consulAppTestDependencies)) - .settings(mainClass in (Compile, run) := Some("com.supersonic.main.KafkaConsulMirrorApp")) + .settings(Compile / run / mainClass := Some("com.supersonic.main.KafkaConsulMirrorApp")) .dependsOn(`app-common` % "compile -> compile; test -> test; it -> it") } } @@ -49,24 +49,30 @@ lazy val `file-watcher-app` = .settings(name := "kafka-snow-white-file-watcher-app") .settings(baseSettings: _*) .settings(libraryDependencies ++= fileAppDependencies) - .settings(mainClass in (Compile, run) := Some("com.supersonic.main.KafkaFileWatcherMirrorApp")) + .settings(Compile / run / mainClass := Some("com.supersonic.main.KafkaFileWatcherMirrorApp")) .dependsOn(`app-common` % "compile -> compile; test -> test; it -> it") } } +sonatypeCredentialHost := Sonatype.sonatype01 inThisBuild(List( - licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), + organization := "com.supersonic", homepage := Some(url("https://github.com/SupersonicAds/kafka-snow-white")), + licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), developers := List(Developer("SupersonicAds", "SupersonicAds", "SupersonicAds", url("https://github.com/SupersonicAds"))), - scmInfo := Some(ScmInfo(url("https://github.com/SupersonicAds/kafka-snow-white"), "scm:git:git@github.com:SupersonicAds/kafka-snow-white.git")), - pgpPublicRing := file("./travis/local.pubring.asc"), - pgpSecretRing := file("./travis/local.secring.asc"), - releaseEarlyEnableSyncToMaven := false, - releaseEarlyWith := BintrayPublisher)) + githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))), + githubWorkflowTargetTags ++= Seq("v*"), + githubWorkflowPublish := Seq( + WorkflowStep.Sbt( + List("ci-release"), + env = Map( + "PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}", + "PGP_SECRET" -> "${{ secrets.PGP_SECRET }}", + "SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}", + "SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"))))) def baseSettings = List( - organization := "com.supersonic", scalaVersion := "2.12.8", scalacOptions ++= List( "-encoding", "UTF-8", @@ -80,14 +86,15 @@ def baseSettings = List( "-Xlint", "-Ypartial-unification", "-P:splain:color:false"), + sonatypeCredentialHost := Sonatype.sonatype01, resolvers += Resolver.jcenterRepo, - scalacOptions.in(Compile, console) ~= filterConsoleScalacOptions, - scalacOptions.in(Test, console) ~= filterConsoleScalacOptions, - sources in (Compile, doc) := List.empty, + Compile / console / scalacOptions ~= filterConsoleScalacOptions, + Test / console / scalacOptions ~= filterConsoleScalacOptions, + Compile / doc / sources := List.empty, mergeStrategy, // a workaround for https://github.com/sbt/sbt/issues/1380 makePomConfiguration := makePomConfiguration.value.withConfigurations(Configurations.defaultMavenConfigurations), - addCompilerPlugin("io.tryp" % "splain" % "0.4.0" cross CrossVersion.patch)) + addCompilerPlugin("io.tryp" % "splain" % "0.5.8" cross CrossVersion.patch)) val akkaVersion = "2.5.21" val akkaHTTPVersion = "10.1.8" @@ -146,13 +153,13 @@ val IntegrationConfig = IntegrationTest.extend(Test) def withIntegrationTests(project: Project) = { val testWithIntegration = - test in Test := (test in IntegrationConfig).dependsOn(test in Test).value + Test / test := (IntegrationConfig / test).dependsOn(Test / test).value val integrationTestSettings = inConfig(IntegrationConfig)(testSettings) ++ Seq( testWithIntegration, - parallelExecution in IntegrationConfig := false) + IntegrationConfig / parallelExecution := false) project .settings(integrationTestSettings) @@ -163,19 +170,19 @@ def withIntegrationTests(project: Project) = { def withAssemblyArtifact(project: Project) = project .settings { - artifact in (Compile, assembly) ~= { art => + Compile / assembly / artifact ~= { art => art.withClassifier(Some("assembly")) } } - .settings(addArtifact(artifact in (Compile, assembly), assembly).settings: _*) - .settings(test in assembly := {}) + .settings(addArtifact(Compile / assembly / artifact, assembly).settings: _*) + .settings(assembly / test := {}) def mergeStrategy = - assemblyMergeStrategy in assembly := { + assembly / assemblyMergeStrategy := { case PathList("org", "apache", "commons", "collections", _*) => MergeStrategy.last case x => - val oldStrategy = (assemblyMergeStrategy in assembly).value + val oldStrategy = (assembly / assemblyMergeStrategy).value oldStrategy(x) } diff --git a/project/build.properties b/project/build.properties index dca663d..b366316 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version = 1.2.8 +sbt.version = 1.5.0 diff --git a/project/plugins.sbt b/project/plugins.sbt index 41e6ee5..913a545 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,10 +4,10 @@ resolvers += Classpaths.sbtPluginReleases addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6") -addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0") - addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0") -addSbtPlugin("ch.epfl.scala" % "sbt-release-early" % "2.1.1") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") + +addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.10.1") diff --git a/travis/secrets.tar.enc b/travis/secrets.tar.enc deleted file mode 100644 index 79bb42a..0000000 Binary files a/travis/secrets.tar.enc and /dev/null differ