diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4c7d5d5..641f259 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,13 +10,24 @@ on: - main jobs: - sbt-build: + test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: coursier/cache-action@v6 - - uses: olafurpg/setup-scala@v11 + - name: Checkout + uses: actions/checkout@v3 + - name: Setup JDK + uses: actions/setup-java@v3 with: - java-version: adopt@1.11 + distribution: corretto + java-version: 11 + cache: sbt - name: Build and Test - run: sbt ++test + run: sbt -v +test +publishLocal + - name: Check that example app compiles + working-directory: ./example/webapp + run: sbt -v +test + - name: Test Summary + uses: test-summary/action@v2 + with: + paths: "test-results/**/TEST-*.xml" + if: always() diff --git a/.gitignore b/.gitignore index 67059da..00bda0e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,6 @@ target/ .idea/ *.log .bsp/ + +/test-results/ +.DS_Store diff --git a/build.sbt b/build.sbt index 4087a69..7a7b6fc 100644 --- a/build.sbt +++ b/build.sbt @@ -35,6 +35,8 @@ def projectWithPlayVersion(playVersion: PlayVersion) = crossScalaVersions := Seq(scalaVersion.value) ++ (if (playVersion.supportsScala3) Seq("3.3.1") else Seq.empty), scalacOptions ++= Seq("-feature", "-deprecation"), Compile / unmanagedSourceDirectories += baseDirectory.value / playVersion.pekkoOrAkkaSrcFolder, + Test / testOptions += + Tests.Argument(TestFrameworks.ScalaTest, "-u", s"test-results/scala-${scalaVersion.value}", "-o"), libraryDependencies ++= Seq( "com.gu.play-secret-rotation" %% "core" % "0.40", diff --git a/play-v27/src/sbt-test/example/webapp/app/AppComponents.scala b/example/webapp/app/AppComponents.scala similarity index 92% rename from play-v27/src/sbt-test/example/webapp/app/AppComponents.scala rename to example/webapp/app/AppComponents.scala index bb695cf..08da7dd 100644 --- a/play-v27/src/sbt-test/example/webapp/app/AppComponents.scala +++ b/example/webapp/app/AppComponents.scala @@ -21,7 +21,7 @@ class AppComponents(context: ApplicationLoader.Context) clientId = configuration.get[String]("your.clientId.config.path"), clientSecret = configuration.get[String]("your.clientSecret.config.path"), redirectUrl = configuration.get[String]("your.redirectUrl.config.path"), - domain = configuration.get[String]("your.apps-domain.config.path"), + domains = List(configuration.get[String]("your.apps-domain.config.path")), antiForgeryChecker = AntiForgeryChecker.borrowSettingsFromPlay(httpConfiguration) ) @@ -31,7 +31,7 @@ class AppComponents(context: ApplicationLoader.Context) val googleServiceAccount = GoogleServiceAccount(googleCredential.getServiceAccountId, googleCredential.getServiceAccountPrivateKey, "service.account@mydomain.com") val googleGroupChecker = new GoogleGroupChecker(googleServiceAccount) - val authAction = new AuthAction[AnyContent](googleAuthConfig, routes.Login.loginAction(), controllerComponents.parsers.default)(executionContext) + val authAction = new AuthAction[AnyContent](googleAuthConfig, routes.Login.loginAction, controllerComponents.parsers.default)(executionContext) val login = new Login(requiredGoogleGroups, googleAuthConfig, googleGroupChecker, wsClient, controllerComponents)(executionContext) val appController = new Application(authAction, requiredGoogleGroups, googleAuthConfig, googleGroupChecker, controllerComponents)(executionContext) diff --git a/play-v27/src/sbt-test/example/webapp/app/AppLoader.scala b/example/webapp/app/AppLoader.scala similarity index 100% rename from play-v27/src/sbt-test/example/webapp/app/AppLoader.scala rename to example/webapp/app/AppLoader.scala diff --git a/play-v27/src/sbt-test/example/webapp/app/controllers/Application.scala b/example/webapp/app/controllers/Application.scala similarity index 94% rename from play-v27/src/sbt-test/example/webapp/app/controllers/Application.scala rename to example/webapp/app/controllers/Application.scala index 318d048..54c47c4 100644 --- a/play-v27/src/sbt-test/example/webapp/app/controllers/Application.scala +++ b/example/webapp/app/controllers/Application.scala @@ -4,7 +4,6 @@ import com.gu.googleauth import com.gu.googleauth.{AuthAction, Filters, GoogleAuthConfig, GoogleGroupChecker} import play.api.mvc.Security.AuthenticatedRequest import play.api.mvc._ -import com.google.api.client.auth.oauth2.GoogleCredential import scala.concurrent.ExecutionContext diff --git a/play-v27/src/sbt-test/example/webapp/app/controllers/Login.scala b/example/webapp/app/controllers/Login.scala similarity index 91% rename from play-v27/src/sbt-test/example/webapp/app/controllers/Login.scala rename to example/webapp/app/controllers/Login.scala index 69d55b8..979452d 100644 --- a/play-v27/src/sbt-test/example/webapp/app/controllers/Login.scala +++ b/example/webapp/app/controllers/Login.scala @@ -38,9 +38,9 @@ class Login(requiredGoogleGroups: Set[String], val authConfig: GoogleAuthConfig, } def logout = Action { implicit request => - Redirect(routes.Application.index()).withNewSession + Redirect(routes.Application.index).withNewSession } - override val failureRedirectTarget: Call = routes.Login.login() - override val defaultRedirectTarget: Call = routes.Application.authenticated() + override val failureRedirectTarget: Call = routes.Login.login + override val defaultRedirectTarget: Call = routes.Application.authenticated } diff --git a/play-v27/src/sbt-test/example/webapp/app/views/authenticated.scala.html b/example/webapp/app/views/authenticated.scala.html similarity index 85% rename from play-v27/src/sbt-test/example/webapp/app/views/authenticated.scala.html rename to example/webapp/app/views/authenticated.scala.html index 52ea0ed..89884de 100644 --- a/play-v27/src/sbt-test/example/webapp/app/views/authenticated.scala.html +++ b/example/webapp/app/views/authenticated.scala.html @@ -18,7 +18,7 @@
The expiry time is @{Instant.ofEpochSecond(request.user.exp)}
-You can go to the login page - or logout.
+You can go to the login page + or logout.