Skip to content

Commit 45f0d4b

Browse files
committed
Adjust db config and prepare system test
1 parent c0be744 commit 45f0d4b

File tree

1 file changed

+90
-21
lines changed

1 file changed

+90
-21
lines changed

.github/workflows/test.yml

Lines changed: 90 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Test with Postgres
1+
name: Test
22

33
env:
44
PLUGIN_NAME: ${{ github.event.repository.name }}
@@ -15,7 +15,7 @@ on:
1515

1616
jobs:
1717
test:
18-
name: redmine:${{ matrix.redmine_version }} ruby:${{ matrix.ruby_version }} postgres:${{ matrix.db_version }}
18+
name: redmine:${{ matrix.redmine_version }} ruby:${{ matrix.ruby_version }} db:${{ matrix.db }}
1919
runs-on: ubuntu-22.04
2020

2121
container:
@@ -25,17 +25,33 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
redmine_version: [4.2-stable, 5.0-stable, master]
28-
ruby_version: [2.7, 3.0, 3.1]
29-
db_version: [10, 14]
28+
ruby_version: ['2.6', '2.7', '3.0', '3.1']
29+
db: [mysql, postgres, sqlite]
30+
# # System test takes 2~3 times longer, so limit to specific matrix combinations
31+
# # See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#expanding-or-adding-matrix-configurations
32+
# include:
33+
# - system_test: true
34+
# redmine_version: master
35+
# ruby_version: '3.1'
36+
# db: mysql
3037
exclude:
3138
- redmine_version: 4.2-stable
32-
ruby_version: 3.0
39+
ruby_version: '3.0'
3340
- redmine_version: 4.2-stable
34-
ruby_version: 3.1
41+
ruby_version: '3.1'
3542

3643
services:
44+
mysql:
45+
image: mysql:5.7 # min
46+
# image: mysql:8.0 # latest
47+
env:
48+
MYSQL_ROOT_PASSWORD: password
49+
ports:
50+
- 3306:3306
51+
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 5
3752
postgres:
38-
image: postgres:${{ matrix.db_version }}
53+
image: postgres:10 # min
54+
# image: postgres:15 # latest
3955
env:
4056
POSTGRES_USER: postgres
4157
POSTGRES_PASSWORD: postgres
@@ -45,37 +61,73 @@ jobs:
4561

4662
steps:
4763
- name: Checkout Redmine
48-
uses: actions/checkout@v2
64+
uses: actions/checkout@v3
4965
with:
5066
repository: redmine/redmine
5167
ref: ${{ matrix.redmine_version }}
5268
path: redmine
5369

5470
- name: Checkout Plugin
55-
uses: actions/checkout@v2
71+
uses: actions/checkout@v3
5672
with:
5773
path: redmine/plugins/${{ env.PLUGIN_NAME }}
5874

5975
- name: Update package archives
6076
run: apt-get update --yes --quiet
6177

6278
- name: Install package dependencies
63-
run: >
64-
apt-get install --yes --quiet
65-
postgresql-client
79+
run: |
80+
if [ ${{ matrix.db }} = "mysql" ]; then
81+
apt-get install --yes --quiet default-mysql-client-core
82+
fi
83+
if [ ${{ matrix.db }} = "postgres" ]; then
84+
apt-get install --yes --quiet postgresql-client
85+
fi
86+
# For system test
87+
if [ ${{ matrix.system_test }} = "true" ]; then
88+
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
89+
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
90+
apt-get -y update
91+
apt-get install -y google-chrome-stable
92+
fi
93+
94+
- name: Verify MySQL connection from host
95+
if: matrix.db == 'mysql'
96+
run: |
97+
mysql --host mysql --port 3306 -uroot -ppassword -e "SHOW DATABASES"
6698
6799
- name: Prepare Redmine source
68100
working-directory: redmine
69101
run: |
70-
cat <<EOF > config/database.yml
71-
test:
72-
adapter: postgresql
73-
database: redmine
74-
host: postgres
75-
username: postgres
76-
password: postgres
77-
encoding: utf8
102+
if [ ${{ matrix.db }} = "mysql" ]; then
103+
cat <<EOF > config/database.yml
104+
test:
105+
adapter: mysql2
106+
database: redmine
107+
host: mysql
108+
username: root
109+
password: password
110+
encoding: utf8mb4
111+
EOF
112+
fi
113+
if [ ${{ matrix.db }} = "postgres" ]; then
114+
cat <<EOF > config/database.yml
115+
test:
116+
adapter: postgresql
117+
database: redmine
118+
host: postgres
119+
username: postgres
120+
password: postgres
121+
encoding: utf8
78122
EOF
123+
fi
124+
if [ ${{ matrix.db }} = "sqlite" ]; then
125+
cat <<EOF > config/database.yml
126+
test:
127+
adapter: sqlite3
128+
database: db/redmine.sqlite3
129+
EOF
130+
fi
79131
80132
- name: Install Ruby dependencies
81133
working-directory: redmine
@@ -101,12 +153,29 @@ jobs:
101153
fi
102154
shell: bash
103155

104-
- name: Run tests
156+
- name: Run plugin tests
105157
env:
106158
RAILS_ENV: test
159+
# For system test in plugin
160+
GOOGLE_CHROME_OPTS_ARGS: "headless,disable-gpu,no-sandbox,disable-dev-shm-usage"
107161
working-directory: redmine
108162
run: bundle exec rake redmine:plugins:test NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
109163

164+
# - name: Run core tests
165+
# env:
166+
# RAILS_ENV: test
167+
# PARALLEL_WORKERS: 1
168+
# working-directory: redmine
169+
# run: bundle exec rake test
170+
171+
# - name: Run core system tests
172+
# if: matrix.system_test == true
173+
# env:
174+
# RAILS_ENV: test
175+
# GOOGLE_CHROME_OPTS_ARGS: "headless,disable-gpu,no-sandbox,disable-dev-shm-usage"
176+
# working-directory: redmine
177+
# run: bundle exec rake test:system
178+
110179
- name: Run uninstall test
111180
env:
112181
RAILS_ENV: test

0 commit comments

Comments
 (0)