chatwork / sbt-wix-embedded-mysql   1.0.30

MIT License GitHub

sbt-wix-embedded-mysql is sbt-plugin for wix-embedded-mysql

Scala versions: 2.12
sbt plugins: 1.x

sbt-wix-embedded-mysql

CI Scala Steward badge Maven Central Scaladoc License

sbt-wix-embedded-mysql is sbt-plugin for wix-embedded-mysql

You can start and stop embedded MySQL on sbt task.

Installation

Add this to your project/plugins.sbt file:

project/plugins.sbt

Supported sbt version is 1.x.

resolvers += "Sonatype OSS Release Repository" at "https://oss.sonatype.org/content/repositories/releases/"

addSbtPlugin("com.chatwork" % "sbt-wix-embedded-mysql" % "1.0.11")

Usage

Basic Configuration

If you want default settings, no configuration is necessary. Please refer to here for sbt keys of the plugin.These sbt keys base on the API of wix-embedded-mysql. If you understand how to use wix-embedded-mysql, it is easy to use this plugin.

An example for configuration

build.sbt

wixMySQLVersion := com.wix.mysql.distribution.Version.v8_latest

wixMySQLSchemaName := "your schema name"

wixMySQLUserName := Some("my-db-user")

wixMySQLPassword := Some("my-db-passwd")

Task of sbt

You can use sbt tasks that the followings.

// start mysqld
> wixMySQLStart

// stop mysqld
> wixMySQLStop

How to use for testing

build.sbt

Test / testOptions ++= Seq(
  Tests.Setup { () =>
    wixMySQLStart.value
    // If you want to use the flywayMigrate together, please join the two tasks using `Def.sequential` as follows.
    // Def.sequential(wixMySQLStart, flywayMigrate).value
  },
  Tests.Cleanup { () =>
    wixMySQLStop.value
  }
)

How to use on Github Actions

.github/workflows/ci.yml

# -- snip
steps:
  - uses: actions/[email protected]
    with:
      fetch-depth: 0
  - uses: olafurpg/setup-scala@v12
    with:
      java-version: "[email protected]"
  - uses: coursier/cache-action@v6
  - run: |
    sudo echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' | sudo tee -a /etc/apt/sources.list
    sudo apt-get update -qq
    sudo apt-get install -y libaio1 libevent-dev libssl-dev libssl1.0.0
  - run: sbt -v test
# -- snip

Seting up download cache on Github Actions

build.sbt

wixMySQLDownloadPath := Some(sys.env("HOME") + "/.wixMySQL/downloads"),

.github/workflows/ci.yml

# -- snip
steps:
  - uses: actions/cache@v2
    with:
      path: |
        ~/.wixMySQL
# -- snip