Skip to content

Commit

Permalink
Add mysql support
Browse files Browse the repository at this point in the history
  • Loading branch information
hidakatsuya committed May 18, 2024
1 parent fbeb7f8 commit 2c61d8f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
27 changes: 26 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 <<EOS > 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: |
Expand All @@ -118,6 +142,7 @@ runs:

- name: Set up database
run: |
bundle show
bin/rails db:create db:migrate
shell: bash
working-directory: ${{ inputs.path }}

0 comments on commit 2c61d8f

Please sign in to comment.