Skip to content

Commit

Permalink
Transition from TravisCI to Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
scullxbones committed Oct 18, 2021
1 parent 5f2a055 commit a78a802
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 46 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI
on: [push, pull_request]
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- mongo-version: 3.6
scala-version: 2.12.15
- mongo-version: 3.6
scala-version: 2.13.6
# 4.0 must be quoted, otherwise will be truncated to 4
- mongo-version: "4.0"
scala-version: 2.12.15
- mongo-version: "4.0"
scala-version: 2.13.6
- mongo-version: 4.2
scala-version: 2.12.15
- mongo-version: 4.2
scala-version: 2.13.6
env:
MONGODB_AUTH_PORT: 28117
MONGODB_NOAUTH_PORT: 27117
MONGODB_OPTS: --storageEngine wiredTiger --bind_ip_all
CONTAINER_HOST: 127.0.0.1
AKKA_TEST_TIMEFACTOR: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup JDK
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 8
- name: Coursier cache
uses: coursier/cache-action@v6
- name: Start mongod
run: |
echo Starting mongod version ${{matrix.mongo-version}}
sudo docker pull scullxbones/mongodb:${{matrix.mongo-version}}
sudo docker run -d -p $MONGODB_NOAUTH_PORT:27017 scullxbones/mongodb:${{matrix.mongo-version}} --noauth $MONGODB_OPTS
sudo docker run -d -p $MONGODB_AUTH_PORT:27017 scullxbones/mongodb:${{matrix.mongo-version}} --auth $MONGODB_OPTS
sudo docker ps -a
- name: Setup authentication
run: |
sleep 15
sudo docker exec $(sudo docker ps -a | grep -e "--auth" | awk '{print $1;}') mongo admin --eval "db.createUser({user:'admin',pwd:'password',roles:['root']});"
- name: Build and test
shell: bash
run: |
echo Running test suite for scala version ${{matrix.scala-version}}
./ci_build.sh ${{matrix.scala-version}}
- name: Cleanup before cache
shell: bash
run: |
rm -rf "$HOME/.ivy2/local" || true
find $HOME/Library/Caches/Coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.ivy2/cache -name "ivydata-*.properties" -delete || true
find $HOME/.cache/coursier/v1 -name "ivydata-*.properties" -delete || true
find $HOME/.sbt -name "*.lock" -delete || true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ out/
.bloop/

.bsp/
.vscode/
34 changes: 0 additions & 34 deletions .travis.yml

This file was deleted.

14 changes: 7 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ val commonDeps = Seq(
"com.typesafe.akka" %% "akka-cluster-sharding" % akkaV % "test"
)

lazy val Travis = config("travis").extend(Test)
lazy val Ci = config("ci").extend(Test)

ThisBuild / organization := "com.github.scullxbones"
ThisBuild / version := releaseV
Expand Down Expand Up @@ -82,16 +82,16 @@ val commonSettings = Seq(
),
parallelExecution in Test := false,
testOptions in Test += Tests.Argument("-oDS"),
testOptions in Travis += Tests.Argument("-l", "org.scalatest.tags.Slow"),
testOptions in Ci += Tests.Argument("-l", "org.scalatest.tags.Slow"),
fork in Test := false,
publishTo := sonatypePublishTo.value,
publishConfiguration := publishConfiguration.value.withOverwrite(true),
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true)
) ++ inConfig(Travis)(Defaults.testTasks)
) ++ inConfig(Ci)(Defaults.testTasks)

lazy val `akka-persistence-mongo-common` = (project in file("common"))
.settings(commonSettings:_*)
.configs(Travis)
.configs(Ci)

lazy val `akka-persistence-mongo-scala` = (project in file("scala"))
.dependsOn(`akka-persistence-mongo-common` % "test->test;compile->compile")
Expand All @@ -108,7 +108,7 @@ lazy val `akka-persistence-mongo-scala` = (project in file("scala"))
dependencyOverrides ++= Seq(
)
)
.configs(Travis)
.configs(Ci)

