From 807846f0d8346a011383576b0ceba74b5b985efc Mon Sep 17 00:00:00 2001 From: Naftoli Gugenheim <98384+nafg@users.noreply.github.com> Date: Tue, 12 Jul 2022 02:36:34 -0400 Subject: [PATCH] Enable Oracle in CI --- .github/workflows/ci.yml | 2 +- build.sbt | 2 ++ ci.sbt | 2 +- docker-compose.yml | 6 ++++++ src/test/scala/slick/migration/api/dbs.scala | 18 +++--------------- test-dbs/testkit.conf | 4 ++-- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33083558..ac22df14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck - name: Start databases - run: docker compose up -d mysql postgres + run: docker compose up -d - name: Build project run: sbt '++ ${{ matrix.scala }}' -Dslick.testkit-config=test-dbs/testkit-github.conf test diff --git a/build.sbt b/build.sbt index 7842a38b..b314f6be 100644 --- a/build.sbt +++ b/build.sbt @@ -27,6 +27,8 @@ libraryDependencies += "com.mysql" % "mysql-connector-j" % "9.3.0" libraryDependencies += "org.slf4j" % "slf4j-simple" % "2.0.17" % "test" +libraryDependencies += "com.oracle.database.jdbc.debug" % "ojdbc8_g" % "21.6.0.0.1" % Test + (Compile / doc / scalacOptions) ++= Seq("-groups", "-implicits") scalacOptions ++= Seq("-feature", "-deprecation", "-Xsource:3") diff --git a/ci.sbt b/ci.sbt index f8766632..4e1325fa 100644 --- a/ci.sbt +++ b/ci.sbt @@ -17,7 +17,7 @@ inThisBuild(List( githubWorkflowJavaVersions := Seq(JavaSpec.temurin("11")), githubWorkflowTargetTags ++= Seq("v*"), githubWorkflowBuild := Seq( - WorkflowStep.Run(List("docker compose up -d mysql postgres"), name = Some("Start databases")), + WorkflowStep.Run(List("docker compose up -d"), name = Some("Start databases")), WorkflowStep.Sbt(List("-Dslick.testkit-config=test-dbs/testkit-github.conf", "test"), name = Some("Build project")) ), githubWorkflowPublishTargetBranches := Seq(RefPredicate.StartsWith(Ref.Tag("v"))), diff --git a/docker-compose.yml b/docker-compose.yml index f3f58ec1..3023a23e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,3 +14,9 @@ services: MYSQL_ALLOW_EMPTY_PASSWORD: "yes" ports: - "33060:3306" + + oracle: + image: oracleinanutshell/oracle-xe-11g + ports: + - "49160:22" + - "49161:1521" diff --git a/src/test/scala/slick/migration/api/dbs.scala b/src/test/scala/slick/migration/api/dbs.scala index 506fa441..5e444604 100644 --- a/src/test/scala/slick/migration/api/dbs.scala +++ b/src/test/scala/slick/migration/api/dbs.scala @@ -6,16 +6,16 @@ import java.util.logging.{Level, Logger} import scala.concurrent.ExecutionContext import scala.concurrent.ExecutionContext.Implicits.{global => ec} + +import slick.dbio.{DBIO, DBIOAction, Effect, NoStream} import slick.jdbc.GetResult._ import slick.jdbc._ -import com.typesafe.slick.testkit.util.{ExternalJdbcTestDB, InternalJdbcTestDB, JdbcTestDB, TestDB} -import org.scalatest.Ignore -import slick.dbio.{DBIO, DBIOAction, Effect, NoStream} import slick.jdbc.meta.{MColumn, MTable} import slick.lifted.{AbstractTable, TableQuery} import slick.model.ForeignKeyAction + object Dialects { implicit def derby : Dialect[DerbyProfile ] = new DerbyDialect implicit def h2 : Dialect[H2Profile ] = new H2Dialect @@ -107,18 +107,6 @@ class PostgresTest extends DbTest(new ExternalJdbcTestDB("postgres") { override def columnDefaultFormat(s: String) = s"'$s'::character varying" } -// copied from slick-testkit - -// To test on Oracle: -// * Install Oracle DB -// - manually from https://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html -// - or using Docker image: oracleinanutshell/oracle-xe-11g -// * Correct connection config in '/test-dbs/testkit.conf' according to your DB config -// * Download Oracle JDBC driver from https://www.oracle.com/technetwork/database/application-development/jdbc/downloads/index.html -// and put it into '/lib' directory -// * Remove '@Ignore' below -// * Run 'sbt testOnly *OracleTest' -@Ignore class OracleTest extends DbTest(new ExternalJdbcTestDB("oracle") { override val profile: OracleProfile.type = OracleProfile import profile.api.actionBasedSQLInterpolation diff --git a/test-dbs/testkit.conf b/test-dbs/testkit.conf index 61074b00..4193eee5 100644 --- a/test-dbs/testkit.conf +++ b/test-dbs/testkit.conf @@ -12,9 +12,9 @@ mysql { } oracle { - enabled = false + enabled = true driver=oracle.jdbc.OracleDriver - baseURL = "jdbc:oracle:thin:@//localhost:1521/xe" + baseURL = "jdbc:oracle:thin:@//localhost:49161/xe" testDB = "" admindb = "" adminConn {