From 9d49d15b2028e841886db1e703cdf2438289c476 Mon Sep 17 00:00:00 2001 From: Junichi Kato Date: Wed, 21 Jul 2021 21:36:04 +0900 Subject: [PATCH] add support for sbt-ci-release --- .github/CODEOWNERS | 1 + .github/clean-up.sh | 6 + .github/dependabot.yml | 6 + .github/workflows/bump-version.yml | 59 +++++++ .github/workflows/ci.yml | 77 ++++++++ .github/workflows/release.yml | 53 ++++++ .github/workflows/scala-steward.yml | 15 ++ .github/workflows/snapshot.yml | 32 ++++ .scala-steward.conf | 2 + .scalafix.conf | 11 ++ .scalafmt.conf | 21 +-- build.sbt | 167 +++++++++--------- .../chatwork/scala/jwk/AlgorithmType.scala | 0 .../chatwork/scala/jwk/AssymetricJWK.scala | 0 .../scala/jwk/Base64StringJsonImplicits.scala | 0 .../com/chatwork/scala/jwk/ByteUtils.scala | 0 .../scala/com/chatwork/scala/jwk/Curve.scala | 0 .../chatwork/scala/jwk/CurveBasedJWK.scala | 0 .../scala/com/chatwork/scala/jwk/ECJWK.scala | 4 +- .../chatwork/scala/jwk/ECParameterTable.scala | 0 .../scala/com/chatwork/scala/jwk/JWK.scala | 0 .../com/chatwork/scala/jwk/JWKError.scala | 0 .../com/chatwork/scala/jwk/JWKMatcher.scala | 0 .../com/chatwork/scala/jwk/JWKPrinter.scala | 0 .../scala/com/chatwork/scala/jwk/JWKSet.scala | 1 - .../chatwork/scala/jwk/JWKThumbprint.scala | 0 .../chatwork/scala/jwk/JWSAlgorithmType.scala | 0 .../scala/com/chatwork/scala/jwk/JsType.scala | 0 .../chatwork/scala/jwk/JsonImplicits.scala | 0 .../scala/com/chatwork/scala/jwk/KeyId.scala | 0 .../chatwork/scala/jwk/KeyOperationType.scala | 0 .../chatwork/scala/jwk/KeyOperations.scala | 0 .../com/chatwork/scala/jwk/KeyType.scala | 0 .../scala/jwk/KeyUseAndOpsConsistency.scala | 0 .../chatwork/scala/jwk/OtherPrimesInfo.scala | 0 .../chatwork/scala/jwk/PublicKeyUseType.scala | 0 .../scala/com/chatwork/scala/jwk/RSAJWK.scala | 13 +- .../com/chatwork/scala/jwk/Requirement.scala | 0 .../chatwork/scala/jwk/URIJsonImplicits.scala | 0 .../chatwork/scala/jwk/utils/ECChecks.scala | 0 .../com/chatwork/scala/jwk/ECJWKSpec.scala | 2 +- .../com/chatwork/scala/jwk/JWKSetSpec.scala | 1 - .../com/chatwork/scala/jwk/KeyIdSpec.scala | 1 - .../com/chatwork/scala/jwk/RSAJWKSpec.scala | 1 - project/Dependencies.scala | 6 + project/plugins.sbt | 13 +- release.sbt | 24 --- scalafmt.sbt | 3 - version.sbt | 1 - 49 files changed, 380 insertions(+), 140 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100755 .github/clean-up.sh create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/bump-version.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/scala-steward.yml create mode 100644 .github/workflows/snapshot.yml create mode 100644 .scala-steward.conf create mode 100644 .scalafix.conf rename {src => library/src}/main/scala/com/chatwork/scala/jwk/AlgorithmType.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/AssymetricJWK.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/Base64StringJsonImplicits.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/ByteUtils.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/Curve.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/CurveBasedJWK.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/ECJWK.scala (99%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/ECParameterTable.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/JWK.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/JWKError.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/JWKMatcher.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/JWKPrinter.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/JWKSet.scala (98%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/JWKThumbprint.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/JWSAlgorithmType.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/JsType.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/JsonImplicits.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/KeyId.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/KeyOperationType.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/KeyOperations.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/KeyType.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/KeyUseAndOpsConsistency.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/OtherPrimesInfo.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/PublicKeyUseType.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/RSAJWK.scala (98%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/Requirement.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/URIJsonImplicits.scala (100%) rename {src => library/src}/main/scala/com/chatwork/scala/jwk/utils/ECChecks.scala (100%) rename {src => library/src}/test/scala/com/chatwork/scala/jwk/ECJWKSpec.scala (99%) rename {src => library/src}/test/scala/com/chatwork/scala/jwk/JWKSetSpec.scala (99%) rename {src => library/src}/test/scala/com/chatwork/scala/jwk/KeyIdSpec.scala (98%) rename {src => library/src}/test/scala/com/chatwork/scala/jwk/RSAJWKSpec.scala (99%) delete mode 100644 release.sbt delete mode 100644 scalafmt.sbt delete mode 100644 version.sbt diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..c68a989 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @j5ik2o @exoego diff --git a/.github/clean-up.sh b/.github/clean-up.sh new file mode 100755 index 0000000..78c4ada --- /dev/null +++ b/.github/clean-up.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +rm -rf "$HOME/.ivy2/local" || true +find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true +find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true +find $HOME/.sbt -name "*.lock" -delete || true diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..5ace460 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 0000000..60346f3 --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -0,0 +1,59 @@ +name: Bump Version +on: + workflow_dispatch: + inputs: + force: + description: 'force release' + required: false + default: '0' + schedule: + - cron: '0 0 * * *' +jobs: + bump-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + persist-credentials: false + token: ${{ secrets.CW_SCALA_STEWARD_TOKEN }} + - name: Calculate changes from the latest tag to HEAD + id: changes + run: | + LATEST_TAG=$(git describe --abbrev=0 --tags) + echo "latest-tag = $LATEST_TAG" + COUNT=$(git log $LATEST_TAG..HEAD --pretty=format:"%s" --no-merges \ + --grep='^build:' \ + --grep='^ci:' \ + --grep='^feat:' \ + --grep='^fix:' \ + --grep='^docs:' \ + --grep='^style:' \ + --grep='^refactor:' \ + --grep='^perf:' \ + --grep='^test:' \ + --grep='^revert:' \ + --grep='^chore:' | awk 'END{print NR}') + echo "steps.changes.outputs.count = $COUNT" + FORCE=${{ github.event.inputs.force }} + if [[ "$FORCE" = "1" ]]; then + echo "::set-output name=count::1" + else + echo "::set-output name=count::$COUNT" + fi + - name: Bump version and push tag + id: tag_version + uses: mathieudutour/github-tag-action@v5.5 + with: + github_token: ${{ secrets.CW_SCALA_STEWARD_TOKEN }} + default_bump: patch + if: steps.changes.outputs.count > 0 + - name: Create a GitHub release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.CW_SCALA_STEWARD_TOKEN }} + with: + tag_name: ${{ steps.tag_version.outputs.new_tag }} + release_name: Release ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.tag_version.outputs.changelog }} + if: steps.changes.outputs.count > 0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..25d738c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +name: CI +on: + push: + branches: + - main + paths: + - '**.scala' + - '**.java' + - '**.sbt' + - '.scalafmt.conf' + - '.github/workflows/ci.yml' + pull_request: + branches: + - main + paths: + - '**.scala' + - '**.java' + - '**.sbt' + - '.scalafmt.conf' + - '.github/workflows/ci.yml' + schedule: + - cron: '0 * * * *' +jobs: + lint: + runs-on: ubuntu-latest + env: + JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + steps: + - uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + - uses: olafurpg/setup-scala@v12 + with: + java-version: "adopt@1.8" + - uses: coursier/cache-action@v6 + - run: sbt -v lint + - name: clean up + run: "${GITHUB_WORKSPACE}/.github/clean-up.sh" + test: + strategy: + fail-fast: false + matrix: + jdk: [ adopt@1.8, adopt@1.11, adopt@1.14 ] + scala: [ 2.13.5, 2.12.13, 2.11.12 ] + runs-on: ubuntu-latest + needs: lint + env: + JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + AWS_REGION: ap-northeast-1 + TEST_TIME_FACTOR: 3 + steps: + - uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + - uses: olafurpg/setup-scala@v12 + with: + java-version: ${{ matrix.jdk }} + - uses: coursier/cache-action@v6 + - uses: olafurpg/setup-gpg@v3 + - name: sbt test + run: sbt -v ++${{ matrix.scala }} test + - name: clean up + run: "${GITHUB_WORKSPACE}/.github/clean-up.sh" + automerge: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + needs: test + steps: + - name: automerge + uses: pascalgn/automerge-action@v0.14.2 + env: + GITHUB_TOKEN: "${{ secrets.CW_SCALA_STEWARD_TOKEN }}" + MERGE_LABELS: "" + MERGE_METHOD: "rebase" + MERGE_FILTER_AUTHOR: "cw-scala-steward" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..68050a8 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Release +on: + push: + tags: + - v[1-9]+.[0-9]+.[0-9]+ +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest ] + jdk: [ adopt@1.8, adopt@1.11, adopt@1.14 ] + scala: [ 2.11.12, 2.12.13, 2.13.5 ] + runs-on: ${{ matrix.os }} + env: + JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + AWS_REGION: ap-northeast-1 + TEST_TIME_FACTOR: 3 + steps: + - uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + - uses: olafurpg/setup-scala@v12 + with: + java-version: ${{ matrix.jdk }} + - uses: coursier/cache-action@v6 + - run: sbt -v ++${{ matrix.scala }} test + - name: clean up + run: "${GITHUB_WORKSPACE}/.github/clean-up.sh" + release: + runs-on: ubuntu-latest + needs: test + env: + JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + steps: + - uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + - uses: olafurpg/setup-scala@v12 + with: + java-version: "adopt@1.8" + - uses: coursier/cache-action@v6 + - uses: olafurpg/setup-gpg@v3 + - run: sbt -v ci-release + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + - name: clean up + run: "${GITHUB_WORKSPACE}/.github/clean-up.sh" diff --git a/.github/workflows/scala-steward.yml b/.github/workflows/scala-steward.yml new file mode 100644 index 0000000..af40658 --- /dev/null +++ b/.github/workflows/scala-steward.yml @@ -0,0 +1,15 @@ +name: Scala Steward +on: + workflow_dispatch: + schedule: + - cron: '0 * * * *' +jobs: + scala-steward: + runs-on: ubuntu-latest + steps: + - uses: scala-steward-org/scala-steward-action@v2 + if: ${{ !github.event.repository.fork }} + with: + github-token: ${{ secrets.CW_SCALA_STEWARD_TOKEN }} + author-email: "develop-hq+scala-steward@chatwork.com" + author-name: "cw-scala-steward" diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..b8051f8 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,32 @@ +name: Snapshot +on: + workflow_run: + workflows: + - CI + types: + - completed +jobs: + snapshot: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + env: + JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + JVM_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8 + steps: + - uses: actions/checkout@v2.3.4 + with: + ref: ${{ github.event.workflow_run.head_branch }} + fetch-depth: 0 + - uses: olafurpg/setup-scala@v12 + with: + java-version: "adopt@1.8" + - uses: coursier/cache-action@v6 + - uses: olafurpg/setup-gpg@v3 + - run: sbt -v ci-release + env: + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + PGP_SECRET: ${{ secrets.PGP_SECRET }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + - name: clean up + run: "${GITHUB_WORKSPACE}/.github/clean-up.sh" diff --git a/.scala-steward.conf b/.scala-steward.conf new file mode 100644 index 0000000..7abda14 --- /dev/null +++ b/.scala-steward.conf @@ -0,0 +1,2 @@ +updatePullRequests = "always" +commits.message = "build: Update ${artifactName} from ${currentVersion} to ${nextVersion}" diff --git a/.scalafix.conf b/.scalafix.conf new file mode 100644 index 0000000..c603de2 --- /dev/null +++ b/.scalafix.conf @@ -0,0 +1,11 @@ +rules = [ + //Semantic Rules + //ExplicitResultTypes, // Deactivated as scalafix on Scala 3 fails otherwise + RemoveUnused, + NoAutoTupling, + //Syntactic Rules + DisableSyntax, + ProcedureSyntax, + LeakingImplicitClassVal, + NoValInForComprehension +] \ No newline at end of file diff --git a/.scalafmt.conf b/.scalafmt.conf index fafffee..bff2029 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,10 +1,11 @@ -version = 2.7.5 -style = defaultWithAlign -danglingParentheses.preset = true -indentOperator.preset = spray -includeCurlyBraceInSelectChains = true -maxColumn = 120 -rewrite.rules = [RedundantParens, SortImports, PreferCurlyFors] -spaces.inImportCurlyBraces = true -binPack.literalArgumentLists = false -unindentTopLevelOperators = true +version = 3.0.0-RC3 +style = defaultWithAlign +danglingParentheses.preset = true +indentOperator.preset = spray +includeCurlyBraceInSelectChains = true +maxColumn = 120 +rewrite.rules = [RedundantParens, SortImports, PreferCurlyFors] +spaces.inImportCurlyBraces = true +binPack.literalArgumentLists = false +unindentTopLevelOperators = true +optIn.breaksInsideChains = true \ No newline at end of file diff --git a/build.sbt b/build.sbt index 0168f14..a7984a6 100644 --- a/build.sbt +++ b/build.sbt @@ -1,91 +1,94 @@ -val scala212Version = "2.12.13" -val scala213Version = "2.13.6" -val scala3Version = "3.0.1" +import sbt._ -sonatypeProfileName := "com.chatwork" - -organization := "com.chatwork" - -name := "scala-jwk" - -scalaVersion := scala213Version - -crossScalaVersions := Seq(scala212Version, scala213Version, scala3Version) - -scalacOptions ++= Seq( - "-feature", - "-deprecation", - "-unchecked", - "-encoding", - "UTF-8", - "-language:_" -) - -scalacOptions ++= { - CrossVersion.partialVersion(scalaVersion.value) match { +def crossScalacOptions(scalaVersion: String): Seq[String] = + CrossVersion.partialVersion(scalaVersion) match { case Some((3L, _)) => - Seq.empty + Seq( + "-source:3.0-migration", + "-Xignore-scala2-macros" + ) case Some((2L, scalaMajor)) if scalaMajor >= 12 => - Seq.empty - case Some((2L, scalaMajor)) if scalaMajor <= 11 => Seq( - "-Yinline-warnings" + "-Ydelambdafy:method", + "-target:jvm-1.8", + "-Yrangepos", + "-Ywarn-unused" ) } -} -resolvers ++= Seq( - "Sonatype OSS Snapshot Repository" at "https://oss.sonatype.org/content/repositories/snapshots/", - "Sonatype OSS Release Repository" at "https://oss.sonatype.org/content/repositories/releases/" +lazy val baseSettings = Seq( + organization := "com.chatwork", + homepage := Some(url("https://github.com/chatwork/scala-jwk")), + licenses := List("The MIT License" -> url("http://opensource.org/licenses/MIT")), + developers := List( + Developer( + id = "j5ik2o", + name = "Junichi Kato", + email = "j5ik2o@gmail.com", + url = url("https://blog.j5ik2o.me") + ), + Developer( + id = "exoego", + name = "TATSUNO Yasuhiro", + email = "ytatsuno.jp@gmail.com", + url = url("https://www.exoego.net") + ) + ), + scalaVersion := Versions.scala213Version, + crossScalaVersions := Seq(Versions.scala212Version, Versions.scala213Version, Versions.scala3Version), + scalacOptions ++= (Seq( + "-unchecked", + "-feature", + "-deprecation", + "-encoding", + "UTF-8", + "-language:_" + ) ++ crossScalacOptions(scalaVersion.value)), + resolvers ++= Seq( + Resolver.sonatypeRepo("snapshots") + ), + Test / publishArtifact := false, + Test / parallelExecution := false, + Compile / doc / sources := { + val old = (Compile / doc / sources).value + if (scalaVersion.value == Versions.scala3Version) { + Nil + } else { + old + } + }, + semanticdbEnabled := true, + semanticdbVersion := scalafixSemanticdb.revision, + // Remove me when scalafix is stable and feature-complete on Scala 3 + ThisBuild / scalafixScalaBinaryVersion := (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((2, _)) => CrossVersion.binaryScalaVersion(scalaVersion.value) + case _ => CrossVersion.binaryScalaVersion(Versions.scala212Version) + }) ) -libraryDependencies ++= Seq( - scalatest.scalatest % Test, - scalacheck.scalacheck % Test, - scalaLang.java8Compat, - j5ik2o.base64scala, - circe.core, - circe.generic, - circe.parser -) - -updateOptions := updateOptions.value.withCachedResolution(true) - -Test / parallelExecution := false - -Test / run / javaOptions ++= Seq("-Xms4g", "-Xmx4g", "-Xss10M", "-XX:+CMSClassUnloadingEnabled") - -publishMavenStyle := true - -Test / publishArtifact := false - -pomIncludeRepository := { _ => false } - -pomExtra := { - https://github.com/chatwork/scala-jwk - - - The MIT License - http://opensource.org/licenses/MIT - - - - git@github.com:chatwork/scala-jwk.git - scm:git:github.com/chatwork/scala-jwk - scm:git:git@github.com:chatwork/scala-jwk.git - - - - j5ik2o - Junichi Kato - - -} - -publishTo := sonatypePublishToBundle.value - -credentials := { - val ivyCredentials = (LocalRootProject / baseDirectory).value / ".credentials" - val gpgCredentials = (LocalRootProject / baseDirectory).value / ".gpgCredentials" - Credentials(ivyCredentials) :: Credentials(gpgCredentials) :: Nil -} +val library = (project in file("library")) + .settings(baseSettings) + .settings( + name := "scala-jwk", + libraryDependencies ++= Seq( + scalatest.scalatest % Test, + scalacheck.scalacheck % Test, + scalaLang.java8Compat, + j5ik2o.base64scala, + circe.core, + circe.generic, + circe.parser + ) + ) + +val root = (project in file(".")) + .settings(baseSettings) + .settings( + name := "scala-jwk-root", + publish / skip := true + ) + .aggregate(library) + +// --- Custom commands +addCommandAlias("lint", ";scalafmtCheck;test:scalafmtCheck;scalafmtSbtCheck;scalafixAll --check") +addCommandAlias("fmt", ";scalafmtAll;scalafmtSbt;scalafix RemoveUnused") diff --git a/src/main/scala/com/chatwork/scala/jwk/AlgorithmType.scala b/library/src/main/scala/com/chatwork/scala/jwk/AlgorithmType.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/AlgorithmType.scala rename to library/src/main/scala/com/chatwork/scala/jwk/AlgorithmType.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/AssymetricJWK.scala b/library/src/main/scala/com/chatwork/scala/jwk/AssymetricJWK.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/AssymetricJWK.scala rename to library/src/main/scala/com/chatwork/scala/jwk/AssymetricJWK.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/Base64StringJsonImplicits.scala b/library/src/main/scala/com/chatwork/scala/jwk/Base64StringJsonImplicits.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/Base64StringJsonImplicits.scala rename to library/src/main/scala/com/chatwork/scala/jwk/Base64StringJsonImplicits.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/ByteUtils.scala b/library/src/main/scala/com/chatwork/scala/jwk/ByteUtils.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/ByteUtils.scala rename to library/src/main/scala/com/chatwork/scala/jwk/ByteUtils.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/Curve.scala b/library/src/main/scala/com/chatwork/scala/jwk/Curve.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/Curve.scala rename to library/src/main/scala/com/chatwork/scala/jwk/Curve.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/CurveBasedJWK.scala b/library/src/main/scala/com/chatwork/scala/jwk/CurveBasedJWK.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/CurveBasedJWK.scala rename to library/src/main/scala/com/chatwork/scala/jwk/CurveBasedJWK.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/ECJWK.scala b/library/src/main/scala/com/chatwork/scala/jwk/ECJWK.scala similarity index 99% rename from src/main/scala/com/chatwork/scala/jwk/ECJWK.scala rename to library/src/main/scala/com/chatwork/scala/jwk/ECJWK.scala index 68e414a..26f66e0 100644 --- a/src/main/scala/com/chatwork/scala/jwk/ECJWK.scala +++ b/library/src/main/scala/com/chatwork/scala/jwk/ECJWK.scala @@ -111,7 +111,7 @@ object ECJWK extends ECJWKJsonImplicits { val SUPPORTED_CURVES = Set(Curve.P_256, Curve.P_256K, Curve.P_384, Curve.P_521) - private def ensurePublicCoordinatesOnCurve(curve: Curve, x: Base64String, y: Base64String) = { + private def ensurePublicCoordinatesOnCurve(curve: Curve, x: Base64String, y: Base64String): Unit = { require(SUPPORTED_CURVES.contains(curve), "Unknown / unsupported curve: " + curve) val result = for { dx <- x.decodeToBigInt @@ -299,7 +299,7 @@ class ECJWK private[jwk] ( state.map(_.hashCode()).foldLeft(super.hashCode())((a, b) => 31 * a + b) } - override def toString = + override def toString: String = Seq( curve, x, diff --git a/src/main/scala/com/chatwork/scala/jwk/ECParameterTable.scala b/library/src/main/scala/com/chatwork/scala/jwk/ECParameterTable.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/ECParameterTable.scala rename to library/src/main/scala/com/chatwork/scala/jwk/ECParameterTable.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/JWK.scala b/library/src/main/scala/com/chatwork/scala/jwk/JWK.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/JWK.scala rename to library/src/main/scala/com/chatwork/scala/jwk/JWK.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/JWKError.scala b/library/src/main/scala/com/chatwork/scala/jwk/JWKError.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/JWKError.scala rename to library/src/main/scala/com/chatwork/scala/jwk/JWKError.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/JWKMatcher.scala b/library/src/main/scala/com/chatwork/scala/jwk/JWKMatcher.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/JWKMatcher.scala rename to library/src/main/scala/com/chatwork/scala/jwk/JWKMatcher.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/JWKPrinter.scala b/library/src/main/scala/com/chatwork/scala/jwk/JWKPrinter.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/JWKPrinter.scala rename to library/src/main/scala/com/chatwork/scala/jwk/JWKPrinter.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/JWKSet.scala b/library/src/main/scala/com/chatwork/scala/jwk/JWKSet.scala similarity index 98% rename from src/main/scala/com/chatwork/scala/jwk/JWKSet.scala rename to library/src/main/scala/com/chatwork/scala/jwk/JWKSet.scala index 2a7ef9d..f7d6869 100644 --- a/src/main/scala/com/chatwork/scala/jwk/JWKSet.scala +++ b/library/src/main/scala/com/chatwork/scala/jwk/JWKSet.scala @@ -66,7 +66,6 @@ object JWKSet extends JWKSetJsonImplicits { trait JWKSetJsonImplicits extends JWKJsonImplicits { import io.circe.syntax._ - import cats.syntax.either._ implicit val JWKSetJsonEncoder: Encoder[JWKSet] = Encoder.instance { v => Json.obj( diff --git a/src/main/scala/com/chatwork/scala/jwk/JWKThumbprint.scala b/library/src/main/scala/com/chatwork/scala/jwk/JWKThumbprint.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/JWKThumbprint.scala rename to library/src/main/scala/com/chatwork/scala/jwk/JWKThumbprint.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/JWSAlgorithmType.scala b/library/src/main/scala/com/chatwork/scala/jwk/JWSAlgorithmType.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/JWSAlgorithmType.scala rename to library/src/main/scala/com/chatwork/scala/jwk/JWSAlgorithmType.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/JsType.scala b/library/src/main/scala/com/chatwork/scala/jwk/JsType.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/JsType.scala rename to library/src/main/scala/com/chatwork/scala/jwk/JsType.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/JsonImplicits.scala b/library/src/main/scala/com/chatwork/scala/jwk/JsonImplicits.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/JsonImplicits.scala rename to library/src/main/scala/com/chatwork/scala/jwk/JsonImplicits.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/KeyId.scala b/library/src/main/scala/com/chatwork/scala/jwk/KeyId.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/KeyId.scala rename to library/src/main/scala/com/chatwork/scala/jwk/KeyId.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/KeyOperationType.scala b/library/src/main/scala/com/chatwork/scala/jwk/KeyOperationType.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/KeyOperationType.scala rename to library/src/main/scala/com/chatwork/scala/jwk/KeyOperationType.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/KeyOperations.scala b/library/src/main/scala/com/chatwork/scala/jwk/KeyOperations.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/KeyOperations.scala rename to library/src/main/scala/com/chatwork/scala/jwk/KeyOperations.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/KeyType.scala b/library/src/main/scala/com/chatwork/scala/jwk/KeyType.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/KeyType.scala rename to library/src/main/scala/com/chatwork/scala/jwk/KeyType.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/KeyUseAndOpsConsistency.scala b/library/src/main/scala/com/chatwork/scala/jwk/KeyUseAndOpsConsistency.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/KeyUseAndOpsConsistency.scala rename to library/src/main/scala/com/chatwork/scala/jwk/KeyUseAndOpsConsistency.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/OtherPrimesInfo.scala b/library/src/main/scala/com/chatwork/scala/jwk/OtherPrimesInfo.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/OtherPrimesInfo.scala rename to library/src/main/scala/com/chatwork/scala/jwk/OtherPrimesInfo.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/PublicKeyUseType.scala b/library/src/main/scala/com/chatwork/scala/jwk/PublicKeyUseType.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/PublicKeyUseType.scala rename to library/src/main/scala/com/chatwork/scala/jwk/PublicKeyUseType.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/RSAJWK.scala b/library/src/main/scala/com/chatwork/scala/jwk/RSAJWK.scala similarity index 98% rename from src/main/scala/com/chatwork/scala/jwk/RSAJWK.scala rename to library/src/main/scala/com/chatwork/scala/jwk/RSAJWK.scala index cb0f3b3..fe8a8c1 100644 --- a/src/main/scala/com/chatwork/scala/jwk/RSAJWK.scala +++ b/library/src/main/scala/com/chatwork/scala/jwk/RSAJWK.scala @@ -416,10 +416,10 @@ class RSAJWK private[jwk] ( ) } yield spec }.getOrElse { - Right[PrivateKeyCreationError, RSAPrivateKeySpec]( - new RSAPrivateKeySpec(_modulus.bigInteger, _privateExponent.bigInteger) - ) - } + Right[PrivateKeyCreationError, RSAPrivateKeySpec]( + new RSAPrivateKeySpec(_modulus.bigInteger, _privateExponent.bigInteger) + ) + } } private def createInternalPrivateKeySpec( @@ -450,7 +450,10 @@ class RSAJWK private[jwk] ( .left .map(e => PrivateKeyCreationError(e.message)) } yield new RSAOtherPrimeInfo(otherPrime, otherPrimeExponent, otherCrtCoefficient) - for { result <- r; _e <- e } yield result :+ _e + for { + result <- r + _e <- e + } yield result :+ _e } .map { otherPrimeSeq => if (otherPrimeSeq.nonEmpty) diff --git a/src/main/scala/com/chatwork/scala/jwk/Requirement.scala b/library/src/main/scala/com/chatwork/scala/jwk/Requirement.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/Requirement.scala rename to library/src/main/scala/com/chatwork/scala/jwk/Requirement.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/URIJsonImplicits.scala b/library/src/main/scala/com/chatwork/scala/jwk/URIJsonImplicits.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/URIJsonImplicits.scala rename to library/src/main/scala/com/chatwork/scala/jwk/URIJsonImplicits.scala diff --git a/src/main/scala/com/chatwork/scala/jwk/utils/ECChecks.scala b/library/src/main/scala/com/chatwork/scala/jwk/utils/ECChecks.scala similarity index 100% rename from src/main/scala/com/chatwork/scala/jwk/utils/ECChecks.scala rename to library/src/main/scala/com/chatwork/scala/jwk/utils/ECChecks.scala diff --git a/src/test/scala/com/chatwork/scala/jwk/ECJWKSpec.scala b/library/src/test/scala/com/chatwork/scala/jwk/ECJWKSpec.scala similarity index 99% rename from src/test/scala/com/chatwork/scala/jwk/ECJWKSpec.scala rename to library/src/test/scala/com/chatwork/scala/jwk/ECJWKSpec.scala index 6762880..8008aa7 100644 --- a/src/test/scala/com/chatwork/scala/jwk/ECJWKSpec.scala +++ b/library/src/test/scala/com/chatwork/scala/jwk/ECJWKSpec.scala @@ -53,7 +53,7 @@ class ECJWKSpec extends AnyFreeSpec with Matchers with ECJWKJsonImplicits with E jwk match { case Left(e: JWKCreationError) => println(e.message) - case Left(e) => + case Left(_) => fail() case Right(_) => fail() diff --git a/src/test/scala/com/chatwork/scala/jwk/JWKSetSpec.scala b/library/src/test/scala/com/chatwork/scala/jwk/JWKSetSpec.scala similarity index 99% rename from src/test/scala/com/chatwork/scala/jwk/JWKSetSpec.scala rename to library/src/test/scala/com/chatwork/scala/jwk/JWKSetSpec.scala index 4a0d6ab..2b744f4 100644 --- a/src/test/scala/com/chatwork/scala/jwk/JWKSetSpec.scala +++ b/library/src/test/scala/com/chatwork/scala/jwk/JWKSetSpec.scala @@ -1,7 +1,6 @@ package com.chatwork.scala.jwk import com.github.j5ik2o.base64scala.Base64String -import cats.syntax.either._ import io.circe.parser._ import org.scalatest.matchers.should.Matchers import org.scalatest.freespec.AnyFreeSpec diff --git a/src/test/scala/com/chatwork/scala/jwk/KeyIdSpec.scala b/library/src/test/scala/com/chatwork/scala/jwk/KeyIdSpec.scala similarity index 98% rename from src/test/scala/com/chatwork/scala/jwk/KeyIdSpec.scala rename to library/src/test/scala/com/chatwork/scala/jwk/KeyIdSpec.scala index dba7ce5..68a861e 100644 --- a/src/test/scala/com/chatwork/scala/jwk/KeyIdSpec.scala +++ b/library/src/test/scala/com/chatwork/scala/jwk/KeyIdSpec.scala @@ -8,7 +8,6 @@ import java.util.UUID import com.github.j5ik2o.base64scala.Base64String import org.scalatest.matchers.should.Matchers import org.scalatest.freespec.AnyFreeSpec -import cats.syntax.either._ class KeyIdSpec extends AnyFreeSpec with Matchers { diff --git a/src/test/scala/com/chatwork/scala/jwk/RSAJWKSpec.scala b/library/src/test/scala/com/chatwork/scala/jwk/RSAJWKSpec.scala similarity index 99% rename from src/test/scala/com/chatwork/scala/jwk/RSAJWKSpec.scala rename to library/src/test/scala/com/chatwork/scala/jwk/RSAJWKSpec.scala index 734aa2a..c5e41d7 100644 --- a/src/test/scala/com/chatwork/scala/jwk/RSAJWKSpec.scala +++ b/library/src/test/scala/com/chatwork/scala/jwk/RSAJWKSpec.scala @@ -10,7 +10,6 @@ import io.circe.parser._ import io.circe.syntax._ import org.scalatest.matchers.should.Matchers import org.scalatest.freespec.AnyFreeSpec -import cats.syntax.either._ class RSAJWKSpec extends AnyFreeSpec with Matchers with RSAJWKJsonImplicits { val base64StringFactory = Base64StringFactory(urlSafe = true, isNoPadding = true) diff --git a/project/Dependencies.scala b/project/Dependencies.scala index a018d42..108b3a8 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -1,6 +1,12 @@ import sbt._ import sbt.ModuleID +object Versions { + val scala212Version = "2.12.13" + val scala213Version = "2.13.6" + val scala3Version = "3.0.1" +} + object scalaLang { val java8Compat = "org.scala-lang.modules" %% "scala-java8-compat" % "1.0.0" } diff --git a/project/plugins.sbt b/project/plugins.sbt index 1dbfe02..86ed721 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,12 +1,9 @@ -resolvers ++= Seq( - "Sonatype OSS Snapshot Repository" at "https://oss.sonatype.org/content/repositories/snapshots/", - "Sonatype OSS Release Repository" at "https://oss.sonatype.org/content/repositories/releases/" -) +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.3") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") -addSbtPlugin("com.github.sbt" % "sbt-release" % "1.0.15") +addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.3") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.29") -addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") +addDependencyTreePlugin diff --git a/release.sbt b/release.sbt deleted file mode 100644 index ad87ae5..0000000 --- a/release.sbt +++ /dev/null @@ -1,24 +0,0 @@ -import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._ - -releaseCrossBuild := true - -releaseProcess := Seq[ReleaseStep]( - checkSnapshotDependencies, - inquireVersions, - runClean, - setReleaseVersion, - commitReleaseVersion, - tagRelease, - ReleaseStep( - action = { state => - val extracted = Project extract state - extracted.runAggregated(PgpKeys.publishSigned in Global in extracted.get(thisProjectRef), state) - }, - enableCrossBuild = true - ), - releaseStepCommandAndRemaining("+publishSigned"), - releaseStepCommand("sonatypeBundleRelease"), - setNextVersion, - commitNextVersion, - pushChanges -) diff --git a/scalafmt.sbt b/scalafmt.sbt deleted file mode 100644 index 32f27ee..0000000 --- a/scalafmt.sbt +++ /dev/null @@ -1,3 +0,0 @@ -//scalafmtVersion in ThisBuild := "1.4.0" -scalafmtOnCompile in ThisBuild := true -//scalafmtTestOnCompile in ThisBuild := true diff --git a/version.sbt b/version.sbt deleted file mode 100644 index ab92045..0000000 --- a/version.sbt +++ /dev/null @@ -1 +0,0 @@ -version in ThisBuild := "1.1.1-SNAPSHOT"