Skip to content

Commit

Permalink
Separate the setup of MySQL, PostgreSQL, and SQLite3 into individual …
Browse files Browse the repository at this point in the history
…scripts
  • Loading branch information
hidakatsuya committed Jul 11, 2024
1 parent 86ecd00 commit 8ed66bf
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 55 deletions.
69 changes: 14 additions & 55 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,69 +78,28 @@ runs:
echo GOOGLE_CHROME_OPTS_ARGS="headless,disable-gpu,no-sandbox,disable-dev-shm-usage" >> $GITHUB_ENV
shell: bash

- name: Set up PostgreSQL database connection for testing
- name: Set up PostgreSQL database
if: ${{ startsWith(inputs.database, 'postgres:') }}
run: |
sudo apt-get install -y --no-install-recommends libpq-dev
docker run \
--name redmine-postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
-d ${{ inputs.database }}
cat <<EOS > config/database.yml
test:
adapter: postgresql
database: redmine_test
encoding: utf8
host: localhost
port: 5432
username: postgres
password: postgres
EOS
run: ./scripts/setup-postgresql.sh
shell: bash
working-directory: ${{ inputs.path }}
env:
REDMINE_DIR: ${{ inputs.path }}
DATABASE: ${{ inputs.database }}

- name: Set up MySQL database connection for testing
- name: Set up MySQL database
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 }} \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci
cat <<EOS > config/database.yml
test:
adapter: mysql2
database: redmine_test
host: 127.0.0.1
port: 3306
username: root
password: password
encoding: utf8mb4
EOS
run: ./scripts/setup-mysql.sh
shell: bash
working-directory: ${{ inputs.path }}
env:
REDMINE_DIR: ${{ inputs.path }}
DATABASE: ${{ inputs.database }}

- name: Set up SQLite3 database connection for testing
- name: Set up SQLite3 database
if: ${{ inputs.database == 'sqlite3' }}
run: |
sudo apt-get install -y --no-install-recommends libsqlite3-dev
cat <<EOS > config/database.yml
test:
adapter: sqlite3
database: db/test.sqlite3
EOS
run: ./scripts/setup-sqlite3.sh
shell: bash
working-directory: ${{ inputs.path }}
env:
REDMINE_DIR: ${{ inputs.path }}

# https://www.redmine.org/issues/40802
- name: Fix LoadError in Redmine 4.2
Expand Down
26 changes: 26 additions & 0 deletions scripts/setup-mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -eu

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 $DATABASE \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci

cd $REDMINE_DIR
cat <<EOS > config/database.yml
test:
adapter: mysql2
database: redmine_test
host: 127.0.0.1
port: 3306
username: root
password: password
encoding: utf8mb4
EOS
23 changes: 23 additions & 0 deletions scripts/setup-postgresql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -eu

sudo apt-get install -y --no-install-recommends libpq-dev

docker run \
--name redmine-postgres \
-e POSTGRES_PASSWORD=postgres \
-p 5432:5432 \
-d $DATABASE

cd $REDMINE_DIR
cat <<EOS > config/database.yml
test:
adapter: postgresql
database: redmine_test
encoding: utf8
host: localhost
port: 5432
username: postgres
password: postgres
EOS
12 changes: 12 additions & 0 deletions scripts/setup-sqlite3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -eu

sudo apt-get install -y --no-install-recommends libsqlite3-dev

cd $REDMINE_DIR
cat <<EOS > config/database.yml
test:
adapter: sqlite3
database: db/test.sqlite3
EOS

0 comments on commit 8ed66bf

Please sign in to comment.