Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Switch to GHA #215

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Check

on:
pull_request: # Check Pull Requests

push:
branches:
- main # Check main branch after merge
- gha # TODO: drop before merge

concurrency:
# Only run once for latest commit per ref and cancel other (previous) runs.
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
check-code-style:
name: Code Style
uses: playframework/.github/.github/workflows/cmd.yml@v2
with:
cmd: sbt validateCode

tests:
name: Tests
needs: # Waiting more lightweight checks
- "check-code-style"
uses: playframework/.github/.github/workflows/cmd.yml@v2
with:
scala: 2.12.15, 2.13.8
cmd: sbt ++$MATRIX_SCALA test

samples:
name: Samples
needs: # Waiting more lightweight checks
- "tests"
uses: playframework/.github/.github/workflows/cmd.yml@v2
with:
add-dimensions: >-
{
"sample": [ "scalaChat", "scalaMultiRoomChat", "scalaClusteredChat", "javaChat", "javaMultiRoomChat", "javaClusteredChat" ]
}
cmd: |- # sbt $MATRIX_SAMPLE/test
echo "TODO: NEED FIX"

finish:
name: Finish
needs: # Should be last
- "samples"
uses: playframework/.github/.github/workflows/rtm.yml@v2
13 changes: 13 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Publish

on:
push:
branches: # Snapshots
- main
tags: ["*"] # Releases

jobs:
publish-artifacts:
name: Publish / Artifacts
uses: playframework/.github/.github/workflows/publish.yml@v2
secrets: inherit
26 changes: 13 additions & 13 deletions .mergify.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
queue_rules:
- name: default
conditions:
# Conditions to get out of the queue (= merged)
- check-success~=/ Ready To Merge$

pull_request_rules:
- name: Merge PRs that are ready
conditions:
- status-success=Travis CI - Pull Request
- status-success=typesafe-cla-validator
- check-success~=/ Ready To Merge$
- check-success=typesafe-cla-validator
- "#approved-reviews-by>=1"
- "#review-requested=0"
- "#changes-requested-reviews-by=0"
- label!=status:block-merge
- label=status:merge-when-green
actions:
merge:
method: squash
strict: smart
queue:
method: merge
name: default

- name: Delete the PR branch after merge
conditions:
- merged
actions:
delete_head_branch: {}

- name: auto add wip
conditions:
# match a few flavours of wip
- title~=^(\[wip\]( |:) |\[WIP\]( |:) |wip( |:) |WIP( |:)).*
actions:
label:
add: ["status:block-merge"]
remove: [ "status:merge-when-green" ]
57 changes: 0 additions & 57 deletions .travis.yml

This file was deleted.

25 changes: 12 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import Dependencies.AkkaVersion
import Dependencies.Scala212
import Dependencies.Scala213
import play.core.PlayVersion.{ current => playVersion }

val AkkaVersion = "2.5.28"

lazy val runChromeWebDriver = taskKey[Unit]("Run the chromewebdriver tests")

val macwire = "com.softwaremill.macwire" %% "macros" % "2.3.4"
val lombok = "org.projectlombok" % "lombok" % "1.18.8"
val lombok = "org.projectlombok" % "lombok" % "1.18.8" % Provided
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 👍

