diff --git a/action.yml b/action.yml index d79c655..159b51c 100644 --- a/action.yml +++ b/action.yml @@ -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 < 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 < 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 < 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 diff --git a/scripts/setup-mysql.sh b/scripts/setup-mysql.sh new file mode 100755 index 0000000..63aa79e --- /dev/null +++ b/scripts/setup-mysql.sh @@ -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 < config/database.yml + test: + adapter: mysql2 + database: redmine_test + host: 127.0.0.1 + port: 3306 + username: root + password: password + encoding: utf8mb4 +EOS diff --git a/scripts/setup-postgresql.sh b/scripts/setup-postgresql.sh new file mode 100755 index 0000000..f9f335f --- /dev/null +++ b/scripts/setup-postgresql.sh @@ -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 < config/database.yml + test: + adapter: postgresql + database: redmine_test + encoding: utf8 + host: localhost + port: 5432 + username: postgres + password: postgres +EOS diff --git a/scripts/setup-sqlite3.sh b/scripts/setup-sqlite3.sh new file mode 100755 index 0000000..6ec867a --- /dev/null +++ b/scripts/setup-sqlite3.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +set -eu + +sudo apt-get install -y --no-install-recommends libsqlite3-dev + +cd $REDMINE_DIR +cat < config/database.yml + test: + adapter: sqlite3 + database: db/test.sqlite3 +EOS