From b8b43e2199e22e01b503f3e251a9f34675a53297 Mon Sep 17 00:00:00 2001 From: Juan Pedro Moreno Date: Tue, 17 Dec 2019 18:22:10 +0100 Subject: [PATCH 1/7] Removes support for Scala 2.11 and ScalaJS --- .travis.yml | 30 +-- README.md | 14 -- build.sbt | 42 +--- .../AsyncHttpRequestBuilderExtensionJS.scala | 60 ------ .../github4s/cats/effect/js/Implicits.scala | 19 -- .../github4s/cats/effect/js/ImplicitsJS.scala | 29 --- .../cats/effect/js/CatsEffectJSSpec.scala | 71 ------- .../cats/effect/SyncCaptureInstance.scala | 0 .../github4s/cats/effect/jvm/Implicits.scala | 0 .../cats/effect/jvm/ImplicitsJVM.scala | 0 .../cats/effect/jvm/CatsEffectJVMSpec.scala | 0 docs/src/main/tut/activity.md | 3 - docs/src/main/tut/auth.md | 7 - docs/src/main/tut/docs.md | 40 ---- docs/src/main/tut/gist.md | 3 - docs/src/main/tut/git_data.md | 3 - docs/src/main/tut/index.md | 16 +- docs/src/main/tut/issue.md | 3 - docs/src/main/tut/organization.md | 3 - docs/src/main/tut/pull_request.md | 3 - docs/src/main/tut/repository.md | 3 - docs/src/main/tut/user.md | 3 - .../HttpRequestBuilderExtensionJS.scala | 111 ---------- .../main/scala/github4s/js/Implicits.scala | 19 -- .../main/scala/github4s/js/ImplicitsJS.scala | 32 --- .../main/scala/github4s/util/URLEncoder.scala | 24 --- .../integration/IntegrationSpec.scala | 45 ---- .../scala/github4s/utils/TestUtilsJS.scala | 26 --- github4s/jvm/src/test/resources/logback.xml | 15 -- .../scala/github4s/api/PullRequests.scala | 196 ------------------ .../src/main/resources/application.conf | 0 .../src/main/scala/github4s/Decoders.scala | 26 +-- .../src/main/scala/github4s/Encoders.scala | 3 +- .../src/main/scala/github4s/Github.scala | 0 .../src/main/scala/github4s/GithubAPIs.scala | 0 .../scala/github4s/GithubDefaultUrls.scala | 0 .../main/scala/github4s/GithubResponses.scala | 4 +- .../src/main/scala/github4s/HttpClient.scala | 0 .../scala/github4s/HttpClientExtension.scala | 0 .../HttpRequestBuilderExtensionJVM.scala | 0 .../src/main/scala/github4s/Implicits.scala | 2 +- .../main/scala/github4s/api/Activities.scala | 0 .../src/main/scala/github4s/api/Auth.scala | 0 .../src/main/scala/github4s/api/Gists.scala | 0 .../src/main/scala/github4s/api/GitData.scala | 2 +- .../src/main/scala/github4s/api/Issues.scala | 23 +- .../scala/github4s/api/Organizations.scala | 2 +- .../scala/github4s/api/PullRequests.scala | 193 +++++++++++++++++ .../src/main/scala/github4s/api/Repos.scala | 28 +-- .../src/main/scala/github4s/api/Users.scala | 20 +- .../src/main/scala/github4s/api/package.scala | 0 .../src/main/scala/github4s/app.scala | 0 .../github4s/free/algebra/ActivityOps.scala | 0 .../scala/github4s/free/algebra/AuthOps.scala | 16 +- .../scala/github4s/free/algebra/GistOps.scala | 0 .../github4s/free/algebra/GitDataOps.scala | 60 +++--- .../github4s/free/algebra/IssuesOps.scala | 0 .../free/algebra/OrganizationOps.scala | 6 +- .../free/algebra/PullRequestOps.scala | 138 ++++++------ .../github4s/free/algebra/RepositoryOps.scala | 3 +- .../scala/github4s/free/algebra/UserOps.scala | 5 +- .../scala/github4s/free/domain/Activity.scala | 0 .../github4s/free/domain/Authorization.scala | 0 .../scala/github4s/free/domain/Gist.scala | 0 .../scala/github4s/free/domain/GitData.scala | 28 ++- .../scala/github4s/free/domain/Issue.scala | 0 .../github4s/free/domain/Pagination.scala | 0 .../github4s/free/domain/PullRequest.scala | 0 .../github4s/free/domain/Repository.scala | 12 +- .../github4s/free/domain/SearchParam.scala | 0 .../scala/github4s/free/domain/User.scala | 0 .../free/interpreters/Interpreters.scala | 21 +- .../main/scala/github4s/jvm/Implicits.scala | 0 .../scala/github4s/jvm/ImplicitsJVM.scala | 0 .../main/scala/github4s/util/URLEncoder.scala | 0 .../{js => }/src/test/resources/logback.xml | 0 .../integration/GHActivitiesSpec.scala | 16 +- .../github4s/integration/GHAuthSpec.scala | 0 .../github4s/integration/GHGitDataSpec.scala | 33 +-- .../github4s/integration/GHIssuesSpec.scala | 0 .../integration/GHOrganizationsSpec.scala | 4 +- .../integration/GHPullRequestsSpec.scala | 12 +- .../github4s/integration/GHReposSpec.scala | 4 +- .../github4s/integration/GHUsersSpec.scala | 2 +- .../integration/IntegrationSpec.scala | 0 .../scala/github4s/unit/ActivitiesSpec.scala | 0 .../test/scala/github4s/unit/ApiSpec.scala | 0 .../test/scala/github4s/unit/AuthSpec.scala | 0 .../scala/github4s/unit/DecodersSpec.scala | 0 .../scala/github4s/unit/EncodersSpec.scala | 0 .../github4s/unit/GHActivitiesSpec.scala | 0 .../test/scala/github4s/unit/GHAuthSpec.scala | 0 .../test/scala/github4s/unit/GHGistSpec.scala | 34 ++- .../scala/github4s/unit/GHGitDataSpec.scala | 22 +- .../scala/github4s/unit/GHIssuesSpec.scala | 0 .../github4s/unit/GHOrganizationsSpec.scala | 0 .../github4s/unit/GHPullRequestsSpec.scala | 12 +- .../scala/github4s/unit/GHReposSpec.scala | 0 .../test/scala/github4s/unit/GHUserSpec.scala | 0 .../test/scala/github4s/unit/GistSpec.scala | 5 +- .../scala/github4s/unit/GitDataSpec.scala | 15 +- .../test/scala/github4s/unit/IssuesSpec.scala | 10 +- .../github4s/unit/OrganizationsSpec.scala | 0 .../github4s/unit/PullRequestsSpec.scala | 9 +- .../test/scala/github4s/unit/ReposSpec.scala | 0 .../test/scala/github4s/unit/UserSpec.scala | 0 .../github4s/utils/BaseIntegrationSpec.scala | 11 +- .../test/scala/github4s/utils/BaseSpec.scala | 5 +- .../github4s/utils/DummyGithubUrls.scala | 0 .../scala/github4s/utils/FakeResponses.scala | 4 +- .../github4s/utils/MockGithubApiServer.scala | 0 .../github4s/utils/MockServerService.scala | 0 .../test/scala/github4s/utils/TestData.scala | 0 .../scala/github4s/utils/TestUtilsJVM.scala | 0 project/ProjectPlugin.scala | 41 +--- project/plugins.sbt | 7 +- .../scala/github4s/scalaz/Implicits.scala | 59 ------ 117 files changed, 529 insertions(+), 1188 deletions(-) delete mode 100644 cats-effect/js/src/main/scala/github4s/cats/effect/AsyncHttpRequestBuilderExtensionJS.scala delete mode 100644 cats-effect/js/src/main/scala/github4s/cats/effect/js/Implicits.scala delete mode 100644 cats-effect/js/src/main/scala/github4s/cats/effect/js/ImplicitsJS.scala delete mode 100644 cats-effect/js/src/test/scala/github4s/cats/effect/js/CatsEffectJSSpec.scala rename cats-effect/{shared => }/src/main/scala/github4s/cats/effect/SyncCaptureInstance.scala (100%) rename cats-effect/{jvm => }/src/main/scala/github4s/cats/effect/jvm/Implicits.scala (100%) rename cats-effect/{jvm => }/src/main/scala/github4s/cats/effect/jvm/ImplicitsJVM.scala (100%) rename cats-effect/{jvm => }/src/test/scala/github4s/cats/effect/jvm/CatsEffectJVMSpec.scala (100%) delete mode 100644 github4s/js/src/main/scala/github4s/HttpRequestBuilderExtensionJS.scala delete mode 100644 github4s/js/src/main/scala/github4s/js/Implicits.scala delete mode 100644 github4s/js/src/main/scala/github4s/js/ImplicitsJS.scala delete mode 100644 github4s/js/src/main/scala/github4s/util/URLEncoder.scala delete mode 100644 github4s/js/src/test/scala/github4s/integration/IntegrationSpec.scala delete mode 100644 github4s/js/src/test/scala/github4s/utils/TestUtilsJS.scala delete mode 100644 github4s/jvm/src/test/resources/logback.xml delete mode 100644 github4s/shared/src/main/scala/github4s/api/PullRequests.scala rename github4s/{shared => }/src/main/resources/application.conf (100%) rename github4s/{shared => }/src/main/scala/github4s/Decoders.scala (94%) rename github4s/{shared => }/src/main/scala/github4s/Encoders.scala (96%) rename github4s/{shared => }/src/main/scala/github4s/Github.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/GithubAPIs.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/GithubDefaultUrls.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/GithubResponses.scala (96%) rename github4s/{shared => }/src/main/scala/github4s/HttpClient.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/HttpClientExtension.scala (100%) rename github4s/{jvm => }/src/main/scala/github4s/HttpRequestBuilderExtensionJVM.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/Implicits.scala (98%) rename github4s/{shared => }/src/main/scala/github4s/api/Activities.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/api/Auth.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/api/Gists.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/api/GitData.scala (99%) rename github4s/{shared => }/src/main/scala/github4s/api/Issues.scala (95%) rename github4s/{shared => }/src/main/scala/github4s/api/Organizations.scala (99%) create mode 100644 github4s/src/main/scala/github4s/api/PullRequests.scala rename github4s/{shared => }/src/main/scala/github4s/api/Repos.scala (96%) rename github4s/{shared => }/src/main/scala/github4s/api/Users.scala (85%) rename github4s/{shared => }/src/main/scala/github4s/api/package.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/app.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/algebra/ActivityOps.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/algebra/AuthOps.scala (88%) rename github4s/{shared => }/src/main/scala/github4s/free/algebra/GistOps.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/algebra/GitDataOps.scala (87%) rename github4s/{shared => }/src/main/scala/github4s/free/algebra/IssuesOps.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/algebra/OrganizationOps.scala (91%) rename github4s/{shared => }/src/main/scala/github4s/free/algebra/PullRequestOps.scala (71%) rename github4s/{shared => }/src/main/scala/github4s/free/algebra/RepositoryOps.scala (98%) rename github4s/{shared => }/src/main/scala/github4s/free/algebra/UserOps.scala (94%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/Activity.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/Authorization.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/Gist.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/GitData.scala (83%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/Issue.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/Pagination.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/PullRequest.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/Repository.scala (97%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/SearchParam.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/domain/User.scala (100%) rename github4s/{shared => }/src/main/scala/github4s/free/interpreters/Interpreters.scala (96%) rename github4s/{jvm => }/src/main/scala/github4s/jvm/Implicits.scala (100%) rename github4s/{jvm => }/src/main/scala/github4s/jvm/ImplicitsJVM.scala (100%) rename github4s/{jvm => }/src/main/scala/github4s/util/URLEncoder.scala (100%) rename github4s/{js => }/src/test/resources/logback.xml (100%) rename github4s/{shared => }/src/test/scala/github4s/integration/GHActivitiesSpec.scala (92%) rename github4s/{shared => }/src/test/scala/github4s/integration/GHAuthSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/integration/GHGitDataSpec.scala (85%) rename github4s/{shared => }/src/test/scala/github4s/integration/GHIssuesSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/integration/GHOrganizationsSpec.scala (95%) rename github4s/{shared => }/src/test/scala/github4s/integration/GHPullRequestsSpec.scala (95%) rename github4s/{shared => }/src/test/scala/github4s/integration/GHReposSpec.scala (98%) rename github4s/{shared => }/src/test/scala/github4s/integration/GHUsersSpec.scala (98%) rename github4s/{jvm => }/src/test/scala/github4s/integration/IntegrationSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/ActivitiesSpec.scala (100%) rename github4s/{jvm => }/src/test/scala/github4s/unit/ApiSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/AuthSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/DecodersSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/EncodersSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/GHActivitiesSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/GHAuthSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/GHGistSpec.scala (80%) rename github4s/{shared => }/src/test/scala/github4s/unit/GHGitDataSpec.scala (93%) rename github4s/{shared => }/src/test/scala/github4s/unit/GHIssuesSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/GHOrganizationsSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/GHPullRequestsSpec.scala (95%) rename github4s/{shared => }/src/test/scala/github4s/unit/GHReposSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/GHUserSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/GistSpec.scala (95%) rename github4s/{shared => }/src/test/scala/github4s/unit/GitDataSpec.scala (96%) rename github4s/{shared => }/src/test/scala/github4s/unit/IssuesSpec.scala (97%) rename github4s/{shared => }/src/test/scala/github4s/unit/OrganizationsSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/PullRequestsSpec.scala (96%) rename github4s/{shared => }/src/test/scala/github4s/unit/ReposSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/unit/UserSpec.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/utils/BaseIntegrationSpec.scala (87%) rename github4s/{shared => }/src/test/scala/github4s/utils/BaseSpec.scala (97%) rename github4s/{shared => }/src/test/scala/github4s/utils/DummyGithubUrls.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/utils/FakeResponses.scala (99%) rename github4s/{jvm => }/src/test/scala/github4s/utils/MockGithubApiServer.scala (100%) rename github4s/{jvm => }/src/test/scala/github4s/utils/MockServerService.scala (100%) rename github4s/{shared => }/src/test/scala/github4s/utils/TestData.scala (100%) rename github4s/{jvm => }/src/test/scala/github4s/utils/TestUtilsJVM.scala (100%) delete mode 100644 scalaz/src/main/scala/github4s/scalaz/Implicits.scala diff --git a/.travis.yml b/.travis.yml index 37fe3239e..eda1c357c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,20 +3,7 @@ language: scala dist: trusty scala: -- 2.11.12 -- 2.12.8 - -env: -- SCALAENV=jvm -- SCALAENV=js -- SCALAENV=all -- G4SBUILD=docs - -matrix: - exclude: - - scala: 2.11.12 - env: G4SBUILD=docs - - env: SCALAENV=all +- 2.12.10 jdk: - oraclejdk11 @@ -42,16 +29,8 @@ before_script: - sudo chmod +x /usr/local/bin/sbt script: -- if [ "$SCALAENV" = "jvm" ]; then - sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT validateJVM; - elif [ "$SCALAENV" = "js" ]; then - sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT compile; - sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT validateJS; - elif [ "$G4SBUILD" = "docs" ]; then - sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT docs/tut; - else - echo "You might not be invited to the party"; - fi +- sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT validate; +- sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT docs/tut; after_success: - bash <(curl -s https://codecov.io/bash) @@ -73,8 +52,7 @@ jobs: sbt docs/publishMicrosite; fi fi - scala: 2.12.8 - env: SCALAENV=all + scala: 2.12.10 before_cache: - du -h -d 1 $HOME/.ivy2/cache diff --git a/README.md b/README.md index 46fdc37e7..58f917f58 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,8 @@ Github4s ## Installation -Github4s is compatible with both Scala JVM and Scala.js. It supports 2.10, 2.11 and 2.12. - To get started with SBT, simply add the following to your build.sbt file. -For Scala.jvm: - [comment]: # (Start Replace) ```scala @@ -26,16 +22,6 @@ libraryDependencies += "com.47deg" %% "github4s" % "0.20.1" [comment]: # (End Replace) -For Scala.js: - -[comment]: # (Start Replace) - -```scala -libraryDependencies += "com.47deg" %%% "github4s" % "0.20.1" -``` - -[comment]: # (End Replace) - ## Github4s in the wild If you wish to add your library here please consider a PR to include it in the list below. diff --git a/build.sbt b/build.sbt index c80d5526c..c4a92c78e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,4 @@ import sbtorgpolicies.runnable.syntax._ -// shadow sbt-scalajs' crossProject and CrossType from Scala.js 0.6.x -import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType} pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray) pgpPublicRing := file(s"$gpgFolder/pubring.gpg") @@ -13,7 +11,7 @@ lazy val root = (project in file(".")) .settings(noPublishSettings: _*) lazy val github4s = - (crossProject(JSPlatform, JVMPlatform) in file("github4s")) + (project in file("github4s")) .settings(moduleName := "github4s") .enablePlugins(BuildInfoPlugin) .settings( @@ -23,48 +21,19 @@ lazy val github4s = "token" -> sys.env.getOrElse("GITHUB4S_ACCESS_TOKEN", "")), buildInfoPackage := "github4s" ) - .settings(commonCrossDeps: _*) - .settings(standardCommonDeps: _*) - .jvmSettings(jvmDeps: _*) - .jsSettings(jsDeps: _*) - .jsSettings(sharedJsSettings: _*) - .jsSettings(testSettings: _*) - -lazy val github4sJVM = github4s.jvm -lazy val github4sJS = github4s.js - -lazy val scalaz = (project in file("scalaz")) - .settings(moduleName := "github4s-scalaz") - .settings(scalazDependencies: _*) - .dependsOn(github4sJVM) + .settings(coreDeps: _*) lazy val catsEffect = - (crossProject(JSPlatform, JVMPlatform) in file("cats-effect")) + (project in file("cats-effect")) .settings(moduleName := "github4s-cats-effect") .settings(catsEffectDependencies: _*) - .jsSettings(sharedJsSettings: _*) - .jsSettings(testSettings: _*) .dependsOn(github4s) -lazy val catsEffectJVM = catsEffect.jvm -lazy val catsEffectJS = catsEffect.js - ///////////////////// //// ALL MODULES //// ///////////////////// -lazy val jvmModules: Seq[ProjectReference] = Seq( - github4sJVM, - scalaz, - catsEffectJVM -) - -lazy val jsModules: Seq[ProjectReference] = Seq( - github4sJS, - catsEffectJS -) - -lazy val allModules: Seq[ProjectReference] = jvmModules ++ jsModules +lazy val allModules: Seq[ProjectReference] = Seq(github4s, catsEffect) lazy val allModulesDeps: Seq[ClasspathDependency] = allModules.map(ClasspathDependency(_, None)) @@ -86,8 +55,7 @@ lazy val docs = (project in file("docs")) ////////// addCommandAlias("validateDocs", ";project docs;tut;project root") -addCommandAlias("validateJVM", (toCompileTestList(jvmModules) ++ List("project root")).asCmd) -addCommandAlias("validateJS", (toCompileTestList(jsModules) ++ List("project root")).asCmd) +addCommandAlias("validateJVM", (toCompileTestList(allModules) ++ List("project root")).asCmd) addCommandAlias( "validate", ";clean;compile;coverage;validateJVM;coverageReport;coverageAggregate;coverageOff") diff --git a/cats-effect/js/src/main/scala/github4s/cats/effect/AsyncHttpRequestBuilderExtensionJS.scala b/cats-effect/js/src/main/scala/github4s/cats/effect/AsyncHttpRequestBuilderExtensionJS.scala deleted file mode 100644 index b4b4f8976..000000000 --- a/cats-effect/js/src/main/scala/github4s/cats/effect/AsyncHttpRequestBuilderExtensionJS.scala +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.cats.effect - -import scala.concurrent.{ExecutionContext, Future} - -import cats.Eval -import cats.effect.Async -import fr.hmil.roshttp.response.SimpleHttpResponse -import github4s.{HttpRequestBuilder, HttpRequestBuilderExtension, HttpRequestBuilderExtensionJS} -import github4s.GithubResponses.GHResponse -import io.circe.Decoder - -trait AsyncHttpRequestBuilderExtensionJS extends HttpRequestBuilderExtensionJS { - - import monix.execution.Scheduler.Implicits.global - - implicit def extensionAsyncJS[F[_]: Async]: HttpRequestBuilderExtension[SimpleHttpResponse, F] = - new HttpRequestBuilderExtension[SimpleHttpResponse, F] { - - def run[A](rb: HttpRequestBuilder[SimpleHttpResponse, F])( - implicit D: Decoder[A]): F[GHResponse[A]] = - runMapWrapper[A](rb, decodeEntity[A]) - - def runEmpty(rb: HttpRequestBuilder[SimpleHttpResponse, F]): F[GHResponse[Unit]] = - runMapWrapper[Unit](rb, emptyResponse) - - private[this] def runMapWrapper[A]( - rb: HttpRequestBuilder[SimpleHttpResponse, F], - mapResponse: SimpleHttpResponse => GHResponse[A]): F[GHResponse[A]] = - fromFuture(runMap[A, F](rb, mapResponse)) - - /** Taken from Http4s **/ - private def fromFuture[A](future: Eval[Future[A]])(implicit ec: ExecutionContext): F[A] = - Async[F].async { cb => - import scala.util.{Failure, Success} - future.value.onComplete { - case Failure(e) => cb(Left(e)) - case Success(a) => cb(Right(a)) - } - } - private def fromFuture[A](future: => Future[A])(implicit ec: ExecutionContext): F[A] = - fromFuture(Eval.always(future)) - - } -} diff --git a/cats-effect/js/src/main/scala/github4s/cats/effect/js/Implicits.scala b/cats-effect/js/src/main/scala/github4s/cats/effect/js/Implicits.scala deleted file mode 100644 index 119e463af..000000000 --- a/cats-effect/js/src/main/scala/github4s/cats/effect/js/Implicits.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.cats.effect.js - -object Implicits extends ImplicitsJS \ No newline at end of file diff --git a/cats-effect/js/src/main/scala/github4s/cats/effect/js/ImplicitsJS.scala b/cats-effect/js/src/main/scala/github4s/cats/effect/js/ImplicitsJS.scala deleted file mode 100644 index 96ce4ec0d..000000000 --- a/cats-effect/js/src/main/scala/github4s/cats/effect/js/ImplicitsJS.scala +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.cats.effect.js - -import cats.effect.Async -import fr.hmil.roshttp.response.SimpleHttpResponse -import github4s.HttpRequestBuilderExtensionJS -import github4s.cats.effect.{AsyncHttpRequestBuilderExtensionJS, SyncCaptureInstance} -import github4s.free.interpreters.Interpreters -import github4s.implicits._ - -trait ImplicitsJS extends AsyncHttpRequestBuilderExtensionJS with SyncCaptureInstance { - implicit def intInstanceAsyncRosHttp[F[_]: Async] = - new Interpreters[F, SimpleHttpResponse] -} diff --git a/cats-effect/js/src/test/scala/github4s/cats/effect/js/CatsEffectJSSpec.scala b/cats-effect/js/src/test/scala/github4s/cats/effect/js/CatsEffectJSSpec.scala deleted file mode 100644 index f210d787f..000000000 --- a/cats-effect/js/src/test/scala/github4s/cats/effect/js/CatsEffectJSSpec.scala +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.cats.effect.js - -import cats.effect.IO -import github4s.Github -import github4s.Github._ -import github4s.cats.effect.js.Implicits._ -import org.scalatest.{Assertion, AsyncFunSuite, Matchers} -import fr.hmil.roshttp.response.SimpleHttpResponse -import github4s.GithubResponses.GHResponse -import github4s.free.domain.User - -import scala.concurrent.{ExecutionContext, ExecutionContextExecutor} -import scala.scalajs.js - -class CatsEffectJSSpec extends AsyncFunSuite with Matchers { - - implicit override def executionContext: ExecutionContextExecutor = ExecutionContext.global - - val accessToken = - js.Dynamic.global.process.env.GITHUB4S_ACCESS_TOKEN.asInstanceOf[js.UndefOr[String]].toOption - val headerUserAgent = Map("user-agent" -> "github4s") - val validUsername = "rafaparadela" - val invalidUsername = "GHInvalidUserName" - val okStatusCode = 200 - - test("return a succeded result for a valid call") { - val response = Github(accessToken).users - .get(validUsername) - .exec[IO, SimpleHttpResponse](headerUserAgent) - - response - .unsafeToFuture() - .map { r: GHResponse[User] => - r.isRight shouldBe true - r.right.map(_.statusCode) shouldBe Right(okStatusCode) - } - } - - test("return a failed result for an invalid call") { - val response = Github(accessToken).users - .get(invalidUsername) - .exec[IO, SimpleHttpResponse](headerUserAgent) - - response - .unsafeToFuture() - .map { r: GHResponse[User] => - r.isLeft shouldBe true - } - } - - // only here for the 80% coverage, to remove once JS makes use of Captures - test("IOCapture == IO.apply") { - syncCaptureInstance[IO].capture("a").unsafeRunSync shouldBe IO("a").unsafeRunSync - } -} diff --git a/cats-effect/shared/src/main/scala/github4s/cats/effect/SyncCaptureInstance.scala b/cats-effect/src/main/scala/github4s/cats/effect/SyncCaptureInstance.scala similarity index 100% rename from cats-effect/shared/src/main/scala/github4s/cats/effect/SyncCaptureInstance.scala rename to cats-effect/src/main/scala/github4s/cats/effect/SyncCaptureInstance.scala diff --git a/cats-effect/jvm/src/main/scala/github4s/cats/effect/jvm/Implicits.scala b/cats-effect/src/main/scala/github4s/cats/effect/jvm/Implicits.scala similarity index 100% rename from cats-effect/jvm/src/main/scala/github4s/cats/effect/jvm/Implicits.scala rename to cats-effect/src/main/scala/github4s/cats/effect/jvm/Implicits.scala diff --git a/cats-effect/jvm/src/main/scala/github4s/cats/effect/jvm/ImplicitsJVM.scala b/cats-effect/src/main/scala/github4s/cats/effect/jvm/ImplicitsJVM.scala similarity index 100% rename from cats-effect/jvm/src/main/scala/github4s/cats/effect/jvm/ImplicitsJVM.scala rename to cats-effect/src/main/scala/github4s/cats/effect/jvm/ImplicitsJVM.scala diff --git a/cats-effect/jvm/src/test/scala/github4s/cats/effect/jvm/CatsEffectJVMSpec.scala b/cats-effect/src/test/scala/github4s/cats/effect/jvm/CatsEffectJVMSpec.scala similarity index 100% rename from cats-effect/jvm/src/test/scala/github4s/cats/effect/jvm/CatsEffectJVMSpec.scala rename to cats-effect/src/test/scala/github4s/cats/effect/jvm/CatsEffectJVMSpec.scala diff --git a/docs/src/main/tut/activity.md b/docs/src/main/tut/activity.md index d5889fe91..5bf7a49bc 100644 --- a/docs/src/main/tut/activity.md +++ b/docs/src/main/tut/activity.md @@ -21,9 +21,6 @@ import github4s.Github import github4s.Github._ import github4s.jvm.Implicits._ import scalaj.http.HttpResponse -// if you're using ScalaJS, replace occurrences of HttpResponse by SimpleHttpResponse -//import github4s.js.Implicits._ -//import fr.hmil.roshttp.response.SimpleHttpResponse val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") ``` diff --git a/docs/src/main/tut/auth.md b/docs/src/main/tut/auth.md index 9b9719cc6..a2879e079 100644 --- a/docs/src/main/tut/auth.md +++ b/docs/src/main/tut/auth.md @@ -21,13 +21,6 @@ import github4s.jvm.Implicits._ import scalaj.http.HttpResponse ``` -for ScalaJS (replace occurrences of HttpResponse by SimpleHttpResponse): - -```scala -import github4s.js.Implicits._ -import fr.hmil.roshttp.response.SimpleHttpResponse -``` - **NOTE**: In the examples you will see `Github(None)` because if you are authenticating for the first time you don't have any access token yet. diff --git a/docs/src/main/tut/docs.md b/docs/src/main/tut/docs.md index 925ae2a78..3cc5c097a 100755 --- a/docs/src/main/tut/docs.md +++ b/docs/src/main/tut/docs.md @@ -26,12 +26,6 @@ implicits in your scope, depending on your needs: import github4s.jvm.Implicits._ ``` -for ScalaJS: - -```scala -import github4s.js.Implicits._ -``` - ```tut:invisible val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") ``` @@ -59,11 +53,6 @@ val user1 = Github(accessToken).users.get("rafaparadela") `MonadError[M, Throwable]` (for instance `cats.Eval`) and `C` represents a valid implementation of an [HttpClient][http-client]. -The previously mentioned implicit classes carry out of the box -instances for working with [scalaj][scalaj] (for JVM-compatible apps) and [roshttp][roshttp] (for -scala-js-compatible apps). Take into account that in the latter case, you can only use `Future` and -`cats.effect.Async` (if you pull in the `github4s-cats-effect` dependency) in place of `M[_]`. - A few examples follow with different `MonadError[M, Throwable]`. ### Using `cats.Eval` @@ -115,20 +104,6 @@ object ProgramFuture { } ``` -### Using `scalaz.Task` - -```tut:silent -import scalaz.concurrent.Task -import github4s.scalaz.implicits._ - -object ProgramTask { - val u4 = Github(accessToken).users.get("franciscodr").exec[Task, HttpResponse[String]]() - u4.unsafePerformSyncAttempt -} -``` - -Note that you'll need a dependency to the `github4s-scalaz` pacakge to leverage `scalaz.Task`. - ### Using `cats.effect.{Async, Sync}` On the JVM, you can use any `cats.effect.Sync`, here we're using `cats.effect.IO`: @@ -142,20 +117,6 @@ object ProgramTask { } ``` -Using scala-js, you can use any `cats.effect.Async`, here we're using `cats.effect.IO`: -```tut:silent -import github4s.cats.effect.js.Implicits._ -import fr.hmil.roshttp.response.SimpleHttpResponse - -object ProgramTask { - val u6 = Github(accessToken).users.get("fedefernandez").exec[IO, SimpleHttpResponse]() - u6.unsafeRunAsync { - case Right(s) => // IO effect success - case Left(e) => // IO effect failure - } -} -``` - Note that you'll need a dependency to the `github4s-cats-effect` package to leverage cats-effect integration. @@ -172,5 +133,4 @@ object ProgramEval { [http-client]: https://github.com/47deg/github4s/blob/master/github4s/shared/src/main/scala/github4s/HttpClient.scala [scalaj]: https://github.com/scalaj/scalaj-http -[roshttp]: https://github.com/hmil/RosHTTP [access-token]: https://github.com/settings/tokens diff --git a/docs/src/main/tut/gist.md b/docs/src/main/tut/gist.md index 1e8b2d547..96b7423b6 100644 --- a/docs/src/main/tut/gist.md +++ b/docs/src/main/tut/gist.md @@ -18,9 +18,6 @@ import github4s.Github import github4s.Github._ import github4s.jvm.Implicits._ import scalaj.http.HttpResponse -// if you're using ScalaJS, replace occurrences of HttpResponse by SimpleHttpResponse -//import github4s.js.Implicits._ -//import fr.hmil.roshttp.response.SimpleHttpResponse val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") ``` diff --git a/docs/src/main/tut/git_data.md b/docs/src/main/tut/git_data.md index 7bdf7754d..62f6cb4fd 100644 --- a/docs/src/main/tut/git_data.md +++ b/docs/src/main/tut/git_data.md @@ -28,9 +28,6 @@ import github4s.Github import github4s.Github._ import github4s.jvm.Implicits._ import scalaj.http.HttpResponse -// if you're using ScalaJS, replace occurrences of HttpResponse by SimpleHttpResponse -//import github4s.js.Implicits._ -//import fr.hmil.roshttp.response.SimpleHttpResponse val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") ``` diff --git a/docs/src/main/tut/index.md b/docs/src/main/tut/index.md index b594022cd..9d4f05425 100644 --- a/docs/src/main/tut/index.md +++ b/docs/src/main/tut/index.md @@ -2,7 +2,7 @@ layout: home technologies: - first: ["Scala", "Github4s is a Github API wrapper purely written in Scala"] - - second: ["ScalaJS", "Now, with Scala.js support"] + - second: ["cats-effect", "Integrated with cats-effect typeclasses and effect types"] - third: ["Free Monads", "Github4s is based on a Free Monad Architecture, which helps decoupling of program declaration from program interpretation"] --- @@ -12,12 +12,8 @@ Github4s is a GitHub API wrapper written in Scala. ## Installation -Github4s is compatible with both Scala JVM and Scala.js. It supports 2.10, 2.11, and 2.12. - To get started with SBT, simply add the following to your build.sbt file. -For Scala.jvm: - [comment]: # (Start Replace) ```scala @@ -25,13 +21,3 @@ libraryDependencies += "com.47deg" %% "github4s" % "0.20.1" ``` [comment]: # (End Replace) - -For Scala.js: - -[comment]: # (Start Replace) - -```scala -libraryDependencies += "com.47deg" %%% "github4s" % "0.20.1" -``` - -[comment]: # (End Replace) \ No newline at end of file diff --git a/docs/src/main/tut/issue.md b/docs/src/main/tut/issue.md index e3454b1a0..bf465da9d 100644 --- a/docs/src/main/tut/issue.md +++ b/docs/src/main/tut/issue.md @@ -33,9 +33,6 @@ import github4s.Github import github4s.Github._ import github4s.jvm.Implicits._ import scalaj.http.HttpResponse -// if you're using ScalaJS, replace occurrences of HttpResponse by SimpleHttpResponse -//import github4s.js.Implicits._ -//import fr.hmil.roshttp.response.SimpleHttpResponse val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") ``` diff --git a/docs/src/main/tut/organization.md b/docs/src/main/tut/organization.md index 89a703247..6025ae70c 100644 --- a/docs/src/main/tut/organization.md +++ b/docs/src/main/tut/organization.md @@ -20,9 +20,6 @@ import github4s.Github import github4s.Github._ import github4s.jvm.Implicits._ import scalaj.http.HttpResponse -// if you're using ScalaJS, replace occurrences of HttpResponse by SimpleHttpResponse -//import github4s.js.Implicits._ -//import fr.hmil.roshttp.response.SimpleHttpResponse val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") ``` diff --git a/docs/src/main/tut/pull_request.md b/docs/src/main/tut/pull_request.md index aa875ba0f..207ed1a04 100644 --- a/docs/src/main/tut/pull_request.md +++ b/docs/src/main/tut/pull_request.md @@ -24,9 +24,6 @@ import github4s.Github import github4s.Github._ import github4s.jvm.Implicits._ import scalaj.http.HttpResponse -// if you're using ScalaJS, replace occurrences of HttpResponse by SimpleHttpResponse -//import github4s.js.Implicits._ -//import fr.hmil.roshttp.response.SimpleHttpResponse val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") ``` diff --git a/docs/src/main/tut/repository.md b/docs/src/main/tut/repository.md index 4f23f9e72..07dda2735 100644 --- a/docs/src/main/tut/repository.md +++ b/docs/src/main/tut/repository.md @@ -32,9 +32,6 @@ import github4s.Github import github4s.Github._ import github4s.jvm.Implicits._ import scalaj.http.HttpResponse -// if you're using ScalaJS, replace occurrences of HttpResponse by SimpleHttpResponse -//import github4s.js.Implicits._ -//import fr.hmil.roshttp.response.SimpleHttpResponse val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") ``` diff --git a/docs/src/main/tut/user.md b/docs/src/main/tut/user.md index dddcdedc8..066564164 100644 --- a/docs/src/main/tut/user.md +++ b/docs/src/main/tut/user.md @@ -21,9 +21,6 @@ import github4s.Github import github4s.Github._ import github4s.jvm.Implicits._ import scalaj.http.HttpResponse -// if you're using ScalaJS, replace occurrences of HttpResponse by SimpleHttpResponse -//import github4s.js.Implicits._ -//import fr.hmil.roshttp.response.SimpleHttpResponse val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") ``` diff --git a/github4s/js/src/main/scala/github4s/HttpRequestBuilderExtensionJS.scala b/github4s/js/src/main/scala/github4s/HttpRequestBuilderExtensionJS.scala deleted file mode 100644 index 25cffeef6..000000000 --- a/github4s/js/src/main/scala/github4s/HttpRequestBuilderExtensionJS.scala +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s - -import java.nio.ByteBuffer - -import cats.implicits._ -import fr.hmil.roshttp._ -import fr.hmil.roshttp.body.BulkBodyPart -import fr.hmil.roshttp.response.SimpleHttpResponse -import fr.hmil.roshttp.util.HeaderMap -import github4s.GithubResponses._ -import github4s.HttpClient.{HttpCode200, HttpCode299} -import io.circe._ -import io.circe.jackson._ -import io.circe.syntax._ - -import scala.concurrent.Future - -case class CirceJSONBody(value: String) extends BulkBodyPart { - override def contentType: String = s"application/json; charset=utf-8" - override def contentData: ByteBuffer = - ByteBuffer.wrap(value.getBytes("utf-8")) -} - -trait HttpRequestBuilderExtensionJS { - - import monix.execution.Scheduler.Implicits.global - - implicit def extensionJS: HttpRequestBuilderExtension[SimpleHttpResponse, Future] = - new HttpRequestBuilderExtension[SimpleHttpResponse, Future] { - - def run[A](rb: HttpRequestBuilder[SimpleHttpResponse, Future])( - implicit D: Decoder[A]): Future[GHResponse[A]] = runMapWrapper[A](rb, decodeEntity[A]) - - def runEmpty(rb: HttpRequestBuilder[SimpleHttpResponse, Future]): Future[GHResponse[Unit]] = - runMapWrapper[Unit](rb, emptyResponse) - - private[this] def runMapWrapper[A]( - rb: HttpRequestBuilder[SimpleHttpResponse, Future], - mapResponse: SimpleHttpResponse => GHResponse[A]): Future[GHResponse[A]] = - runMap[A, Future](rb, mapResponse) - } - - protected def runMap[A, M[_]]( - rb: HttpRequestBuilder[SimpleHttpResponse, M], - mapResponse: SimpleHttpResponse => GHResponse[A]): Future[GHResponse[A]] = { - val params = rb.params.map { - case (key, value) => s"$key=$value" - } mkString "&" - - val request = HttpRequest(rb.url) - .withMethod(Method(rb.httpVerb.verb)) - .withQueryStringRaw(params) - .withHeader("content-type", "application/json") - .withHeaders(rb.authHeader.toList: _*) - .withHeaders(rb.headers.toList: _*) - - rb.data - .map(d => request.send(CirceJSONBody(d))) - .getOrElse(request.send()) - .map(toEntity[A](_, mapResponse)) - .recoverWith { - case e => - Future.successful(Either.left(UnexpectedException(e.getMessage))) - } - } - - def toEntity[A]( - response: SimpleHttpResponse, - mapResponse: SimpleHttpResponse => GHResponse[A]): GHResponse[A] = - response match { - case r if r.statusCode <= HttpCode299.statusCode && r.statusCode >= HttpCode200.statusCode => - mapResponse(r) - case r => - Either.left( - UnsuccessfulHttpRequest( - s"Failed invoking with status : ${r.statusCode}, body : \n ${r.body}", - r.statusCode - )) - } - - def emptyResponse(r: SimpleHttpResponse): GHResponse[Unit] = - Either.right(GHResult((): Unit, r.statusCode, rosHeaderMapToRegularMap(r.headers))) - - def decodeEntity[A](r: SimpleHttpResponse)(implicit D: Decoder[A]): GHResponse[A] = - parse(r.body) - .flatMap(_.as[A]) - .bimap( - e => JsonParsingException(e.getMessage, r.body), - result => GHResult(result, r.statusCode, rosHeaderMapToRegularMap(r.headers)) - ) - private def rosHeaderMapToRegularMap( - headers: HeaderMap[String]): Map[String, IndexedSeq[String]] = - headers.flatMap(m => Map(m._1.toLowerCase -> IndexedSeq(m._2))) - -} diff --git a/github4s/js/src/main/scala/github4s/js/Implicits.scala b/github4s/js/src/main/scala/github4s/js/Implicits.scala deleted file mode 100644 index 3c2153a2f..000000000 --- a/github4s/js/src/main/scala/github4s/js/Implicits.scala +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.js - -object Implicits extends ImplicitsJS diff --git a/github4s/js/src/main/scala/github4s/js/ImplicitsJS.scala b/github4s/js/src/main/scala/github4s/js/ImplicitsJS.scala deleted file mode 100644 index e78018994..000000000 --- a/github4s/js/src/main/scala/github4s/js/ImplicitsJS.scala +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.js - -import cats.instances.FutureInstances -import fr.hmil.roshttp.response.SimpleHttpResponse -import github4s.HttpRequestBuilderExtensionJS -import github4s.free.interpreters.Interpreters -import github4s.implicits._ -import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent.Future - -trait ImplicitsJS extends FutureInstances with HttpRequestBuilderExtensionJS { - - implicit val intInstanceFutureRosHttp = - new Interpreters[Future, SimpleHttpResponse] - -} diff --git a/github4s/js/src/main/scala/github4s/util/URLEncoder.scala b/github4s/js/src/main/scala/github4s/util/URLEncoder.scala deleted file mode 100644 index f213b5096..000000000 --- a/github4s/js/src/main/scala/github4s/util/URLEncoder.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.util - -object URLEncoder { - - def encode(string: String): String = - fr.hmil.roshttp.util.Utils.encodeQueryString(string) - -} diff --git a/github4s/js/src/test/scala/github4s/integration/IntegrationSpec.scala b/github4s/js/src/test/scala/github4s/integration/IntegrationSpec.scala deleted file mode 100644 index c0924a9a2..000000000 --- a/github4s/js/src/test/scala/github4s/integration/IntegrationSpec.scala +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.integration - -import fr.hmil.roshttp.response.SimpleHttpResponse -import github4s.HttpRequestBuilderExtension -import github4s.free.interpreters.{Capture, Interpreters} -import github4s.js.ImplicitsJS -import github4s.utils.{BaseIntegrationSpec, TestUtilsJS} - -import scala.concurrent.Future - -class IntegrationSpec - extends BaseIntegrationSpec[SimpleHttpResponse] - with GHAuthSpec[SimpleHttpResponse] - with GHGitDataSpec[SimpleHttpResponse] - with GHIssuesSpec[SimpleHttpResponse] - with GHPullRequestsSpec[SimpleHttpResponse] - with GHReposSpec[SimpleHttpResponse] - with GHUsersSpec[SimpleHttpResponse] - with GHActivitiesSpec[SimpleHttpResponse] - with ImplicitsJS - with TestUtilsJS { - - override implicit def extension( - implicit capture: Capture[Future]): HttpRequestBuilderExtension[SimpleHttpResponse, Future] = - extensionJS - - override implicit def futureInterpreters: Interpreters[Future, SimpleHttpResponse] = - intInstanceFutureRosHttp -} diff --git a/github4s/js/src/test/scala/github4s/utils/TestUtilsJS.scala b/github4s/js/src/test/scala/github4s/utils/TestUtilsJS.scala deleted file mode 100644 index 9c2d7a4dc..000000000 --- a/github4s/js/src/test/scala/github4s/utils/TestUtilsJS.scala +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.utils - -import org.scalatest.Matchers - -trait TestUtilsJS extends Matchers with TestData { - - val accessToken: Option[String] = Option(github4s.BuildInfo.token) - def tokenHeader: String = "token " + accessToken.getOrElse("") - -} diff --git a/github4s/jvm/src/test/resources/logback.xml b/github4s/jvm/src/test/resources/logback.xml deleted file mode 100644 index e73b91cf9..000000000 --- a/github4s/jvm/src/test/resources/logback.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/github4s/shared/src/main/scala/github4s/api/PullRequests.scala b/github4s/shared/src/main/scala/github4s/api/PullRequests.scala deleted file mode 100644 index 9e1a787c8..000000000 --- a/github4s/shared/src/main/scala/github4s/api/PullRequests.scala +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.api - -import github4s.GithubResponses.GHResponse -import github4s.free.domain._ -import github4s.free.interpreters.Capture -import github4s.{Decoders, Encoders, GithubApiUrls, HttpClient, HttpRequestBuilderExtension} -import github4s.util.URLEncoder -import io.circe.generic.auto._ -import io.circe.syntax._ - -import scala.language.higherKinds - -/** Factory to encapsulate calls related to PullRequests operations */ -class PullRequests[C, M[_]]( - implicit urls: GithubApiUrls, - C: Capture[M], - httpClientImpl: HttpRequestBuilderExtension[C, M]) { - - import Decoders._ - import Encoders._ - - val httpClient = new HttpClient[C, M] - - /** - * Get a single pull request for a repository - * - * @param accessToken to identify the authenticated user - * @param headers optional user headers to include in the request - * @param owner of the repo - * @param repo name of the repo - * @param number of the pull request - * @return a GHResponse with the pull request. - */ - def get( - accessToken: Option[String] = None, - headers: Map[String, String] = Map(), - owner: String, - repo: String, - number: Int): M[GHResponse[PullRequest]] = - httpClient.get[PullRequest]( - accessToken, - s"repos/$owner/$repo/pulls/$number", - headers) - - /** - * List pull requests for a repository - * - * @param accessToken to identify the authenticated user - * @param headers optional user headers to include in the request - * @param owner of the repo - * @param repo name of the repo - * @param filters define the filter list. Options are: - * - state: Either `open`, `closed`, or `all` to filter by state. Default: `open` - * - head: Filter pulls by head user and branch name in the format of `user:ref-name`. - * Example: `github:new-script-format`. - * - base: Filter pulls by base branch name. Example: `gh-pages`. - * - sort: What to sort results by. Can be either `created`, `updated`, `popularity` (comment count) - * or `long-running` (age, filtering by pulls updated in the last month). Default: `created` - * - direction: The direction of the sort. Can be either `asc` or `desc`. - * Default: `desc` when sort is created or sort is not specified, otherwise `asc`. - * @param pagination Limit and Offset for pagination - * @return a GHResponse with the pull request list. - */ - def list( - accessToken: Option[String] = None, - headers: Map[String, String] = Map(), - owner: String, - repo: String, - filters: List[PRFilter] = Nil, - pagination: Option[Pagination] = None): M[GHResponse[List[PullRequest]]] = - httpClient.get[List[PullRequest]]( - accessToken, - s"repos/$owner/$repo/pulls", - headers, - filters.map(_.tupled).toMap, - pagination) - - /** - * List files for a specific pull request - * - * @param accessToken to identify the authenticated user - * @param headers optional user headers to include in the request - * @param owner of the repo - * @param repo name of the repo - * @param number of the pull request for which we want to list the files - * @param pagination Limit and Offset for pagination - * @return a GHResponse with the list of files affected by the pull request identified by number. - */ - def listFiles( - accessToken: Option[String] = None, - headers: Map[String, String] = Map(), - owner: String, - repo: String, - number: Int, - pagination: Option[Pagination] = None): M[GHResponse[List[PullRequestFile]]] = - httpClient - .get[List[PullRequestFile]]( - accessToken, - s"repos/$owner/$repo/pulls/$number/files", - headers, - pagination = pagination) - - /** - * Create a pull request - * - * @param accessToken Token to identify the authenticated user - * @param headers Optional user headers to include in the request - * @param owner Owner of the repo - * @param repo Name of the repo - * @param newPullRequest The title and body parameters or the issue parameter - * @param head The name of the branch where your changes are implemented. For cross-repository pull - * requests in the same network, namespace head with a user like this: username:branch. - * @param base The name of the branch you want the changes pulled into. This should be an existing branch - * on the current repository. You cannot submit a pull request to one repository that - * @param maintainerCanModify Indicates whether maintainers can modify the pull request, Default:Some(true). - */ - def create( - accessToken: Option[String] = None, - headers: Map[String, String] = Map(), - owner: String, - repo: String, - newPullRequest: NewPullRequest, - head: String, - base: String, - maintainerCanModify: Option[Boolean] = Some(true)): M[GHResponse[PullRequest]] = { - val data: CreatePullRequest = newPullRequest match { - case NewPullRequestData(title, body) => - CreatePullRequestData(title, head, base, body, maintainerCanModify) - case NewPullRequestIssue(issue) => - CreatePullRequestIssue(issue, head, base, maintainerCanModify) - } - httpClient - .post[PullRequest](accessToken, s"repos/$owner/$repo/pulls", headers, data.asJson.noSpaces) - } - - /** - * List pull request reviews. - * - * @param accessToken Token to identify the authenticated user - * @param headers Optional user header to include in the request - * @param owner Owner of the repo - * @param repo Name of the repo - * @param pullRequest ID number of the PR to get reviews for. - * @param pagination Limit and Offset for pagination - */ - def listReviews( - accessToken: Option[String] = None, - headers: Map[String, String] = Map(), - owner: String, - repo: String, - pullRequest: Int, - pagination: Option[Pagination] = None): M[GHResponse[List[PullRequestReview]]] = - httpClient.get[List[PullRequestReview]]( - accessToken, - s"repos/$owner/$repo/pulls/$pullRequest/reviews", - headers, - pagination = pagination) - - /** - * Get a specific pull request review. - * - * @param accessToken Token to identify the authenticated user - * @param headers Optional user header to include in the request - * @param owner Owner of the repo - * @param repo Name of the repo - * @param pullRequest ID number of the PR to get reviews for - * @param review ID number of the review to retrieve. - */ - def getReview( - accessToken: Option[String] = None, - headers: Map[String, String] = Map(), - owner: String, - repo: String, - pullRequest: Int, - review: Int): M[GHResponse[PullRequestReview]] = - httpClient.get[PullRequestReview]( - accessToken, - s"repos/$owner/$repo/pulls/$pullRequest/reviews/$review", - headers) -} diff --git a/github4s/shared/src/main/resources/application.conf b/github4s/src/main/resources/application.conf similarity index 100% rename from github4s/shared/src/main/resources/application.conf rename to github4s/src/main/resources/application.conf diff --git a/github4s/shared/src/main/scala/github4s/Decoders.scala b/github4s/src/main/scala/github4s/Decoders.scala similarity index 94% rename from github4s/shared/src/main/scala/github4s/Decoders.scala rename to github4s/src/main/scala/github4s/Decoders.scala index 0bac9f227..cfd23231e 100644 --- a/github4s/shared/src/main/scala/github4s/Decoders.scala +++ b/github4s/src/main/scala/github4s/Decoders.scala @@ -224,20 +224,22 @@ object Decoders { } implicit val decodeStargazer: Decoder[Stargazer] = - Decoder[User].map(Stargazer(None, _)).or(Decoder.instance(c => - for { - starred_at ← c.downField("starred_at").as[String] - user ← c.downField("user").as[User] - } yield Stargazer(Some(starred_at), user) - )) + Decoder[User] + .map(Stargazer(None, _)) + .or(Decoder.instance(c => + for { + starred_at ← c.downField("starred_at").as[String] + user ← c.downField("user").as[User] + } yield Stargazer(Some(starred_at), user))) implicit val decodeStarredRepository: Decoder[StarredRepository] = - Decoder[Repository].map(StarredRepository(None, _)).or(Decoder.instance(c => - for { - starred_at ← c.downField("starred_at").as[String] - repo ← c.downField("repo").as[Repository] - } yield StarredRepository(Some(starred_at), repo) - )) + Decoder[Repository] + .map(StarredRepository(None, _)) + .or(Decoder.instance(c => + for { + starred_at ← c.downField("starred_at").as[String] + repo ← c.downField("repo").as[Repository] + } yield StarredRepository(Some(starred_at), repo))) implicit def decodeNonEmptyList[T](implicit D: Decoder[T]): Decoder[NonEmptyList[T]] = { diff --git a/github4s/shared/src/main/scala/github4s/Encoders.scala b/github4s/src/main/scala/github4s/Encoders.scala similarity index 96% rename from github4s/shared/src/main/scala/github4s/Encoders.scala rename to github4s/src/main/scala/github4s/Encoders.scala index e06149288..ae6c97e7b 100644 --- a/github4s/shared/src/main/scala/github4s/Encoders.scala +++ b/github4s/src/main/scala/github4s/Encoders.scala @@ -34,7 +34,8 @@ object Encoders { case d: CreatePullRequestIssue => d.asJson } - implicit val encodePrrStatus: Encoder[PullRequestReviewState] = Encoder.encodeString.contramap(_.value) + implicit val encodePrrStatus: Encoder[PullRequestReviewState] = + Encoder.encodeString.contramap(_.value) implicit val encodeEditGistFile: Encoder[EditGistFile] = { deriveEncoder[EditGistFile].mapJsonObject(_.filter(e => diff --git a/github4s/shared/src/main/scala/github4s/Github.scala b/github4s/src/main/scala/github4s/Github.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/Github.scala rename to github4s/src/main/scala/github4s/Github.scala diff --git a/github4s/shared/src/main/scala/github4s/GithubAPIs.scala b/github4s/src/main/scala/github4s/GithubAPIs.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/GithubAPIs.scala rename to github4s/src/main/scala/github4s/GithubAPIs.scala diff --git a/github4s/shared/src/main/scala/github4s/GithubDefaultUrls.scala b/github4s/src/main/scala/github4s/GithubDefaultUrls.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/GithubDefaultUrls.scala rename to github4s/src/main/scala/github4s/GithubDefaultUrls.scala diff --git a/github4s/shared/src/main/scala/github4s/GithubResponses.scala b/github4s/src/main/scala/github4s/GithubResponses.scala similarity index 96% rename from github4s/shared/src/main/scala/github4s/GithubResponses.scala rename to github4s/src/main/scala/github4s/GithubResponses.scala index 13365606a..2a6b17ed3 100644 --- a/github4s/shared/src/main/scala/github4s/GithubResponses.scala +++ b/github4s/src/main/scala/github4s/GithubResponses.scala @@ -38,8 +38,8 @@ object GithubResponses { ) extends GHException(msg) case class UnsuccessfulHttpRequest( - msg: String, - statusCode: Int + msg: String, + statusCode: Int ) extends GHException(msg) case class UnexpectedException(msg: String) extends GHException(msg) diff --git a/github4s/shared/src/main/scala/github4s/HttpClient.scala b/github4s/src/main/scala/github4s/HttpClient.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/HttpClient.scala rename to github4s/src/main/scala/github4s/HttpClient.scala diff --git a/github4s/shared/src/main/scala/github4s/HttpClientExtension.scala b/github4s/src/main/scala/github4s/HttpClientExtension.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/HttpClientExtension.scala rename to github4s/src/main/scala/github4s/HttpClientExtension.scala diff --git a/github4s/jvm/src/main/scala/github4s/HttpRequestBuilderExtensionJVM.scala b/github4s/src/main/scala/github4s/HttpRequestBuilderExtensionJVM.scala similarity index 100% rename from github4s/jvm/src/main/scala/github4s/HttpRequestBuilderExtensionJVM.scala rename to github4s/src/main/scala/github4s/HttpRequestBuilderExtensionJVM.scala diff --git a/github4s/shared/src/main/scala/github4s/Implicits.scala b/github4s/src/main/scala/github4s/Implicits.scala similarity index 98% rename from github4s/shared/src/main/scala/github4s/Implicits.scala rename to github4s/src/main/scala/github4s/Implicits.scala index 128d5d9c8..1e72de4c2 100644 --- a/github4s/shared/src/main/scala/github4s/Implicits.scala +++ b/github4s/src/main/scala/github4s/Implicits.scala @@ -19,7 +19,7 @@ package github4s import cats.instances.FutureInstances import cats.{Eval, FlatMap, Id, Monad, MonadError} import github4s.free.interpreters._ -import scala.concurrent.{Future, ExecutionContext} +import scala.concurrent.{ExecutionContext, Future} object implicits extends FutureCaptureInstance diff --git a/github4s/shared/src/main/scala/github4s/api/Activities.scala b/github4s/src/main/scala/github4s/api/Activities.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/api/Activities.scala rename to github4s/src/main/scala/github4s/api/Activities.scala diff --git a/github4s/shared/src/main/scala/github4s/api/Auth.scala b/github4s/src/main/scala/github4s/api/Auth.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/api/Auth.scala rename to github4s/src/main/scala/github4s/api/Auth.scala diff --git a/github4s/shared/src/main/scala/github4s/api/Gists.scala b/github4s/src/main/scala/github4s/api/Gists.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/api/Gists.scala rename to github4s/src/main/scala/github4s/api/Gists.scala diff --git a/github4s/shared/src/main/scala/github4s/api/GitData.scala b/github4s/src/main/scala/github4s/api/GitData.scala similarity index 99% rename from github4s/shared/src/main/scala/github4s/api/GitData.scala rename to github4s/src/main/scala/github4s/api/GitData.scala index 4e1f8f76b..a14bc42bd 100644 --- a/github4s/shared/src/main/scala/github4s/api/GitData.scala +++ b/github4s/src/main/scala/github4s/api/GitData.scala @@ -213,7 +213,7 @@ class GitData[C, M[_]]( accessToken, s"repos/$owner/$repo/git/trees/$sha", headers, - (if (recursive) Map("recursive"->"1") else Map.empty)) + (if (recursive) Map("recursive" -> "1") else Map.empty)) /** * Create a new Tree diff --git a/github4s/shared/src/main/scala/github4s/api/Issues.scala b/github4s/src/main/scala/github4s/api/Issues.scala similarity index 95% rename from github4s/shared/src/main/scala/github4s/api/Issues.scala rename to github4s/src/main/scala/github4s/api/Issues.scala index 0be1e4365..c3c81a704 100644 --- a/github4s/shared/src/main/scala/github4s/api/Issues.scala +++ b/github4s/src/main/scala/github4s/api/Issues.scala @@ -188,7 +188,8 @@ class Issues[C, M[_]]( owner: String, repo: String, number: Int): M[GHResponse[List[Comment]]] = - httpClient.get[List[Comment]](accessToken, s"repos/$owner/$repo/issues/$number/comments", headers) + httpClient + .get[List[Comment]](accessToken, s"repos/$owner/$repo/issues/$number/comments", headers) /** * Create a comment @@ -323,15 +324,15 @@ class Issues[C, M[_]]( headers) /** - * List available assignees for issues - * - * @param accessToken to identify the authenticated user - * @param headers optional user headers to include in the request - * @param owner repo owner - * @param repo repo name - * @param pagination Limit and Offset for pagination - * @return a GHResponse with the list of available assignees for issues in specified repository - */ + * List available assignees for issues + * + * @param accessToken to identify the authenticated user + * @param headers optional user headers to include in the request + * @param owner repo owner + * @param repo repo name + * @param pagination Limit and Offset for pagination + * @return a GHResponse with the list of available assignees for issues in specified repository + */ def listAvailableAssignees( accessToken: Option[String] = None, headers: Map[String, String] = Map(), @@ -343,6 +344,6 @@ class Issues[C, M[_]]( s"repos/$owner/$repo/assignees", headers, pagination = pagination - ) + ) } diff --git a/github4s/shared/src/main/scala/github4s/api/Organizations.scala b/github4s/src/main/scala/github4s/api/Organizations.scala similarity index 99% rename from github4s/shared/src/main/scala/github4s/api/Organizations.scala rename to github4s/src/main/scala/github4s/api/Organizations.scala index 53fbb9222..e6bbcd8b5 100644 --- a/github4s/shared/src/main/scala/github4s/api/Organizations.scala +++ b/github4s/src/main/scala/github4s/api/Organizations.scala @@ -60,7 +60,7 @@ class Organizations[C, M[_]]( pagination = pagination ) - /** + /** * List users who are outside collaborators * * @param accessToken To identify the authenticated user diff --git a/github4s/src/main/scala/github4s/api/PullRequests.scala b/github4s/src/main/scala/github4s/api/PullRequests.scala new file mode 100644 index 000000000..768c25b28 --- /dev/null +++ b/github4s/src/main/scala/github4s/api/PullRequests.scala @@ -0,0 +1,193 @@ +/* + * Copyright 2016-2019 47 Degrees, LLC. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package github4s.api + +import github4s.GithubResponses.GHResponse +import github4s.free.domain._ +import github4s.free.interpreters.Capture +import github4s.{Decoders, Encoders, GithubApiUrls, HttpClient, HttpRequestBuilderExtension} +import github4s.util.URLEncoder +import io.circe.generic.auto._ +import io.circe.syntax._ + +import scala.language.higherKinds + +/** Factory to encapsulate calls related to PullRequests operations */ +class PullRequests[C, M[_]]( + implicit urls: GithubApiUrls, + C: Capture[M], + httpClientImpl: HttpRequestBuilderExtension[C, M]) { + + import Decoders._ + import Encoders._ + + val httpClient = new HttpClient[C, M] + + /** + * Get a single pull request for a repository + * + * @param accessToken to identify the authenticated user + * @param headers optional user headers to include in the request + * @param owner of the repo + * @param repo name of the repo + * @param number of the pull request + * @return a GHResponse with the pull request. + */ + def get( + accessToken: Option[String] = None, + headers: Map[String, String] = Map(), + owner: String, + repo: String, + number: Int): M[GHResponse[PullRequest]] = + httpClient.get[PullRequest](accessToken, s"repos/$owner/$repo/pulls/$number", headers) + + /** + * List pull requests for a repository + * + * @param accessToken to identify the authenticated user + * @param headers optional user headers to include in the request + * @param owner of the repo + * @param repo name of the repo + * @param filters define the filter list. Options are: + * - state: Either `open`, `closed`, or `all` to filter by state. Default: `open` + * - head: Filter pulls by head user and branch name in the format of `user:ref-name`. + * Example: `github:new-script-format`. + * - base: Filter pulls by base branch name. Example: `gh-pages`. + * - sort: What to sort results by. Can be either `created`, `updated`, `popularity` (comment count) + * or `long-running` (age, filtering by pulls updated in the last month). Default: `created` + * - direction: The direction of the sort. Can be either `asc` or `desc`. + * Default: `desc` when sort is created or sort is not specified, otherwise `asc`. + * @param pagination Limit and Offset for pagination + * @return a GHResponse with the pull request list. + */ + def list( + accessToken: Option[String] = None, + headers: Map[String, String] = Map(), + owner: String, + repo: String, + filters: List[PRFilter] = Nil, + pagination: Option[Pagination] = None): M[GHResponse[List[PullRequest]]] = + httpClient.get[List[PullRequest]]( + accessToken, + s"repos/$owner/$repo/pulls", + headers, + filters.map(_.tupled).toMap, + pagination) + + /** + * List files for a specific pull request + * + * @param accessToken to identify the authenticated user + * @param headers optional user headers to include in the request + * @param owner of the repo + * @param repo name of the repo + * @param number of the pull request for which we want to list the files + * @param pagination Limit and Offset for pagination + * @return a GHResponse with the list of files affected by the pull request identified by number. + */ + def listFiles( + accessToken: Option[String] = None, + headers: Map[String, String] = Map(), + owner: String, + repo: String, + number: Int, + pagination: Option[Pagination] = None): M[GHResponse[List[PullRequestFile]]] = + httpClient + .get[List[PullRequestFile]]( + accessToken, + s"repos/$owner/$repo/pulls/$number/files", + headers, + pagination = pagination) + + /** + * Create a pull request + * + * @param accessToken Token to identify the authenticated user + * @param headers Optional user headers to include in the request + * @param owner Owner of the repo + * @param repo Name of the repo + * @param newPullRequest The title and body parameters or the issue parameter + * @param head The name of the branch where your changes are implemented. For cross-repository pull + * requests in the same network, namespace head with a user like this: username:branch. + * @param base The name of the branch you want the changes pulled into. This should be an existing branch + * on the current repository. You cannot submit a pull request to one repository that + * @param maintainerCanModify Indicates whether maintainers can modify the pull request, Default:Some(true). + */ + def create( + accessToken: Option[String] = None, + headers: Map[String, String] = Map(), + owner: String, + repo: String, + newPullRequest: NewPullRequest, + head: String, + base: String, + maintainerCanModify: Option[Boolean] = Some(true)): M[GHResponse[PullRequest]] = { + val data: CreatePullRequest = newPullRequest match { + case NewPullRequestData(title, body) => + CreatePullRequestData(title, head, base, body, maintainerCanModify) + case NewPullRequestIssue(issue) => + CreatePullRequestIssue(issue, head, base, maintainerCanModify) + } + httpClient + .post[PullRequest](accessToken, s"repos/$owner/$repo/pulls", headers, data.asJson.noSpaces) + } + + /** + * List pull request reviews. + * + * @param accessToken Token to identify the authenticated user + * @param headers Optional user header to include in the request + * @param owner Owner of the repo + * @param repo Name of the repo + * @param pullRequest ID number of the PR to get reviews for. + * @param pagination Limit and Offset for pagination + */ + def listReviews( + accessToken: Option[String] = None, + headers: Map[String, String] = Map(), + owner: String, + repo: String, + pullRequest: Int, + pagination: Option[Pagination] = None): M[GHResponse[List[PullRequestReview]]] = + httpClient.get[List[PullRequestReview]]( + accessToken, + s"repos/$owner/$repo/pulls/$pullRequest/reviews", + headers, + pagination = pagination) + + /** + * Get a specific pull request review. + * + * @param accessToken Token to identify the authenticated user + * @param headers Optional user header to include in the request + * @param owner Owner of the repo + * @param repo Name of the repo + * @param pullRequest ID number of the PR to get reviews for + * @param review ID number of the review to retrieve. + */ + def getReview( + accessToken: Option[String] = None, + headers: Map[String, String] = Map(), + owner: String, + repo: String, + pullRequest: Int, + review: Int): M[GHResponse[PullRequestReview]] = + httpClient.get[PullRequestReview]( + accessToken, + s"repos/$owner/$repo/pulls/$pullRequest/reviews/$review", + headers) +} diff --git a/github4s/shared/src/main/scala/github4s/api/Repos.scala b/github4s/src/main/scala/github4s/api/Repos.scala similarity index 96% rename from github4s/shared/src/main/scala/github4s/api/Repos.scala rename to github4s/src/main/scala/github4s/api/Repos.scala index e5765c3cc..f44650f3e 100644 --- a/github4s/shared/src/main/scala/github4s/api/Repos.scala +++ b/github4s/src/main/scala/github4s/api/Repos.scala @@ -185,21 +185,21 @@ class Repos[C, M[_]]( ) /** - * Retrieve list of branches for a repo - * - * @param accessToken to identify the authenticated user - * @param headers optional user headers to include in the request - * @param owner of the repo - * @param repo name of the repo - * @param onlyProtected Setting to true returns only protected branches - * @return GHResponse[List[Branch]\] List of branches - */ + * Retrieve list of branches for a repo + * + * @param accessToken to identify the authenticated user + * @param headers optional user headers to include in the request + * @param owner of the repo + * @param repo name of the repo + * @param onlyProtected Setting to true returns only protected branches + * @return GHResponse[List[Branch]\] List of branches + */ def listBranches( - accessToken: Option[String] = None, - headers: Map[String, String] = Map(), - owner: String, - repo: String, - onlyProtected: Option[Boolean] = None + accessToken: Option[String] = None, + headers: Map[String, String] = Map(), + owner: String, + repo: String, + onlyProtected: Option[Boolean] = None ): M[GHResponse[List[Branch]]] = httpClient.get[List[Branch]]( accessToken, diff --git a/github4s/shared/src/main/scala/github4s/api/Users.scala b/github4s/src/main/scala/github4s/api/Users.scala similarity index 85% rename from github4s/shared/src/main/scala/github4s/api/Users.scala rename to github4s/src/main/scala/github4s/api/Users.scala index 170263954..5262ff623 100644 --- a/github4s/shared/src/main/scala/github4s/api/Users.scala +++ b/github4s/src/main/scala/github4s/api/Users.scala @@ -74,17 +74,17 @@ class Users[C, M[_]]( .get[List[User]](accessToken, "users", headers, Map("since" -> since.toString), pagination) /** - * Get information for a particular user's list of users they follow - * - * @param accessToken to identify the authenticated user - * @param headers optional user headers to include in the request - * @param username of the user to retrieve - * @return GHResponse[User] User details - */ + * Get information for a particular user's list of users they follow + * + * @param accessToken to identify the authenticated user + * @param headers optional user headers to include in the request + * @param username of the user to retrieve + * @return GHResponse[User] User details + */ def getFollowing( - accessToken: Option[String] = None, - headers: Map[String, String] = Map(), - username: String): M[GHResponse[List[User]]] = + accessToken: Option[String] = None, + headers: Map[String, String] = Map(), + username: String): M[GHResponse[List[User]]] = httpClient.get[List[User]](accessToken, s"users/$username/following", headers) } diff --git a/github4s/shared/src/main/scala/github4s/api/package.scala b/github4s/src/main/scala/github4s/api/package.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/api/package.scala rename to github4s/src/main/scala/github4s/api/package.scala diff --git a/github4s/shared/src/main/scala/github4s/app.scala b/github4s/src/main/scala/github4s/app.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/app.scala rename to github4s/src/main/scala/github4s/app.scala diff --git a/github4s/shared/src/main/scala/github4s/free/algebra/ActivityOps.scala b/github4s/src/main/scala/github4s/free/algebra/ActivityOps.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/algebra/ActivityOps.scala rename to github4s/src/main/scala/github4s/free/algebra/ActivityOps.scala diff --git a/github4s/shared/src/main/scala/github4s/free/algebra/AuthOps.scala b/github4s/src/main/scala/github4s/free/algebra/AuthOps.scala similarity index 88% rename from github4s/shared/src/main/scala/github4s/free/algebra/AuthOps.scala rename to github4s/src/main/scala/github4s/free/algebra/AuthOps.scala index a2fd17a2c..0bd31cfe3 100644 --- a/github4s/shared/src/main/scala/github4s/free/algebra/AuthOps.scala +++ b/github4s/src/main/scala/github4s/free/algebra/AuthOps.scala @@ -19,11 +19,11 @@ package github4s.free.algebra import cats.InjectK import cats.free.Free import github4s.GithubResponses._ -import github4s.free.domain.{OAuthToken, Authorize, Authorization} +import github4s.free.domain.{Authorization, Authorize, OAuthToken} /** - * Auths ops ADT - */ + * Auths ops ADT + */ sealed trait AuthOp[A] final case class NewAuth( @@ -50,9 +50,9 @@ final case class GetAccessToken( ) extends AuthOp[GHResponse[OAuthToken]] /** - * Exposes Auths operations as a Free monadic algebra that may be combined with other Algebras via - * Coproduct - */ + * Exposes Auths operations as a Free monadic algebra that may be combined with other Algebras via + * Coproduct + */ class AuthOps[F[_]](implicit I: InjectK[AuthOp, F]) { def newAuth( @@ -84,8 +84,8 @@ class AuthOps[F[_]](implicit I: InjectK[AuthOp, F]) { } /** - * Default implicit based DI factory from which instances of the AuthOps may be obtained - */ + * Default implicit based DI factory from which instances of the AuthOps may be obtained + */ object AuthOps { implicit def instance[F[_]](implicit I: InjectK[AuthOp, F]): AuthOps[F] = new AuthOps[F] diff --git a/github4s/shared/src/main/scala/github4s/free/algebra/GistOps.scala b/github4s/src/main/scala/github4s/free/algebra/GistOps.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/algebra/GistOps.scala rename to github4s/src/main/scala/github4s/free/algebra/GistOps.scala diff --git a/github4s/shared/src/main/scala/github4s/free/algebra/GitDataOps.scala b/github4s/src/main/scala/github4s/free/algebra/GitDataOps.scala similarity index 87% rename from github4s/shared/src/main/scala/github4s/free/algebra/GitDataOps.scala rename to github4s/src/main/scala/github4s/free/algebra/GitDataOps.scala index 0bf7cb806..72c46a9f9 100644 --- a/github4s/shared/src/main/scala/github4s/free/algebra/GitDataOps.scala +++ b/github4s/src/main/scala/github4s/free/algebra/GitDataOps.scala @@ -35,20 +35,20 @@ final case class GetReference( ) extends GitDataOp[GHResponse[NonEmptyList[Ref]]] final case class CreateReference( - owner: String, - repo: String, - ref: String, - sha: String, - accessToken: Option[String] + owner: String, + repo: String, + ref: String, + sha: String, + accessToken: Option[String] ) extends GitDataOp[GHResponse[Ref]] final case class UpdateReference( - owner: String, - repo: String, - ref: String, - sha: String, - force: Boolean, - accessToken: Option[String] + owner: String, + repo: String, + ref: String, + sha: String, + force: Boolean, + accessToken: Option[String] ) extends GitDataOp[GHResponse[Ref]] final case class GetCommit( @@ -93,14 +93,14 @@ final case class CreateTree( ) extends GitDataOp[GHResponse[TreeResult]] final case class CreateTag( - owner: String, - repo: String, - tag: String, - message: String, - objectSha: String, - objectType: String, - author: Option[RefAuthor], - accessToken: Option[String] + owner: String, + repo: String, + tag: String, + message: String, + objectSha: String, + objectType: String, + author: Option[RefAuthor], + accessToken: Option[String] ) extends GitDataOp[GHResponse[Tag]] /** @@ -153,7 +153,8 @@ class GitDataOps[F[_]](implicit I: InjectK[GitDataOp, F]) { author: Option[RefAuthor], accessToken: Option[String] = None ): Free[F, GHResponse[RefCommit]] = - Free.inject[GitDataOp, F](CreateCommit(owner, repo, message, tree, parents, author, accessToken)) + Free.inject[GitDataOp, F]( + CreateCommit(owner, repo, message, tree, parents, author, accessToken)) def createBlob( owner: String, @@ -183,16 +184,17 @@ class GitDataOps[F[_]](implicit I: InjectK[GitDataOp, F]) { Free.inject[GitDataOp, F](CreateTree(owner, repo, baseTree, treeDataList, accessToken)) def createTag( - owner: String, - repo: String, - tag: String, - message: String, - objectSha: String, - objectType: String, - author: Option[RefAuthor], - accessToken: Option[String] = None + owner: String, + repo: String, + tag: String, + message: String, + objectSha: String, + objectType: String, + author: Option[RefAuthor], + accessToken: Option[String] = None ): Free[F, GHResponse[Tag]] = - Free.inject[GitDataOp, F](CreateTag(owner, repo, tag, message, objectSha, objectType, author, accessToken)) + Free.inject[GitDataOp, F]( + CreateTag(owner, repo, tag, message, objectSha, objectType, author, accessToken)) } /** diff --git a/github4s/shared/src/main/scala/github4s/free/algebra/IssuesOps.scala b/github4s/src/main/scala/github4s/free/algebra/IssuesOps.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/algebra/IssuesOps.scala rename to github4s/src/main/scala/github4s/free/algebra/IssuesOps.scala diff --git a/github4s/shared/src/main/scala/github4s/free/algebra/OrganizationOps.scala b/github4s/src/main/scala/github4s/free/algebra/OrganizationOps.scala similarity index 91% rename from github4s/shared/src/main/scala/github4s/free/algebra/OrganizationOps.scala rename to github4s/src/main/scala/github4s/free/algebra/OrganizationOps.scala index 9d9dc358e..5374dd37f 100644 --- a/github4s/shared/src/main/scala/github4s/free/algebra/OrganizationOps.scala +++ b/github4s/src/main/scala/github4s/free/algebra/OrganizationOps.scala @@ -53,16 +53,14 @@ class OrganizationOps[F[_]](implicit I: InjectK[OrganizationOp, F]) { role: Option[String] = None, pagination: Option[Pagination] = None, accessToken: Option[String] = None): Free[F, GHResponse[List[User]]] = - Free.inject[OrganizationOp, F]( - ListMembers(org, filter, role, pagination, accessToken)) + Free.inject[OrganizationOp, F](ListMembers(org, filter, role, pagination, accessToken)) def listOutsideCollaborators( org: String, filter: Option[String] = None, pagination: Option[Pagination] = None, accessToken: Option[String] = None): Free[F, GHResponse[List[User]]] = - Free.inject[OrganizationOp, F]( - ListOutsideCollaborators(org, filter, pagination, accessToken)) + Free.inject[OrganizationOp, F](ListOutsideCollaborators(org, filter, pagination, accessToken)) } diff --git a/github4s/shared/src/main/scala/github4s/free/algebra/PullRequestOps.scala b/github4s/src/main/scala/github4s/free/algebra/PullRequestOps.scala similarity index 71% rename from github4s/shared/src/main/scala/github4s/free/algebra/PullRequestOps.scala rename to github4s/src/main/scala/github4s/free/algebra/PullRequestOps.scala index 611426386..e58b96fb8 100644 --- a/github4s/shared/src/main/scala/github4s/free/algebra/PullRequestOps.scala +++ b/github4s/src/main/scala/github4s/free/algebra/PullRequestOps.scala @@ -22,126 +22,126 @@ import github4s.GithubResponses._ import github4s.free.domain._ /** - * PullRequests ops ADT - */ + * PullRequests ops ADT + */ sealed trait PullRequestOp[A] final case class GetPullRequest( - owner: String, - repo: String, - number: Int, - accessToken: Option[String] = None + owner: String, + repo: String, + number: Int, + accessToken: Option[String] = None ) extends PullRequestOp[GHResponse[PullRequest]] final case class ListPullRequests( - owner: String, - repo: String, - filters: List[PRFilter] = Nil, - accessToken: Option[String] = None, - pagination: Option[Pagination] = None + owner: String, + repo: String, + filters: List[PRFilter] = Nil, + accessToken: Option[String] = None, + pagination: Option[Pagination] = None ) extends PullRequestOp[GHResponse[List[PullRequest]]] final case class ListPullRequestFiles( - owner: String, - repo: String, - number: Int, - accessToken: Option[String] = None, - pagination: Option[Pagination] = None + owner: String, + repo: String, + number: Int, + accessToken: Option[String] = None, + pagination: Option[Pagination] = None ) extends PullRequestOp[GHResponse[List[PullRequestFile]]] final case class CreatePullRequest( - owner: String, - repo: String, - newPullRequest: NewPullRequest, - head: String, - base: String, - maintainerCanModify: Option[Boolean] = Some(true), - accessToken: Option[String] = None + owner: String, + repo: String, + newPullRequest: NewPullRequest, + head: String, + base: String, + maintainerCanModify: Option[Boolean] = Some(true), + accessToken: Option[String] = None ) extends PullRequestOp[GHResponse[PullRequest]] final case class ListPullRequestReviews( - owner: String, - repo: String, - pullRequest: Int, - accessToken: Option[String] = None, - pagination: Option[Pagination] = None + owner: String, + repo: String, + pullRequest: Int, + accessToken: Option[String] = None, + pagination: Option[Pagination] = None ) extends PullRequestOp[GHResponse[List[PullRequestReview]]] final case class GetPullRequestReview( - owner: String, - repo: String, - pullRequest: Int, - review: Int, - accessToken: Option[String] = None + owner: String, + repo: String, + pullRequest: Int, + review: Int, + accessToken: Option[String] = None ) extends PullRequestOp[GHResponse[PullRequestReview]] /** - * Exposes Pull Request operations as a Free monadic algebra that may be combined with other - * Algebras via Coproduct - */ + * Exposes Pull Request operations as a Free monadic algebra that may be combined with other + * Algebras via Coproduct + */ class PullRequestOps[F[_]](implicit I: InjectK[PullRequestOp, F]) { def getPullRequest( - owner: String, - repo: String, - number: Int, - accessToken: Option[String] = None + owner: String, + repo: String, + number: Int, + accessToken: Option[String] = None ): Free[F, GHResponse[PullRequest]] = Free.inject[PullRequestOp, F](GetPullRequest(owner, repo, number, accessToken)) def listPullRequests( - owner: String, - repo: String, - filters: List[PRFilter] = Nil, - accessToken: Option[String] = None, - pagination: Option[Pagination] = None + owner: String, + repo: String, + filters: List[PRFilter] = Nil, + accessToken: Option[String] = None, + pagination: Option[Pagination] = None ): Free[F, GHResponse[List[PullRequest]]] = Free.inject[PullRequestOp, F](ListPullRequests(owner, repo, filters, accessToken, pagination)) def listPullRequestFiles( - owner: String, - repo: String, - number: Int, - accessToken: Option[String] = None, - pagination: Option[Pagination] = None + owner: String, + repo: String, + number: Int, + accessToken: Option[String] = None, + pagination: Option[Pagination] = None ): Free[F, GHResponse[List[PullRequestFile]]] = Free.inject[PullRequestOp, F]( ListPullRequestFiles(owner, repo, number, accessToken, pagination)) def createPullRequest( - owner: String, - repo: String, - newPullRequest: NewPullRequest, - head: String, - base: String, - maintainerCanModify: Option[Boolean] = Some(true), - accessToken: Option[String] = None + owner: String, + repo: String, + newPullRequest: NewPullRequest, + head: String, + base: String, + maintainerCanModify: Option[Boolean] = Some(true), + accessToken: Option[String] = None ): Free[F, GHResponse[PullRequest]] = Free.inject[PullRequestOp, F]( CreatePullRequest(owner, repo, newPullRequest, head, base, maintainerCanModify, accessToken)) def listPullRequestReviews( - owner: String, - repo: String, - pullRequest: Int, - accessToken: Option[String] = None, - pagination: Option[Pagination] = None): Free[F, GHResponse[List[PullRequestReview]]] = + owner: String, + repo: String, + pullRequest: Int, + accessToken: Option[String] = None, + pagination: Option[Pagination] = None): Free[F, GHResponse[List[PullRequestReview]]] = Free.inject[PullRequestOp, F]( ListPullRequestReviews(owner, repo, pullRequest, accessToken, pagination)) def getPullRequestReview( - owner: String, - repo: String, - pullRequest: Int, - review: Int, - accessToken: Option[String] = None): Free[F, GHResponse[PullRequestReview]] = + owner: String, + repo: String, + pullRequest: Int, + review: Int, + accessToken: Option[String] = None): Free[F, GHResponse[PullRequestReview]] = Free.inject[PullRequestOp, F]( GetPullRequestReview(owner, repo, pullRequest, review, accessToken)) } /** - * Default implicit based DI factory from which instances of the PullRequestOps may be obtained - */ + * Default implicit based DI factory from which instances of the PullRequestOps may be obtained + */ object PullRequestOps { implicit def instance[F[_]](implicit I: InjectK[PullRequestOp, F]): PullRequestOps[F] = diff --git a/github4s/shared/src/main/scala/github4s/free/algebra/RepositoryOps.scala b/github4s/src/main/scala/github4s/free/algebra/RepositoryOps.scala similarity index 98% rename from github4s/shared/src/main/scala/github4s/free/algebra/RepositoryOps.scala rename to github4s/src/main/scala/github4s/free/algebra/RepositoryOps.scala index 50820956f..7929c0ee6 100644 --- a/github4s/shared/src/main/scala/github4s/free/algebra/RepositoryOps.scala +++ b/github4s/src/main/scala/github4s/free/algebra/RepositoryOps.scala @@ -183,8 +183,7 @@ class RepositoryOps[F[_]](implicit I: InjectK[RepositoryOp, F]) { `protected`: Option[Boolean] = None, accessToken: Option[String] = None ): Free[F, GHResponse[List[Branch]]] = - Free.inject[RepositoryOp, F]( - ListBranches(owner, repo, `protected`, accessToken)) + Free.inject[RepositoryOp, F](ListBranches(owner, repo, `protected`, accessToken)) def listContributors( owner: String, diff --git a/github4s/shared/src/main/scala/github4s/free/algebra/UserOps.scala b/github4s/src/main/scala/github4s/free/algebra/UserOps.scala similarity index 94% rename from github4s/shared/src/main/scala/github4s/free/algebra/UserOps.scala rename to github4s/src/main/scala/github4s/free/algebra/UserOps.scala index 441785e89..0dae3c5bd 100644 --- a/github4s/shared/src/main/scala/github4s/free/algebra/UserOps.scala +++ b/github4s/src/main/scala/github4s/free/algebra/UserOps.scala @@ -33,9 +33,8 @@ final case class GetUsers( pagination: Option[Pagination] = None, accessToken: Option[String] = None) extends UserOp[GHResponse[List[User]]] -final case class GetFollowing(username: String, - accessToken: Option[String] = None) - extends UserOp[GHResponse[List[User]]] +final case class GetFollowing(username: String, accessToken: Option[String] = None) + extends UserOp[GHResponse[List[User]]] /** * Exposes Users operations as a Free monadic algebra that may be combined with other Algebras via diff --git a/github4s/shared/src/main/scala/github4s/free/domain/Activity.scala b/github4s/src/main/scala/github4s/free/domain/Activity.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/domain/Activity.scala rename to github4s/src/main/scala/github4s/free/domain/Activity.scala diff --git a/github4s/shared/src/main/scala/github4s/free/domain/Authorization.scala b/github4s/src/main/scala/github4s/free/domain/Authorization.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/domain/Authorization.scala rename to github4s/src/main/scala/github4s/free/domain/Authorization.scala diff --git a/github4s/shared/src/main/scala/github4s/free/domain/Gist.scala b/github4s/src/main/scala/github4s/free/domain/Gist.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/domain/Gist.scala rename to github4s/src/main/scala/github4s/free/domain/Gist.scala diff --git a/github4s/shared/src/main/scala/github4s/free/domain/GitData.scala b/github4s/src/main/scala/github4s/free/domain/GitData.scala similarity index 83% rename from github4s/shared/src/main/scala/github4s/free/domain/GitData.scala rename to github4s/src/main/scala/github4s/free/domain/GitData.scala index c359d13a6..0beaee36d 100644 --- a/github4s/shared/src/main/scala/github4s/free/domain/GitData.scala +++ b/github4s/src/main/scala/github4s/free/domain/GitData.scala @@ -35,12 +35,12 @@ case class RefCommit( parents: List[RefInfo]) case class Tag( - tag: String, - sha: String, - url: String, - message: String, - tagger: RefAuthor, - `object`: RefObject) + tag: String, + sha: String, + url: String, + message: String, + tagger: RefAuthor, + `object`: RefObject) case class RefAuthor(date: String, name: String, email: String) @@ -52,7 +52,8 @@ sealed abstract class TreeData extends Product with Serializable { case class TreeDataSha(path: String, mode: String, `type`: String, sha: String) extends TreeData -case class TreeDataBlob(path: String, mode: String, `type`: String, content: String) extends TreeData +case class TreeDataBlob(path: String, mode: String, `type`: String, content: String) + extends TreeData case class TreeResult( override val sha: String, @@ -69,7 +70,11 @@ case class TreeDataResult( sha: String, url: String) -case class NewCommitRequest(message: String, tree: String, parents: List[String], author: Option[RefAuthor]) +case class NewCommitRequest( + message: String, + tree: String, + parents: List[String], + author: Option[RefAuthor]) case class NewBlobRequest(content: String, encoding: Option[String]) @@ -79,4 +84,9 @@ case class CreateReferenceRequest(ref: String, sha: String) case class UpdateReferenceRequest(sha: String, force: Boolean) -case class NewTagRequest(tag: String, message: String, `object`: String, `type`: String, tagger: Option[RefAuthor]) +case class NewTagRequest( + tag: String, + message: String, + `object`: String, + `type`: String, + tagger: Option[RefAuthor]) diff --git a/github4s/shared/src/main/scala/github4s/free/domain/Issue.scala b/github4s/src/main/scala/github4s/free/domain/Issue.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/domain/Issue.scala rename to github4s/src/main/scala/github4s/free/domain/Issue.scala diff --git a/github4s/shared/src/main/scala/github4s/free/domain/Pagination.scala b/github4s/src/main/scala/github4s/free/domain/Pagination.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/domain/Pagination.scala rename to github4s/src/main/scala/github4s/free/domain/Pagination.scala diff --git a/github4s/shared/src/main/scala/github4s/free/domain/PullRequest.scala b/github4s/src/main/scala/github4s/free/domain/PullRequest.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/domain/PullRequest.scala rename to github4s/src/main/scala/github4s/free/domain/PullRequest.scala diff --git a/github4s/shared/src/main/scala/github4s/free/domain/Repository.scala b/github4s/src/main/scala/github4s/free/domain/Repository.scala similarity index 97% rename from github4s/shared/src/main/scala/github4s/free/domain/Repository.scala rename to github4s/src/main/scala/github4s/free/domain/Repository.scala index f03025ee7..cef832a56 100644 --- a/github4s/shared/src/main/scala/github4s/free/domain/Repository.scala +++ b/github4s/src/main/scala/github4s/free/domain/Repository.scala @@ -104,15 +104,15 @@ case class Commit( ) case class Branch( - name: String, - commit: BranchCommit, - `protected`: Option[Boolean], - protection_url: Option[String] + name: String, + commit: BranchCommit, + `protected`: Option[Boolean], + protection_url: Option[String] ) case class BranchCommit( - sha: String, - url: String + sha: String, + url: String ) case class NewReleaseRequest( diff --git a/github4s/shared/src/main/scala/github4s/free/domain/SearchParam.scala b/github4s/src/main/scala/github4s/free/domain/SearchParam.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/domain/SearchParam.scala rename to github4s/src/main/scala/github4s/free/domain/SearchParam.scala diff --git a/github4s/shared/src/main/scala/github4s/free/domain/User.scala b/github4s/src/main/scala/github4s/free/domain/User.scala similarity index 100% rename from github4s/shared/src/main/scala/github4s/free/domain/User.scala rename to github4s/src/main/scala/github4s/free/domain/User.scala diff --git a/github4s/shared/src/main/scala/github4s/free/interpreters/Interpreters.scala b/github4s/src/main/scala/github4s/free/interpreters/Interpreters.scala similarity index 96% rename from github4s/shared/src/main/scala/github4s/free/interpreters/Interpreters.scala rename to github4s/src/main/scala/github4s/free/interpreters/Interpreters.scala index b625cb724..2815e12dc 100644 --- a/github4s/shared/src/main/scala/github4s/free/interpreters/Interpreters.scala +++ b/github4s/src/main/scala/github4s/free/interpreters/Interpreters.scala @@ -139,8 +139,10 @@ class Interpreters[M[_], C]( fa match { case GetUser(username, accessToken) => users.get(accessToken, headers, username) case GetAuthUser(accessToken) => users.getAuth(accessToken, headers) - case GetUsers(since, pagination, accessToken) => users.getUsers(accessToken, headers, since, pagination) - case GetFollowing(username, accessToken) => users.getFollowing(accessToken, headers, username) + case GetUsers(since, pagination, accessToken) => + users.getUsers(accessToken, headers, since, pagination) + case GetFollowing(username, accessToken) => + users.getFollowing(accessToken, headers, username) } } } @@ -262,9 +264,20 @@ class Interpreters[M[_], C]( case ListStargazers(owner, repo, timeline, pagination, accessToken) => activities.listStargazers(accessToken, headers, owner, repo, timeline, pagination) case ListStarredRepositories( - username, timeline, sort, direction, pagination, accessToken) => + username, + timeline, + sort, + direction, + pagination, + accessToken) => activities.listStarredRepositories( - accessToken, headers, username, timeline, sort, direction, pagination) + accessToken, + headers, + username, + timeline, + sort, + direction, + pagination) } } } diff --git a/github4s/jvm/src/main/scala/github4s/jvm/Implicits.scala b/github4s/src/main/scala/github4s/jvm/Implicits.scala similarity index 100% rename from github4s/jvm/src/main/scala/github4s/jvm/Implicits.scala rename to github4s/src/main/scala/github4s/jvm/Implicits.scala diff --git a/github4s/jvm/src/main/scala/github4s/jvm/ImplicitsJVM.scala b/github4s/src/main/scala/github4s/jvm/ImplicitsJVM.scala similarity index 100% rename from github4s/jvm/src/main/scala/github4s/jvm/ImplicitsJVM.scala rename to github4s/src/main/scala/github4s/jvm/ImplicitsJVM.scala diff --git a/github4s/jvm/src/main/scala/github4s/util/URLEncoder.scala b/github4s/src/main/scala/github4s/util/URLEncoder.scala similarity index 100% rename from github4s/jvm/src/main/scala/github4s/util/URLEncoder.scala rename to github4s/src/main/scala/github4s/util/URLEncoder.scala diff --git a/github4s/js/src/test/resources/logback.xml b/github4s/src/test/resources/logback.xml similarity index 100% rename from github4s/js/src/test/resources/logback.xml rename to github4s/src/test/resources/logback.xml diff --git a/github4s/shared/src/test/scala/github4s/integration/GHActivitiesSpec.scala b/github4s/src/test/scala/github4s/integration/GHActivitiesSpec.scala similarity index 92% rename from github4s/shared/src/test/scala/github4s/integration/GHActivitiesSpec.scala rename to github4s/src/test/scala/github4s/integration/GHActivitiesSpec.scala index 9c3f879c7..35c5bb611 100644 --- a/github4s/shared/src/test/scala/github4s/integration/GHActivitiesSpec.scala +++ b/github4s/src/test/scala/github4s/integration/GHActivitiesSpec.scala @@ -52,7 +52,9 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] { testFutureIsRight[List[Stargazer]](response, { r => r.result.nonEmpty shouldBe true - forAll(r.result) { s => s.starred_at shouldBe None } + forAll(r.result) { s => + s.starred_at shouldBe None + } r.statusCode shouldBe okStatusCode }) } @@ -65,7 +67,9 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] { testFutureIsRight[List[Stargazer]](response, { r => r.result.nonEmpty shouldBe true - forAll(r.result) { s => s.starred_at shouldBe defined } + forAll(r.result) { s => + s.starred_at shouldBe defined + } r.statusCode shouldBe okStatusCode }) } @@ -87,7 +91,9 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] { testFutureIsRight[List[StarredRepository]](response, { r => r.result.nonEmpty shouldBe true - forAll(r.result) { s => s.starred_at shouldBe None } + forAll(r.result) { s => + s.starred_at shouldBe None + } r.statusCode shouldBe okStatusCode }) } @@ -100,7 +106,9 @@ trait GHActivitiesSpec[T] extends BaseIntegrationSpec[T] { testFutureIsRight[List[StarredRepository]](response, { r => r.result.nonEmpty shouldBe true - forAll(r.result) { s => s.starred_at shouldBe defined } + forAll(r.result) { s => + s.starred_at shouldBe defined + } r.statusCode shouldBe okStatusCode }) } diff --git a/github4s/shared/src/test/scala/github4s/integration/GHAuthSpec.scala b/github4s/src/test/scala/github4s/integration/GHAuthSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/integration/GHAuthSpec.scala rename to github4s/src/test/scala/github4s/integration/GHAuthSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/integration/GHGitDataSpec.scala b/github4s/src/test/scala/github4s/integration/GHGitDataSpec.scala similarity index 85% rename from github4s/shared/src/test/scala/github4s/integration/GHGitDataSpec.scala rename to github4s/src/test/scala/github4s/integration/GHGitDataSpec.scala index 30503e510..0ff01e437 100644 --- a/github4s/shared/src/test/scala/github4s/integration/GHGitDataSpec.scala +++ b/github4s/src/test/scala/github4s/integration/GHGitDataSpec.scala @@ -77,31 +77,40 @@ trait GHGitDataSpec[T] extends BaseIntegrationSpec[T] { "GitData >> GetTree" should "return the file tree non-recursively" taggedAs Integration in { val response = Github(accessToken).gitData - .getTree(validRepoOwner, validRepoName, validCommitSha, recursive=false) + .getTree(validRepoOwner, validRepoName, validCommitSha, recursive = false) .execFuture[T](headerUserAgent) - testFutureIsRight[TreeResult](response, { r => - r.statusCode shouldBe okStatusCode - r.result.tree.map(_.path) shouldBe List(".gitignore","build.sbt","project") - r.result.truncated shouldBe Some(false) - }) + testFutureIsRight[TreeResult]( + response, { r => + r.statusCode shouldBe okStatusCode + r.result.tree.map(_.path) shouldBe List(".gitignore", "build.sbt", "project") + r.result.truncated shouldBe Some(false) + } + ) } it should "return the file tree recursively" taggedAs Integration in { val response = Github(accessToken).gitData - .getTree(validRepoOwner, validRepoName, validCommitSha, recursive=true) + .getTree(validRepoOwner, validRepoName, validCommitSha, recursive = true) .execFuture[T](headerUserAgent) - testFutureIsRight[TreeResult](response, { r => - r.statusCode shouldBe okStatusCode - r.result.tree.map(_.path) shouldBe List(".gitignore", "build.sbt", "project", "project/build.properties", "project/plugins.sbt") - }) + testFutureIsRight[TreeResult]( + response, { r => + r.statusCode shouldBe okStatusCode + r.result.tree.map(_.path) shouldBe List( + ".gitignore", + "build.sbt", + "project", + "project/build.properties", + "project/plugins.sbt") + } + ) } it should "return an error when an invalid repository name is passed" taggedAs Integration in { val response = Github(accessToken).gitData - .getTree(validRepoOwner, invalidRepoName, validCommitSha, recursive=false) + .getTree(validRepoOwner, invalidRepoName, validCommitSha, recursive = false) .execFuture[T](headerUserAgent) testFutureIsLeft(response) diff --git a/github4s/shared/src/test/scala/github4s/integration/GHIssuesSpec.scala b/github4s/src/test/scala/github4s/integration/GHIssuesSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/integration/GHIssuesSpec.scala rename to github4s/src/test/scala/github4s/integration/GHIssuesSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/integration/GHOrganizationsSpec.scala b/github4s/src/test/scala/github4s/integration/GHOrganizationsSpec.scala similarity index 95% rename from github4s/shared/src/test/scala/github4s/integration/GHOrganizationsSpec.scala rename to github4s/src/test/scala/github4s/integration/GHOrganizationsSpec.scala index 2df9cd7c7..0046544f6 100644 --- a/github4s/shared/src/test/scala/github4s/integration/GHOrganizationsSpec.scala +++ b/github4s/src/test/scala/github4s/integration/GHOrganizationsSpec.scala @@ -48,8 +48,8 @@ trait GHOrganizationsSpec[T] extends BaseIntegrationSpec[T] { "Organization >> ListOutsideCollaborators" should "return expected list of users" taggedAs Integration in { val response = Github(accessToken).organizations - .listOutsideCollaborators(validOrganizationName) - .execFuture[T](headerUserAgent) + .listOutsideCollaborators(validOrganizationName) + .execFuture[T](headerUserAgent) testFutureIsRight[List[User]](response, { r => r.result.nonEmpty shouldBe true diff --git a/github4s/shared/src/test/scala/github4s/integration/GHPullRequestsSpec.scala b/github4s/src/test/scala/github4s/integration/GHPullRequestsSpec.scala similarity index 95% rename from github4s/shared/src/test/scala/github4s/integration/GHPullRequestsSpec.scala rename to github4s/src/test/scala/github4s/integration/GHPullRequestsSpec.scala index 08ab841d6..516804462 100644 --- a/github4s/shared/src/test/scala/github4s/integration/GHPullRequestsSpec.scala +++ b/github4s/src/test/scala/github4s/integration/GHPullRequestsSpec.scala @@ -157,7 +157,11 @@ trait GHPullRequestsSpec[T] extends BaseIntegrationSpec[T] { "PullRequests >> GetReview" should "return a right response when a valid pr review is provided" taggedAs Integration in { val response = Github(accessToken).pullRequests - .getReview(validRepoOwner, validRepoName, validPullRequestNumber, validPullRequestReviewNumber) + .getReview( + validRepoOwner, + validRepoName, + validPullRequestNumber, + validPullRequestReviewNumber) .execFuture[T](headerUserAgent) testFutureIsRight[PullRequestReview](response, { r => @@ -169,7 +173,11 @@ trait GHPullRequestsSpec[T] extends BaseIntegrationSpec[T] { it should "return error when an invalid repo name is passed" taggedAs Integration in { val response = Github(accessToken).pullRequests - .getReview(validRepoOwner, invalidRepoName, validPullRequestNumber, validPullRequestReviewNumber) + .getReview( + validRepoOwner, + invalidRepoName, + validPullRequestNumber, + validPullRequestReviewNumber) .execFuture[T](headerUserAgent) testFutureIsLeft(response) diff --git a/github4s/shared/src/test/scala/github4s/integration/GHReposSpec.scala b/github4s/src/test/scala/github4s/integration/GHReposSpec.scala similarity index 98% rename from github4s/shared/src/test/scala/github4s/integration/GHReposSpec.scala rename to github4s/src/test/scala/github4s/integration/GHReposSpec.scala index 64db69d90..5bf0bf26f 100644 --- a/github4s/shared/src/test/scala/github4s/integration/GHReposSpec.scala +++ b/github4s/src/test/scala/github4s/integration/GHReposSpec.scala @@ -130,8 +130,8 @@ trait GHReposSpec[T] extends BaseIntegrationSpec[T] { "Repos >> ListBranches" should "return the expected list of branches for valid data" taggedAs Integration in { val response = Github(accessToken).repos - .listBranches(validRepoOwner, validRepoName) - .execFuture[T](headerUserAgent) + .listBranches(validRepoOwner, validRepoName) + .execFuture[T](headerUserAgent) testFutureIsRight[List[Branch]](response, { r => r.result.nonEmpty shouldBe true diff --git a/github4s/shared/src/test/scala/github4s/integration/GHUsersSpec.scala b/github4s/src/test/scala/github4s/integration/GHUsersSpec.scala similarity index 98% rename from github4s/shared/src/test/scala/github4s/integration/GHUsersSpec.scala rename to github4s/src/test/scala/github4s/integration/GHUsersSpec.scala index 5882915b2..592318f75 100644 --- a/github4s/shared/src/test/scala/github4s/integration/GHUsersSpec.scala +++ b/github4s/src/test/scala/github4s/integration/GHUsersSpec.scala @@ -91,7 +91,7 @@ trait GHUsersSpec[T] extends BaseIntegrationSpec[T] { .getFollowing(invalidUsername) .execFuture[T](headerUserAgent) - testFutureIsLeft(response) + testFutureIsLeft(response) } } diff --git a/github4s/jvm/src/test/scala/github4s/integration/IntegrationSpec.scala b/github4s/src/test/scala/github4s/integration/IntegrationSpec.scala similarity index 100% rename from github4s/jvm/src/test/scala/github4s/integration/IntegrationSpec.scala rename to github4s/src/test/scala/github4s/integration/IntegrationSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/ActivitiesSpec.scala b/github4s/src/test/scala/github4s/unit/ActivitiesSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/ActivitiesSpec.scala rename to github4s/src/test/scala/github4s/unit/ActivitiesSpec.scala diff --git a/github4s/jvm/src/test/scala/github4s/unit/ApiSpec.scala b/github4s/src/test/scala/github4s/unit/ApiSpec.scala similarity index 100% rename from github4s/jvm/src/test/scala/github4s/unit/ApiSpec.scala rename to github4s/src/test/scala/github4s/unit/ApiSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/AuthSpec.scala b/github4s/src/test/scala/github4s/unit/AuthSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/AuthSpec.scala rename to github4s/src/test/scala/github4s/unit/AuthSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/DecodersSpec.scala b/github4s/src/test/scala/github4s/unit/DecodersSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/DecodersSpec.scala rename to github4s/src/test/scala/github4s/unit/DecodersSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/EncodersSpec.scala b/github4s/src/test/scala/github4s/unit/EncodersSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/EncodersSpec.scala rename to github4s/src/test/scala/github4s/unit/EncodersSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/GHActivitiesSpec.scala b/github4s/src/test/scala/github4s/unit/GHActivitiesSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/GHActivitiesSpec.scala rename to github4s/src/test/scala/github4s/unit/GHActivitiesSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/GHAuthSpec.scala b/github4s/src/test/scala/github4s/unit/GHAuthSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/GHAuthSpec.scala rename to github4s/src/test/scala/github4s/unit/GHAuthSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/GHGistSpec.scala b/github4s/src/test/scala/github4s/unit/GHGistSpec.scala similarity index 80% rename from github4s/shared/src/test/scala/github4s/unit/GHGistSpec.scala rename to github4s/src/test/scala/github4s/unit/GHGistSpec.scala index 43575679d..0767e14ca 100644 --- a/github4s/shared/src/test/scala/github4s/unit/GHGistSpec.scala +++ b/github4s/src/test/scala/github4s/unit/GHGistSpec.scala @@ -53,16 +53,11 @@ class GHGistSpec extends BaseSpec { val gistOps = mock[GistOpsTest] (gistOps.getGist _) - .expects( - validGistId, - None, - sampleToken) + .expects(validGistId, None, sampleToken) .returns(response) val ghGists = new GHGists(sampleToken)(gistOps) - ghGists.getGist( - validGistId, - sha = None) + ghGists.getGist(validGistId, sha = None) } it should "call to GistOps with the right parameters with sha" in { @@ -72,16 +67,11 @@ class GHGistSpec extends BaseSpec { val gistOps = mock[GistOpsTest] (gistOps.getGist _) - .expects( - validGistId, - Some(validGistSha), - sampleToken) + .expects(validGistId, Some(validGistSha), sampleToken) .returns(response) val ghGists = new GHGists(sampleToken)(gistOps) - ghGists.getGist( - validGistId, - Some(validGistSha)) + ghGists.getGist(validGistId, Some(validGistSha)) } "Gist.editGist" should "call to GistOps with the right parameters" in { @@ -95,11 +85,13 @@ class GHGistSpec extends BaseSpec { validGistId, validGistDescription, Map( - validGistFilename -> Some(EditGistFile(validGistFileContent)), - validGistOldFilename -> Some(EditGistFile(validGistFileContent, Some(validGistNewFilename))), + validGistFilename -> Some(EditGistFile(validGistFileContent)), + validGistOldFilename -> Some( + EditGistFile(validGistFileContent, Some(validGistNewFilename))), validGistDeletedFilename -> None ), - sampleToken) + sampleToken + ) .returns(response) val ghGists = new GHGists(sampleToken)(gistOps) @@ -107,10 +99,12 @@ class GHGistSpec extends BaseSpec { validGistId, validGistDescription, Map( - validGistFilename -> Some(EditGistFile(validGistFileContent)), - validGistOldFilename -> Some(EditGistFile(validGistFileContent, Some(validGistNewFilename))), + validGistFilename -> Some(EditGistFile(validGistFileContent)), + validGistOldFilename -> Some( + EditGistFile(validGistFileContent, Some(validGistNewFilename))), validGistDeletedFilename -> None - )) + ) + ) } } diff --git a/github4s/shared/src/test/scala/github4s/unit/GHGitDataSpec.scala b/github4s/src/test/scala/github4s/unit/GHGitDataSpec.scala similarity index 93% rename from github4s/shared/src/test/scala/github4s/unit/GHGitDataSpec.scala rename to github4s/src/test/scala/github4s/unit/GHGitDataSpec.scala index a9c69a53e..c5749a684 100644 --- a/github4s/shared/src/test/scala/github4s/unit/GHGitDataSpec.scala +++ b/github4s/src/test/scala/github4s/unit/GHGitDataSpec.scala @@ -61,22 +61,11 @@ class GHGitDataSpec extends BaseSpec { val gitDataOps = mock[GitDataOpsTest] (gitDataOps.updateReference _) - .expects( - validRepoOwner, - validRepoName, - validRefSingle, - validCommitSha, - false, - sampleToken) + .expects(validRepoOwner, validRepoName, validRefSingle, validCommitSha, false, sampleToken) .returns(response) val ghGitData = new GHGitData(sampleToken)(gitDataOps) - ghGitData.updateReference( - validRepoOwner, - validRepoName, - validRefSingle, - validCommitSha, - false) + ghGitData.updateReference(validRepoOwner, validRepoName, validRefSingle, validCommitSha, false) } "GHGitData.getCommit" should "call to GitDataOps with the right parameters" in { @@ -123,8 +112,7 @@ class GHGitDataSpec extends BaseSpec { "GHGitData.createBlob" should "call to GitDataOps with the right parameters" in { val response: Free[GitHub4s, GHResponse[RefInfo]] = - Free.pure( - Right(GHResult(new RefInfo(validCommitSha, githubApiUrl), okStatusCode, Map.empty))) + Free.pure(Right(GHResult(new RefInfo(validCommitSha, githubApiUrl), okStatusCode, Map.empty))) val gitDataOps = mock[GitDataOpsTest] (gitDataOps.createBlob _) @@ -141,7 +129,7 @@ class GHGitDataSpec extends BaseSpec { Free.pure( Right( GHResult( - TreeResult(validCommitSha, githubApiUrl, treeDataResult, truncated=Some(false)), + TreeResult(validCommitSha, githubApiUrl, treeDataResult, truncated = Some(false)), okStatusCode, Map.empty))) @@ -151,7 +139,7 @@ class GHGitDataSpec extends BaseSpec { .returns(response) val ghGitData = new GHGitData(sampleToken)(gitDataOps) - ghGitData.getTree(validRepoOwner, validRepoName, validCommitSha, recursive=false) + ghGitData.getTree(validRepoOwner, validRepoName, validCommitSha, recursive = false) } "GHGitData.createTree" should "call to GitDataOps with the right parameters" in { diff --git a/github4s/shared/src/test/scala/github4s/unit/GHIssuesSpec.scala b/github4s/src/test/scala/github4s/unit/GHIssuesSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/GHIssuesSpec.scala rename to github4s/src/test/scala/github4s/unit/GHIssuesSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/GHOrganizationsSpec.scala b/github4s/src/test/scala/github4s/unit/GHOrganizationsSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/GHOrganizationsSpec.scala rename to github4s/src/test/scala/github4s/unit/GHOrganizationsSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/GHPullRequestsSpec.scala b/github4s/src/test/scala/github4s/unit/GHPullRequestsSpec.scala similarity index 95% rename from github4s/shared/src/test/scala/github4s/unit/GHPullRequestsSpec.scala rename to github4s/src/test/scala/github4s/unit/GHPullRequestsSpec.scala index 699745d38..e852ae762 100644 --- a/github4s/shared/src/test/scala/github4s/unit/GHPullRequestsSpec.scala +++ b/github4s/src/test/scala/github4s/unit/GHPullRequestsSpec.scala @@ -128,19 +128,11 @@ class GHPullRequestsSpec extends BaseSpec { val pullRequestOps = mock[PullRequestOpsTest] (pullRequestOps.listPullRequestReviews _) - .expects( - validRepoOwner, - validRepoName, - validPullRequestNumber, - sampleToken, - None) + .expects(validRepoOwner, validRepoName, validPullRequestNumber, sampleToken, None) .returns(response) val ghPullRequests = new GHPullRequests(sampleToken)(pullRequestOps) - ghPullRequests.listReviews( - validRepoOwner, - validRepoName, - validPullRequestNumber) + ghPullRequests.listReviews(validRepoOwner, validRepoName, validPullRequestNumber) } "GHPullRequests.getReview" should "call to PullRequestOps with the right parameters" in { diff --git a/github4s/shared/src/test/scala/github4s/unit/GHReposSpec.scala b/github4s/src/test/scala/github4s/unit/GHReposSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/GHReposSpec.scala rename to github4s/src/test/scala/github4s/unit/GHReposSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/GHUserSpec.scala b/github4s/src/test/scala/github4s/unit/GHUserSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/GHUserSpec.scala rename to github4s/src/test/scala/github4s/unit/GHUserSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/GistSpec.scala b/github4s/src/test/scala/github4s/unit/GistSpec.scala similarity index 95% rename from github4s/shared/src/test/scala/github4s/unit/GistSpec.scala rename to github4s/src/test/scala/github4s/unit/GistSpec.scala index b5817930b..04b39e6b3 100644 --- a/github4s/shared/src/test/scala/github4s/unit/GistSpec.scala +++ b/github4s/src/test/scala/github4s/unit/GistSpec.scala @@ -140,8 +140,9 @@ class GistSpec extends BaseSpec { validGistId, validGistDescription, Map( - validGistFilename -> Some(EditGistFile(validGistFileContent)), - validGistOldFilename -> Some(EditGistFile(validGistFileContent, Some(validGistNewFilename))), + validGistFilename -> Some(EditGistFile(validGistFileContent)), + validGistOldFilename -> Some( + EditGistFile(validGistFileContent, Some(validGistNewFilename))), validGistDeletedFilename -> None ), headerUserAgent, diff --git a/github4s/shared/src/test/scala/github4s/unit/GitDataSpec.scala b/github4s/src/test/scala/github4s/unit/GitDataSpec.scala similarity index 96% rename from github4s/shared/src/test/scala/github4s/unit/GitDataSpec.scala rename to github4s/src/test/scala/github4s/unit/GitDataSpec.scala index 0f23e0391..70e2ba384 100644 --- a/github4s/shared/src/test/scala/github4s/unit/GitDataSpec.scala +++ b/github4s/src/test/scala/github4s/unit/GitDataSpec.scala @@ -187,7 +187,7 @@ class GitDataSpec extends BaseSpec { val response: GHResponse[TreeResult] = Right( GHResult( - TreeResult(validCommitSha, githubApiUrl, treeDataResult, truncated=Some(false)), + TreeResult(validCommitSha, githubApiUrl, treeDataResult, truncated = Some(false)), okStatusCode, Map.empty)) val httpClientMock = httpClientMockGet[TreeResult]( @@ -198,17 +198,20 @@ class GitDataSpec extends BaseSpec { override val httpClient: HttpClient[String, Id] = httpClientMock } - gitData.tree(sampleToken, headerUserAgent, validRepoOwner, validRepoName, validCommitSha, recursive=false) + gitData.tree( + sampleToken, + headerUserAgent, + validRepoOwner, + validRepoName, + validCommitSha, + recursive = false) } "GitData.createTree" should "call to httpClient.post with the right parameters" in { val response: GHResponse[TreeResult] = Right( - GHResult( - TreeResult(validCommitSha, githubApiUrl, treeDataResult), - okStatusCode, - Map.empty)) + GHResult(TreeResult(validCommitSha, githubApiUrl, treeDataResult), okStatusCode, Map.empty)) def treeDataJson(treeData: TreeData): String = { def attr: String = treeData match { diff --git a/github4s/shared/src/test/scala/github4s/unit/IssuesSpec.scala b/github4s/src/test/scala/github4s/unit/IssuesSpec.scala similarity index 97% rename from github4s/shared/src/test/scala/github4s/unit/IssuesSpec.scala rename to github4s/src/test/scala/github4s/unit/IssuesSpec.scala index b91f7e5dd..bae849b28 100644 --- a/github4s/shared/src/test/scala/github4s/unit/IssuesSpec.scala +++ b/github4s/src/test/scala/github4s/unit/IssuesSpec.scala @@ -255,12 +255,7 @@ class IssuesSpec extends BaseSpec { val issues = new Issues[String, Id] { override val httpClient: HttpClient[String, Id] = httpClientMock } - issues.listLabels( - sampleToken, - headerUserAgent, - validRepoOwner, - validRepoName, - validIssueNumber) + issues.listLabels(sampleToken, headerUserAgent, validRepoOwner, validRepoName, validIssueNumber) } "Issues.AddLabels" should "call httpClient.post with the right parameters" in { @@ -297,7 +292,8 @@ class IssuesSpec extends BaseSpec { Right(GHResult(List(label), okStatusCode, Map.empty)) val httpClientMock = httpClientMockDeleteWithResponse[List[Label]]( - url = s"repos/$validRepoOwner/$validRepoName/issues/$validIssueNumber/labels/${validIssueLabel.head}", + url = + s"repos/$validRepoOwner/$validRepoName/issues/$validIssueNumber/labels/${validIssueLabel.head}", response = response ) diff --git a/github4s/shared/src/test/scala/github4s/unit/OrganizationsSpec.scala b/github4s/src/test/scala/github4s/unit/OrganizationsSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/OrganizationsSpec.scala rename to github4s/src/test/scala/github4s/unit/OrganizationsSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/PullRequestsSpec.scala b/github4s/src/test/scala/github4s/unit/PullRequestsSpec.scala similarity index 96% rename from github4s/shared/src/test/scala/github4s/unit/PullRequestsSpec.scala rename to github4s/src/test/scala/github4s/unit/PullRequestsSpec.scala index a299f0e66..97186878e 100644 --- a/github4s/shared/src/test/scala/github4s/unit/PullRequestsSpec.scala +++ b/github4s/src/test/scala/github4s/unit/PullRequestsSpec.scala @@ -38,7 +38,11 @@ class PullRequestsSpec extends BaseSpec { override val httpClient: HttpClient[String, Id] = httpClientMock } pullRequests.get( - sampleToken, headerUserAgent, validRepoOwner, validRepoName, validPullRequestNumber) + sampleToken, + headerUserAgent, + validRepoOwner, + validRepoName, + validPullRequestNumber) } "PullRequests.list" should "call to httpClient.get with the right parameters" in { @@ -176,7 +180,8 @@ class PullRequestsSpec extends BaseSpec { Right(GHResult(pullRequestReview, okStatusCode, Map.empty)) val httpClientMock = httpClientMockGet[PullRequestReview]( - url = s"repos/$validRepoOwner/$validRepoName/pulls/$validPullRequestNumber/reviews/$validPullRequestReviewNumber", + url = + s"repos/$validRepoOwner/$validRepoName/pulls/$validPullRequestNumber/reviews/$validPullRequestReviewNumber", response = response ) diff --git a/github4s/shared/src/test/scala/github4s/unit/ReposSpec.scala b/github4s/src/test/scala/github4s/unit/ReposSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/ReposSpec.scala rename to github4s/src/test/scala/github4s/unit/ReposSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/unit/UserSpec.scala b/github4s/src/test/scala/github4s/unit/UserSpec.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/unit/UserSpec.scala rename to github4s/src/test/scala/github4s/unit/UserSpec.scala diff --git a/github4s/shared/src/test/scala/github4s/utils/BaseIntegrationSpec.scala b/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala similarity index 87% rename from github4s/shared/src/test/scala/github4s/utils/BaseIntegrationSpec.scala rename to github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala index c70e838ea..7571322c2 100644 --- a/github4s/shared/src/test/scala/github4s/utils/BaseIntegrationSpec.scala +++ b/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala @@ -24,9 +24,14 @@ import org.scalatest.{Assertion, AsyncFlatSpec, Ignore, Inspectors, Matchers, Ta import scala.concurrent.{ExecutionContext, Future} -object Integration extends Tag(if (sys.env.get("GITHUB4S_ACCESS_TOKEN").isDefined) "" else classOf[Ignore].getName) - -abstract class BaseIntegrationSpec[T] extends AsyncFlatSpec with Matchers with Inspectors with TestData { +object Integration + extends Tag(if (sys.env.get("GITHUB4S_Agit statuCCESS_TOKEN").isDefined) "" else classOf[Ignore].getName) + +abstract class BaseIntegrationSpec[T] + extends AsyncFlatSpec + with Matchers + with Inspectors + with TestData { override implicit val executionContext: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global diff --git a/github4s/shared/src/test/scala/github4s/utils/BaseSpec.scala b/github4s/src/test/scala/github4s/utils/BaseSpec.scala similarity index 97% rename from github4s/shared/src/test/scala/github4s/utils/BaseSpec.scala rename to github4s/src/test/scala/github4s/utils/BaseSpec.scala index ba790f8f2..f145c7d4e 100644 --- a/github4s/shared/src/test/scala/github4s/utils/BaseSpec.scala +++ b/github4s/src/test/scala/github4s/utils/BaseSpec.scala @@ -139,10 +139,7 @@ trait BaseSpec extends FlatSpec with Matchers with TestData with IdInstances wit response: GHResponse[T]): HttpClient[String, Id] = { val httpClientMock = mock[HttpClientTest] (httpClientMock - .deleteWithResponse[T]( - _: Option[String], - _: String, - _: Map[String, String])(_: Decoder[T])) + .deleteWithResponse[T](_: Option[String], _: String, _: Map[String, String])(_: Decoder[T])) .expects(sampleToken, url, headerUserAgent, *) .returns(response) httpClientMock diff --git a/github4s/shared/src/test/scala/github4s/utils/DummyGithubUrls.scala b/github4s/src/test/scala/github4s/utils/DummyGithubUrls.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/utils/DummyGithubUrls.scala rename to github4s/src/test/scala/github4s/utils/DummyGithubUrls.scala diff --git a/github4s/shared/src/test/scala/github4s/utils/FakeResponses.scala b/github4s/src/test/scala/github4s/utils/FakeResponses.scala similarity index 99% rename from github4s/shared/src/test/scala/github4s/utils/FakeResponses.scala rename to github4s/src/test/scala/github4s/utils/FakeResponses.scala index 0bc9e448c..0faf0190d 100644 --- a/github4s/shared/src/test/scala/github4s/utils/FakeResponses.scala +++ b/github4s/src/test/scala/github4s/utils/FakeResponses.scala @@ -680,9 +680,9 @@ trait FakeResponses { |} """.stripMargin - val singleGistValidResponse = newGistValidResponse + val singleGistValidResponse = newGistValidResponse val specificRevisionOfGistValidResponse = newGistValidResponse - val editedGistValidResponse = newGistValidResponse + val editedGistValidResponse = newGistValidResponse val singleReference = """ diff --git a/github4s/jvm/src/test/scala/github4s/utils/MockGithubApiServer.scala b/github4s/src/test/scala/github4s/utils/MockGithubApiServer.scala similarity index 100% rename from github4s/jvm/src/test/scala/github4s/utils/MockGithubApiServer.scala rename to github4s/src/test/scala/github4s/utils/MockGithubApiServer.scala diff --git a/github4s/jvm/src/test/scala/github4s/utils/MockServerService.scala b/github4s/src/test/scala/github4s/utils/MockServerService.scala similarity index 100% rename from github4s/jvm/src/test/scala/github4s/utils/MockServerService.scala rename to github4s/src/test/scala/github4s/utils/MockServerService.scala diff --git a/github4s/shared/src/test/scala/github4s/utils/TestData.scala b/github4s/src/test/scala/github4s/utils/TestData.scala similarity index 100% rename from github4s/shared/src/test/scala/github4s/utils/TestData.scala rename to github4s/src/test/scala/github4s/utils/TestData.scala diff --git a/github4s/jvm/src/test/scala/github4s/utils/TestUtilsJVM.scala b/github4s/src/test/scala/github4s/utils/TestUtilsJVM.scala similarity index 100% rename from github4s/jvm/src/test/scala/github4s/utils/TestUtilsJVM.scala rename to github4s/src/test/scala/github4s/utils/TestUtilsJVM.scala diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 08e07564a..50dedf5e0 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -28,14 +28,11 @@ object ProjectPlugin extends AutoPlugin { val circe: String = "0.11.2" val circeJackson: String = "0.11.1" val paradise: String = "2.1.1" - val roshttp: String = "2.2.4" val simulacrum: String = "0.19.0" - val scala211: String = "2.11.12" - val scala212: String = "2.12.8" + val scala212: String = "2.12.10" val scalaj: String = "2.4.2" - val scalamockScalatest: String = "3.6.0" + val scalamock: String = "4.4.0" val scalaTest: String = "3.0.8" - val scalaz: String = "7.2.29" } lazy val micrositeSettings = Seq( @@ -58,11 +55,7 @@ object ProjectPlugin extends AutoPlugin { scalacOptions in Tut ~= (_ filterNot Set("-Ywarn-unused-import", "-Xlint").contains) ) - lazy val testSettings = Seq( - fork in Test := false - ) - - lazy val commonCrossDeps = Seq( + lazy val coreDeps = Seq( libraryDependencies ++= Seq( %%("cats-core", V.cats), %%("cats-free", V.cats), @@ -71,33 +64,20 @@ object ProjectPlugin extends AutoPlugin { %%("circe-generic", V.circe), "io.circe" %% "circe-jackson28" % V.circeJackson, %%("base64", V.base64), - %%("circe-parser", V.circe) % Test, - %%("scalamockScalatest", V.scalamockScalatest) % Test, - %%("scalatest", V.scalaTest) % Test - ) - ) - - lazy val standardCommonDeps = Seq( - libraryDependencies += compilerPlugin(%%("paradise", V.paradise) cross CrossVersion.full) - ) - - lazy val jvmDeps = Seq( - libraryDependencies ++= Seq( %%("scalaj", V.scalaj), + %%("circe-parser", V.circe) % Test, + %%("scalamock", V.scalamock) % Test, + %%("scalatest", V.scalaTest) % Test, "org.mock-server" % "mockserver-netty" % "5.8.0" % Test excludeAll ExclusionRule( - "com.twitter") + "com.twitter"), + compilerPlugin(%%("paradise", V.paradise) cross CrossVersion.full) ) ) - lazy val jsDeps: Def.Setting[Seq[ModuleID]] = libraryDependencies += %%%("roshttp", V.roshttp) - lazy val docsDependencies: Def.Setting[Seq[ModuleID]] = libraryDependencies += %%( "scalatest", V.scalaTest) - lazy val scalazDependencies: Def.Setting[Seq[ModuleID]] = - libraryDependencies += %%("scalaz-concurrent", V.scalaz) - lazy val catsEffectDependencies = Seq( libraryDependencies ++= Seq( %%("cats-effect", V.catsEffect), @@ -122,10 +102,9 @@ object ProjectPlugin extends AutoPlugin { startYear := Option(2016), resolvers += Resolver.sonatypeRepo("snapshots"), scalaVersion := V.scala212, - crossScalaVersions := Seq(V.scala211, V.scala212), + crossScalaVersions := Seq(V.scala212), scalacOptions ~= (_ filterNot Set("-Xlint").contains), orgGithubTokenSetting := "GITHUB4S_ACCESS_TOKEN", - resolvers += Resolver.bintrayRepo("hmil", "maven"), orgBadgeListSetting := List( TravisBadge.apply(_), GitterBadge.apply(_), @@ -133,10 +112,8 @@ object ProjectPlugin extends AutoPlugin { MavenCentralBadge.apply(_), LicenseBadge.apply(_), ScalaLangBadge.apply(_), - ScalaJSBadge.apply(_), GitHubIssuesBadge.apply(_) ), - orgSupportedScalaJSVersion := Some("0.6.21"), orgScriptTaskListSetting ++= List( (ScoverageKeys.coverageAggregate in Test).asRunnableItemFull, "docs/tut".asRunnableItem diff --git a/project/plugins.sbt b/project/plugins.sbt index 5cbf38508..4702e67c0 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,3 @@ -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") -addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.9.4") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.31") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.1") +addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.12.0-M3") +addSbtPlugin("com.47deg" % "sbt-microsites" % "0.9.7") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") diff --git a/scalaz/src/main/scala/github4s/scalaz/Implicits.scala b/scalaz/src/main/scala/github4s/scalaz/Implicits.scala deleted file mode 100644 index da970dec7..000000000 --- a/scalaz/src/main/scala/github4s/scalaz/Implicits.scala +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2016-2019 47 Degrees, LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package github4s.scalaz - -import cats.MonadError -import github4s.HttpRequestBuilderExtensionJVM - -import scalaz.concurrent.Task -import github4s.free.interpreters.{Capture, Interpreters} - -import scalaj.http.HttpResponse -import scalaz._ - -object implicits extends HttpRequestBuilderExtensionJVM { - - implicit val taskCaptureInstance = new Capture[Task] { - override def capture[A](a: => A): Task[A] = Task.now(a) - } - - implicit def g4sTaskMonadError: MonadError[Task, Throwable] = - new MonadError[Task, Throwable] { - - override def pure[A](x: A): Task[A] = Task.now(x) - - override def map[A, B](fa: Task[A])(f: A => B): Task[B] = fa.map(f) - - override def flatMap[A, B](fa: Task[A])(ff: A => Task[B]): Task[B] = - fa.flatMap(ff) - - override def tailRecM[A, B](a: A)(f: A => Task[Either[A, B]]): Task[B] = - Task.tailrecM((a: A) => f(a) map (t => toScalazDisjunction(t)))(a) - - override def raiseError[A](e: Throwable): Task[A] = Task.fail(e) - - override def handleErrorWith[A](fa: Task[A])(f: Throwable => Task[A]): Task[A] = - fa.handleWith({ case x => f(x) }) - - } - - implicit val intInstanceTaskScalaJ = - new Interpreters[Task, HttpResponse[String]] - - private[this] def toScalazDisjunction[A, B](disj: Either[A, B]): A \/ B = - disj.fold(l => -\/(l), r => \/-(r)) -} From 8c0ff5324d976da414ccb2f9d871f18035a0ab55 Mon Sep 17 00:00:00 2001 From: Juan Pedro Moreno Date: Tue, 17 Dec 2019 18:29:18 +0100 Subject: [PATCH 2/7] Upgrades sbt-microsites --- .travis.yml | 16 ++++------------ project/ProjectPlugin.scala | 29 +++++++++++++++-------------- project/plugins.sbt | 2 +- version.sbt | 2 +- 4 files changed, 21 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index eda1c357c..874cecaf8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,18 +15,10 @@ before_install: - export PATH=${PATH}:./vendor/bundle install: -- rvm use 2.3.8 --install --fuzzy -- gem update --system -- gem install sass -- gem install ruby_dep -v 1.3.1 -- gem install jekyll -v 3.4.3 -- gem install jekyll-redirect-from -- nvm install 6 -- nvm use 6 -- node --version - -before_script: - - sudo chmod +x /usr/local/bin/sbt + - rvm use 2.6.0 --install --fuzzy + - gem update --system + - gem install sass + - gem install jekyll -v 4.0.0 script: - sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT validate; diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index 50dedf5e0..c4fdfb175 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -22,17 +22,17 @@ object ProjectPlugin extends AutoPlugin { object autoImport { lazy val V = new { - val base64: String = "0.2.9" - val cats: String = "2.0.0" - val catsEffect: String = "2.0.0" - val circe: String = "0.11.2" - val circeJackson: String = "0.11.1" - val paradise: String = "2.1.1" - val simulacrum: String = "0.19.0" - val scala212: String = "2.12.10" - val scalaj: String = "2.4.2" - val scalamock: String = "4.4.0" - val scalaTest: String = "3.0.8" + val base64: String = "0.2.9" + val cats: String = "2.0.0" + val catsEffect: String = "2.0.0" + val circe: String = "0.11.2" + val circeJackson: String = "0.11.1" + val paradise: String = "2.1.1" + val simulacrum: String = "0.19.0" + val scala212: String = "2.12.10" + val scalaj: String = "2.4.2" + val scalamock: String = "4.4.0" + val scalaTest: String = "3.0.8" } lazy val micrositeSettings = Seq( @@ -43,6 +43,7 @@ object ProjectPlugin extends AutoPlugin { micrositeGithubOwner := "47deg", micrositeGithubRepo := "github4s", micrositeAuthor := "Github4s contributors", + micrositeCompilingDocsTool := WithTut, micrositeOrganizationHomepage := "https://github.com/47deg/github4s/blob/master/AUTHORS.md", micrositeExtraMdFiles := Map( file("CHANGELOG.md") -> ExtraMdFileConfig( @@ -65,10 +66,10 @@ object ProjectPlugin extends AutoPlugin { "io.circe" %% "circe-jackson28" % V.circeJackson, %%("base64", V.base64), %%("scalaj", V.scalaj), - %%("circe-parser", V.circe) % Test, + %%("circe-parser", V.circe) % Test, %%("scalamock", V.scalamock) % Test, - %%("scalatest", V.scalaTest) % Test, - "org.mock-server" % "mockserver-netty" % "5.8.0" % Test excludeAll ExclusionRule( + %%("scalatest", V.scalaTest) % Test, + "org.mock-server" % "mockserver-netty" % "5.8.0" % Test excludeAll ExclusionRule( "com.twitter"), compilerPlugin(%%("paradise", V.paradise) cross CrossVersion.full) ) diff --git a/project/plugins.sbt b/project/plugins.sbt index 4702e67c0..937305fc1 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,3 @@ addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.12.0-M3") -addSbtPlugin("com.47deg" % "sbt-microsites" % "0.9.7") +addSbtPlugin("com.47deg" % "sbt-microsites" % "1.0.2") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") diff --git a/version.sbt b/version.sbt index 7ba02199c..58cc0b66f 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "0.20.2-SNAPSHOT" \ No newline at end of file +version in ThisBuild := "0.20.2-SNAPSHOT" From cc0cdf0684685c187960d1a2d3dc18a450a59649 Mon Sep 17 00:00:00 2001 From: Juan Pedro Moreno Date: Tue, 17 Dec 2019 18:37:41 +0100 Subject: [PATCH 3/7] Changes travis dist --- .travis.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 874cecaf8..a6fe6f26d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,10 @@ language: scala - -dist: trusty - +jdk: + - openjdk8 +dist: xenial scala: - 2.12.10 -jdk: -- oraclejdk11 - before_install: - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_88322e86f6b6_key -iv $encrypted_88322e86f6b6_iv -in secring.gpg.enc -out secring.gpg -d; From 1315844b6ae5ef08b43261ceb7f603920faf2516 Mon Sep 17 00:00:00 2001 From: Juan Pedro Moreno Date: Tue, 17 Dec 2019 18:42:05 +0100 Subject: [PATCH 4/7] Tries to fix travis issue --- .travis.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index a6fe6f26d..f39a9c285 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,10 +12,11 @@ before_install: - export PATH=${PATH}:./vendor/bundle install: - - rvm use 2.6.0 --install --fuzzy - - gem update --system - - gem install sass - - gem install jekyll -v 4.0.0 + # Disabled due to unrelated conflicts running the build in travis + # - rvm use 2.6.0 --install --fuzzy + # - gem update --system + # - gem install sass + # - gem install jekyll -v 4.0.0 script: - sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT validate; From f779e1b97f7184ad2a78be1331427fa1f1b35ac8 Mon Sep 17 00:00:00 2001 From: Juan Pedro Moreno Date: Tue, 17 Dec 2019 18:53:24 +0100 Subject: [PATCH 5/7] Adds stages --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f39a9c285..1173646ce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,15 +18,18 @@ install: # - gem install sass # - gem install jekyll -v 4.0.0 -script: -- sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT validate; -- sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT docs/tut; +stages: +- test +- deploy after_success: - bash <(curl -s https://codecov.io/bash) jobs: include: + - script: + - sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT validate; + - sbt ++$TRAVIS_SCALA_VERSION $SBT_JAVA_OPT docs/tut; - stage: deploy script: - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then From 798f88dcda212ca6ee1e41d2f0e52409aed2c6b7 Mon Sep 17 00:00:00 2001 From: Juan Pedro Moreno Date: Tue, 17 Dec 2019 19:07:41 +0100 Subject: [PATCH 6/7] Fixes envvar in tests --- .travis.yml | 6 ++---- .../src/test/scala/github4s/utils/BaseIntegrationSpec.scala | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1173646ce..94737c89a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,7 @@ language: scala +dist: trusty jdk: - - openjdk8 -dist: xenial -scala: -- 2.12.10 + - oraclejdk11 before_install: - if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then diff --git a/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala b/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala index 7571322c2..36dfaf87d 100644 --- a/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala +++ b/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala @@ -25,7 +25,7 @@ import org.scalatest.{Assertion, AsyncFlatSpec, Ignore, Inspectors, Matchers, Ta import scala.concurrent.{ExecutionContext, Future} object Integration - extends Tag(if (sys.env.get("GITHUB4S_Agit statuCCESS_TOKEN").isDefined) "" else classOf[Ignore].getName) + extends Tag(if (sys.env.get("GITHUB4S_ACCESS_TOKEN").isDefined) "" else classOf[Ignore].getName) abstract class BaseIntegrationSpec[T] extends AsyncFlatSpec From 29102ba72dbe182d25c5a4917f8f6f249741dc9a Mon Sep 17 00:00:00 2001 From: Juan Pedro Moreno Date: Tue, 17 Dec 2019 22:00:19 +0100 Subject: [PATCH 7/7] Upgrades build --- .../github4s/cats/effect/jvm/CatsEffectJVMSpec.scala | 5 +++-- github4s/src/main/scala/github4s/api/package.scala | 2 +- github4s/src/test/scala/github4s/unit/ApiSpec.scala | 5 +++-- .../src/test/scala/github4s/unit/DecodersSpec.scala | 6 +++--- .../src/test/scala/github4s/unit/EncodersSpec.scala | 5 +++-- .../scala/github4s/utils/BaseIntegrationSpec.scala | 7 ++++--- github4s/src/test/scala/github4s/utils/BaseSpec.scala | 5 +++-- .../test/scala/github4s/utils/MockServerService.scala | 5 +++-- project/ProjectPlugin.scala | 11 +++++------ 9 files changed, 28 insertions(+), 23 deletions(-) diff --git a/cats-effect/src/test/scala/github4s/cats/effect/jvm/CatsEffectJVMSpec.scala b/cats-effect/src/test/scala/github4s/cats/effect/jvm/CatsEffectJVMSpec.scala index 2c06507e0..e698dd84a 100644 --- a/cats-effect/src/test/scala/github4s/cats/effect/jvm/CatsEffectJVMSpec.scala +++ b/cats-effect/src/test/scala/github4s/cats/effect/jvm/CatsEffectJVMSpec.scala @@ -20,10 +20,11 @@ import cats.effect.IO import github4s.Github import github4s.Github._ import github4s.cats.effect.jvm.Implicits._ -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.matchers.should.Matchers +import org.scalatest.flatspec.AnyFlatSpec import scalaj.http.HttpResponse -class CatsEffectJVMSpec extends FlatSpec with Matchers { +class CatsEffectJVMSpec extends AnyFlatSpec with Matchers { val accessToken = sys.env.get("GITHUB4S_ACCESS_TOKEN") val headerUserAgent = Map("user-agent" -> "github4s") val validUsername = "rafaparadela" diff --git a/github4s/src/main/scala/github4s/api/package.scala b/github4s/src/main/scala/github4s/api/package.scala index 0b5360153..35ba20e7b 100644 --- a/github4s/src/main/scala/github4s/api/package.scala +++ b/github4s/src/main/scala/github4s/api/package.scala @@ -21,6 +21,6 @@ import io.circe.{Json, Printer} package object api { def dropNullPrint(json: Json): String = - Printer.noSpaces.copy(dropNullValues = true).pretty(json) + Printer.noSpaces.copy(dropNullValues = true).print(json) } diff --git a/github4s/src/test/scala/github4s/unit/ApiSpec.scala b/github4s/src/test/scala/github4s/unit/ApiSpec.scala index 02216d47a..0c00089db 100644 --- a/github4s/src/test/scala/github4s/unit/ApiSpec.scala +++ b/github4s/src/test/scala/github4s/unit/ApiSpec.scala @@ -19,15 +19,16 @@ package github4s.unit import github4s.api._ import github4s.free.domain.{EditGistFile, GistFile, Pagination} import github4s.utils.{DummyGithubUrls, MockGithubApiServer, TestUtilsJVM} -import org.scalatest._ import cats.implicits._ import scalaj.http._ import cats.Id import github4s.jvm.ImplicitsJVM import github4s.utils.Integration +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers class ApiSpec - extends FlatSpec + extends AnyFlatSpec with Matchers with TestUtilsJVM with MockGithubApiServer diff --git a/github4s/src/test/scala/github4s/unit/DecodersSpec.scala b/github4s/src/test/scala/github4s/unit/DecodersSpec.scala index 5d4b3028b..8369613e4 100644 --- a/github4s/src/test/scala/github4s/unit/DecodersSpec.scala +++ b/github4s/src/test/scala/github4s/unit/DecodersSpec.scala @@ -17,15 +17,15 @@ package github4s.unit import cats.data.NonEmptyList -import cats.syntax.either._ import github4s.Decoders._ import github4s.free.domain._ import github4s.utils.FakeResponses import io.circe.generic.auto._ import io.circe.parser._ -import org.scalatest._ +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers -class DecodersSpec extends FlatSpec with Matchers with FakeResponses { +class DecodersSpec extends AnyFlatSpec with Matchers with FakeResponses { "Commit decoder" should "return a list of commits when the JSON is valid" in { decode[List[Commit]](listCommitsValidResponse).isRight shouldBe true diff --git a/github4s/src/test/scala/github4s/unit/EncodersSpec.scala b/github4s/src/test/scala/github4s/unit/EncodersSpec.scala index 4ac626ea0..2d6b9c0af 100644 --- a/github4s/src/test/scala/github4s/unit/EncodersSpec.scala +++ b/github4s/src/test/scala/github4s/unit/EncodersSpec.scala @@ -21,9 +21,10 @@ import github4s.free.domain._ import github4s.utils.TestData import io.circe.parser._ import io.circe.syntax._ -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.matchers.should.Matchers +import org.scalatest.flatspec.AnyFlatSpec -class EncodersSpec extends FlatSpec with Matchers with TestData { +class EncodersSpec extends AnyFlatSpec with Matchers with TestData { "TreeData encoder" should "encode the TreeDataSha" in { val treeData: TreeData = TreeDataSha(validFilePath, validMode, validBlobType, validCommitSha) diff --git a/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala b/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala index 36dfaf87d..05ced15be 100644 --- a/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala +++ b/github4s/src/test/scala/github4s/utils/BaseIntegrationSpec.scala @@ -16,11 +16,12 @@ package github4s.utils -import cats.syntax.either._ import github4s.GithubResponses.{GHResponse, GHResult} -import github4s.free.interpreters.{Capture, Interpreters} import github4s.HttpRequestBuilderExtension -import org.scalatest.{Assertion, AsyncFlatSpec, Ignore, Inspectors, Matchers, Tag} +import github4s.free.interpreters.{Capture, Interpreters} +import org.scalatest.{Assertion, Ignore, Inspectors, Tag} +import org.scalatest.flatspec.AsyncFlatSpec +import org.scalatest.matchers.should.Matchers import scala.concurrent.{ExecutionContext, Future} diff --git a/github4s/src/test/scala/github4s/utils/BaseSpec.scala b/github4s/src/test/scala/github4s/utils/BaseSpec.scala index f145c7d4e..cae96b52b 100644 --- a/github4s/src/test/scala/github4s/utils/BaseSpec.scala +++ b/github4s/src/test/scala/github4s/utils/BaseSpec.scala @@ -27,9 +27,10 @@ import io.circe.Decoder import io.circe.parser.parse import org.scalamock.matchers.MockParameter import org.scalamock.scalatest.MockFactory -import org.scalatest.{FlatSpec, Matchers} +import org.scalatest.matchers.should.Matchers +import org.scalatest.flatspec.AnyFlatSpec -trait BaseSpec extends FlatSpec with Matchers with TestData with IdInstances with MockFactory { +trait BaseSpec extends AnyFlatSpec with Matchers with TestData with IdInstances with MockFactory { case class JsonMockParameter(json: String) extends MockParameter[String](json) { override def equals(argument: Any): Boolean = parse(json) == parse(argument.toString) diff --git a/github4s/src/test/scala/github4s/utils/MockServerService.scala b/github4s/src/test/scala/github4s/utils/MockServerService.scala index e86c90177..94d27e2d9 100644 --- a/github4s/src/test/scala/github4s/utils/MockServerService.scala +++ b/github4s/src/test/scala/github4s/utils/MockServerService.scala @@ -18,9 +18,10 @@ package github4s.utils import org.mockserver.configuration.ConfigurationProperties import org.mockserver.integration.ClientAndServer._ -import org.scalatest.{BeforeAndAfterAll, FlatSpec} +import org.scalatest.BeforeAndAfterAll +import org.scalatest.flatspec.AnyFlatSpec -trait MockServerService extends FlatSpec with BeforeAndAfterAll { +trait MockServerService extends AnyFlatSpec with BeforeAndAfterAll { val mockServerPort = 9999 diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala index c4fdfb175..98267c1a8 100644 --- a/project/ProjectPlugin.scala +++ b/project/ProjectPlugin.scala @@ -1,9 +1,8 @@ -import com.typesafe.sbt.site.jekyll.JekyllPlugin.autoImport._ +import com.typesafe.sbt.site.SitePlugin.autoImport._ import microsites._ import microsites.MicrositesPlugin.autoImport._ import sbt.Keys._ import sbt._ -import sbtorgpolicies.model._ import sbtorgpolicies.OrgPoliciesKeys.orgBadgeListSetting import sbtorgpolicies.OrgPoliciesPlugin import sbtorgpolicies.OrgPoliciesPlugin.autoImport._ @@ -25,14 +24,14 @@ object ProjectPlugin extends AutoPlugin { val base64: String = "0.2.9" val cats: String = "2.0.0" val catsEffect: String = "2.0.0" - val circe: String = "0.11.2" - val circeJackson: String = "0.11.1" + val circe: String = "0.12.3" + val circeJackson: String = "0.12.1" val paradise: String = "2.1.1" val simulacrum: String = "0.19.0" val scala212: String = "2.12.10" val scalaj: String = "2.4.2" val scalamock: String = "4.4.0" - val scalaTest: String = "3.0.8" + val scalaTest: String = "3.1.0" } lazy val micrositeSettings = Seq( @@ -52,7 +51,7 @@ object ProjectPlugin extends AutoPlugin { Map("title" -> "Changelog", "section" -> "changelog", "position" -> "2") ) ), - includeFilter in Jekyll := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.md", + includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.md", scalacOptions in Tut ~= (_ filterNot Set("-Ywarn-unused-import", "-Xlint").contains) )