lazy val `akka-persistence-mongo-rxmongo` = (project in file("rxmongo"))
.dependsOn(`akka-persistence-mongo-common` % "test->test;compile->compile")
Expand All @@ -123,7 +123,7 @@ lazy val `akka-persistence-mongo-rxmongo` = (project in file("rxmongo"))
.excludeAll(ExclusionRule("org.apache.logging.log4j"))
)
)
.configs(Travis)
.configs(Ci)

lazy val `akka-persistence-mongo-tools` = (project in file("tools"))
.dependsOn(`akka-persistence-mongo-scala` % "test->test;compile->compile")
Expand All @@ -133,7 +133,7 @@ lazy val `akka-persistence-mongo-tools` = (project in file("tools"))
"org.mongodb.scala" %% "mongo-scala-driver" % "2.7.0" % "compile"
)
)
.configs(Travis)
.configs(Ci)

lazy val `akka-persistence-mongo` = (project in file("."))
.aggregate(`akka-persistence-mongo-common`, `akka-persistence-mongo-rxmongo`, `akka-persistence-mongo-scala`, `akka-persistence-mongo-tools`)
Expand Down
19 changes: 19 additions & 0 deletions ci_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

SCALA_VERSION=$1

if [ -z "$SCALA_VERSION" ]; then
echo "Missing value for SCALA_VERSION"
exit 1
fi

CURRENT=0
MAX_TRIES=3
COMMAND_STATUS=1
until [[ $COMMAND_STATUS -eq 0 || $CURRENT -eq ${MAX_TRIES} ]]; do
sbt ++${SCALA_VERSION} ";akka-persistence-mongo-common/ci:test;akka-persistence-mongo-rxmongo/ci:test;akka-persistence-mongo-scala/ci:test;akka-persistence-mongo-tools/ci:test"
COMMAND_STATUS=$?
sleep 5
let CURRENT=CURRENT+1
done
exit $COMMAND_STATUS
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ abstract class ReadJournalSpec[A <: MongoPersistenceExtension](extensionClass: C
val ar1 = as.actorOf(props("foo", promise1, 3))
val ar2 = as.actorOf(props("bar", promise2, 3))

events slice (0, 3) foreach (ar1 ! _)
events take 3 foreach (ar1 ! _)
Await.ready(promise1.future, 3.seconds)
val readJournal =
PersistenceQuery(as).readJournalFor[ScalaDslMongoReadJournal](MongoReadJournal.Identifier)
Expand All @@ -158,7 +158,7 @@ abstract class ReadJournalSpec[A <: MongoPersistenceExtension](extensionClass: C
.run()
Thread.sleep(1000L)

events slice (3, 6) foreach (ar2 ! _)
events takeRight 3 foreach (ar2 ! _)

probe.receiveN(events.size, 3.seconds.dilated).collect { case msg: EventEnvelope => msg.event.toString } should contain allOf ("this", "is", "just", "a", "test", "END")
ks.shutdown()
Expand Down Expand Up @@ -458,12 +458,17 @@ abstract class ReadJournalSpec[A <: MongoPersistenceExtension](extensionClass: C
.eventsByPersistenceId("foo-live-2b", 0L, Long.MaxValue)
.viaMat(KillSwitches.single)(Keep.right)
.take(events2.size.toLong)
.wireTap(ee => System.out.println(s"${getClass.getSimpleName}-$suiteName Received envelope for event: ${ee.event}"))
.toMat(Sink.seq[EventEnvelope])(Keep.both)
.run()

Thread.sleep(1000L)

events foreach (ar ! _)
events2 foreach (ar2 ! _)

promise2.future.futureValue(Timeout(1.seconds.dilated))

sq.futureValue(Timeout(3.seconds.dilated))
.toList
.map(_.event) should be(events2.map(_.s))
Expand Down
3 changes: 0 additions & 3 deletions travis_build.sh

This file was deleted.

0 comments on commit a78a802

Please sign in to comment.