val akkaCluster = Seq(
"com.typesafe.akka" %% "akka-cluster" % AkkaVersion,
"com.typesafe.akka" %% "akka-cluster-tools" % AkkaVersion
Expand Down Expand Up @@ -36,8 +35,8 @@ lazy val root = (project in file("."))
"com.typesafe.play" %% "play-guice" % playVersion % Test,
macwire % Test,
// Test dependencies for running chrome driver
"io.github.bonigarcia" % "webdrivermanager" % "5.1.1" % Test,
"org.seleniumhq.selenium" % "selenium-chrome-driver" % "3.141.59" % Test,
"io.github.bonigarcia" % "webdrivermanager" % "5.1.1" % Test,
"org.seleniumhq.selenium" % "selenium-chrome-driver" % "4.1.4" % Test,
// Test framework dependencies
"org.scalatest" %% "scalatest" % "3.1.2" % Test,
"com.novocode" % "junit-interface" % "0.11" % Test
Expand Down Expand Up @@ -91,7 +90,6 @@ lazy val scalaClusteredChat = (project in file("samples/scala/clustered-chat"))
.settings(
name := "play-socket.io-scala-clustered-chat-example",
organization := "com.typesafe.play",
publish / skip := true,
scalaVersion := Scala213,
libraryDependencies ++= Seq(macwire % Provided) ++ akkaCluster
)
Expand All @@ -102,7 +100,6 @@ lazy val javaChat = (project in file("samples/java/chat"))
.settings(
name := "play-socket.io-java-chat-example",
organization := "com.typesafe.play",
publish / skip := true,
scalaVersion := Scala213,
libraryDependencies += guice
)
Expand All @@ -113,7 +110,6 @@ lazy val javaMultiRoomChat = (project in file("samples/java/multi-room-chat"))
.settings(
name := "play-socket.io-java-multi-room-chat-example",
organization := "com.typesafe.play",
publish / skip := true,
scalaVersion := Scala213,
libraryDependencies ++= Seq(guice, lombok)
)
Expand All @@ -124,16 +120,19 @@ lazy val javaClusteredChat = (project in file("samples/java/clustered-chat"))
.settings(
name := "play-socket.io-java-clustered-chat-example",
organization := "com.typesafe.play",
publish / skip := true,
scalaVersion := Scala213,
libraryDependencies ++= Seq(guice, lombok) ++ akkaCluster
)

addCommandAlias(
"validateCode",
List(
"headerCheckAll",
"scalafmtSbtCheck",
"scalafmtCheckAll",
(
List(
"headerCheckAll",
"scalafmtSbtCheck",
"scalafmtCheckAll",
) ++
List(scalaChat, scalaMultiRoomChat, scalaClusteredChat, javaChat, javaMultiRoomChat, javaClusteredChat)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

.flatMap(p => List("scalafmtCheckAll").map(cmd => s"${p.id}/$cmd"))
).mkString(";")
)
2 changes: 2 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ object Dependencies {
// Sync with GA (.github/workflows/build-test.yml)
val Scala212 = "2.12.15" // sync! see comment above
val Scala213 = "2.13.8" // sync! see comment above

val AkkaVersion = "2.5.28"
}
20 changes: 13 additions & 7 deletions samples/scala/chat/app/chat/ChatEngine.scala
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
package chat

import akka.stream.Materializer
import akka.stream.scaladsl.{BroadcastHub, Flow, Keep, MergeHub}
import akka.stream.scaladsl.BroadcastHub
import akka.stream.scaladsl.Flow
import akka.stream.scaladsl.Keep
import akka.stream.scaladsl.MergeHub
import play.api.libs.json.Format
import play.engineio.EngineIOController
import play.api.libs.functional.syntax._
import play.socketio.scaladsl.SocketIO

/**
* A simple chat engine.
*/
* A simple chat engine.
*/
class ChatEngine(socketIO: SocketIO)(implicit mat: Materializer) {

import play.socketio.scaladsl.SocketIOEventCodec._

// This will decode String "chat message" events coming in
val decoder = decodeByName {
case "chat message" => decodeJson[String]
case "chat message" =>
decodeJson[String]
}

// This will encode String "chat message" events going out
Expand All @@ -30,8 +34,10 @@ class ChatEngine(socketIO: SocketIO)(implicit mat: Materializer) {
// BroadcastHub to broadcast them out again to all the connected users.
// See http://doc.akka.io/docs/akka/snapshot/scala/stream/stream-dynamic.html
// for details on these features.
val (sink, source) = MergeHub.source[String]
.toMat(BroadcastHub.sink)(Keep.both).run
val (sink, source) = MergeHub
.source[String]
.toMat(BroadcastHub.sink)(Keep.both)
.run

// We couple the sink and source together so that one completes, the other
// will to, and we use this to handle our chat
Expand All @@ -43,4 +49,4 @@ class ChatEngine(socketIO: SocketIO)(implicit mat: Materializer) {
val controller: EngineIOController = socketIO.builder
.addNamespace("/chat", decoder, encoder, chatFlow)
.createController()
}
}
16 changes: 9 additions & 7 deletions samples/scala/chat/app/modules/MyApplicationLoader.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package modules

import chat.ChatEngine
import play.api.{ApplicationLoader, BuiltInComponents, BuiltInComponentsFromContext, LoggerConfigurator}
import play.api.ApplicationLoader
import play.api.BuiltInComponents
import play.api.BuiltInComponentsFromContext
import play.api.LoggerConfigurator
import com.softwaremill.macwire._
import controllers.AssetsComponents
import play.api.inject.DefaultApplicationLifecycle
Expand All @@ -11,23 +14,22 @@ import play.socketio.scaladsl.SocketIOComponents
class MyApplicationLoader extends ApplicationLoader {
override def load(context: ApplicationLoader.Context) =
new BuiltInComponentsFromContext(context) with MyApplication {
LoggerConfigurator.apply(context.environment.classLoader)
LoggerConfigurator
.apply(context.environment.classLoader)
.foreach(_.configure(context.environment))
}.application
}

trait MyApplication extends BuiltInComponents
with AssetsComponents
with SocketIOComponents {
trait MyApplication extends BuiltInComponents with AssetsComponents with SocketIOComponents {

override def applicationLifecycle: DefaultApplicationLifecycle

lazy val chatEngine = wire[ChatEngine]
lazy val chatEngine = wire[ChatEngine]
lazy val engineIOController: EngineIOController = chatEngine.controller

override lazy val router = {
val prefix = "/"
wire[_root_.router.Routes]
}
override lazy val httpFilters = Nil
}
}
Loading