From 96a768f8dba26b32079943cd41a44b4979323b8f Mon Sep 17 00:00:00 2001 From: Katsuya Hidaka Date: Sat, 18 May 2024 10:01:37 +0900 Subject: [PATCH] Add mysql support --- .github/workflows/build.yml | 7 +++++++ README.md | 4 ++-- action.yml | 26 +++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be85e0a..a92ed3d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,6 +28,13 @@ jobs: expected-about-db-adapter: 'SQLite' expected-about-redmine-version: '5\.1\.[0-9]\.stable' + - redmine-repository: 'redmine/redmine' + redmine-version: '5.1-stable' + redmine-database: 'mysql:8.1' + ruby-version: '3.2' + expected-about-db-adapter: 'Mysql2' + expected-about-redmine-version: '5\.1\.[0-9]\.stable' + - redmine-repository: 'redmica/redmica' redmine-version: 'stable-2.4' redmine-database: 'postgres:14' diff --git a/README.md b/README.md index 87eb50b..ee93e31 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ This action installs Redmine and sets up an environment to run tests. It is prim # The branch, tag or commit to checkout. Default is master. version: 'master' - # Database to use for testing. Available values are sqlite3 or - # an official PostgreSQL image tag such as postgres:14. Default is sqlite3. + # Database to use for testing. Possible values are sqlite3 or + # PostgreSQL and MySQL Docker official image tags (e.g. postgres:14, mysql:8.4.0). Default is sqlite3 database: 'sqlite3' # Ruby version to use for testing. See ruby/setup-ruby's ruby-version input for available versions. diff --git a/action.yml b/action.yml index ec9c6e2..20b25af 100644 --- a/action.yml +++ b/action.yml @@ -15,7 +15,7 @@ inputs: required: true default: 'master' database: - description: 'Database to use for testing. Available values are sqlite3 or an official PostgreSQL image tag such as postgres:14. Default is sqlite3.' + description: 'Database to use for testing. Possible values are sqlite3 or PostgreSQL and MySQL Docker official image tags (e.g. postgres:14, mysql:8.4.0). Default is sqlite3' required: true default: 'sqlite3' ruby-version: @@ -96,6 +96,30 @@ runs: shell: bash working-directory: ${{ inputs.path }} + - name: Set up MySQL database connection for testing + if: ${{ startsWith(inputs.database, 'mysql:') }} + run: | + sudo apt-get install -y --no-install-recommends default-mysql-client + + docker run \ + --name redmine-mysql \ + -e MYSQL_ROOT_PASSWORD=password \ + -e MYSQL_DATABASE=redmine_test \ + -p 3306:3306 \ + -d ${{ inputs.database }} + + cat < config/database.yml + test: + adapter: mysql2 + database: redmine_test + host: 127.0.0.1 + port: 3306 + username: root + password: password + EOS + shell: bash + working-directory: ${{ inputs.path }} + - name: Set up SQLite3 database connection for testing if: ${{ inputs.database == 'sqlite3' }} run: |