Skip to content

Commit 32ca9c5

Browse files
authored
Merge pull request #4 from LiveHelperChat/master-test
Automatic test with db access
2 parents 2cd8ed1 + 616e2f3 commit 32ca9c5

File tree

2 files changed

+3658
-1
lines changed

2 files changed

+3658
-1
lines changed

.github/workflows/tests.yml

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ on:
88
pull_request:
99
schedule:
1010
- cron: '0 0 * * *'
11+
repository_dispatch:
12+
types: [livehelperchat-push]
13+
workflow_dispatch:
14+
inputs:
15+
sql_file_path:
16+
description: 'Path to SQL file to import'
17+
required: false
18+
default: 'database/schema.sql'
19+
type: string
1120

1221
permissions:
1322
contents: read
@@ -16,6 +25,16 @@ jobs:
1625
tests:
1726
runs-on: ubuntu-latest
1827

28+
services:
29+
mysql:
30+
image: mysql:8.0
31+
env:
32+
MYSQL_ROOT_PASSWORD: password
33+
MYSQL_DATABASE: testing
34+
ports:
35+
- 3306:3306
36+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
37+
1938
strategy:
2039
fail-fast: true
2140
matrix:
@@ -27,11 +46,35 @@ jobs:
2746
- name: Checkout code
2847
uses: actions/checkout@v4
2948

49+
- name: Clone LiveHelperChat repository
50+
run: |
51+
cd public
52+
git clone --depth 1 https://github.com/LiveHelperChat/livehelperchat.git
53+
54+
- name: Create symlinks in public folder
55+
run: |
56+
cd public
57+
ln -s livehelperchat/lhc_web/cache cache
58+
ln -s livehelperchat/lhc_web/design design
59+
ln -s livehelperchat/lhc_web/extension extension
60+
ln -s livehelperchat/lhc_web/ezcomponents ezcomponents
61+
ln -s livehelperchat/lhc_web/lib lib
62+
ln -s livehelperchat/lhc_web/modules modules
63+
ln -s livehelperchat/lhc_web/pos pos
64+
ln -s livehelperchat/lhc_web/settings settings
65+
ln -s livehelperchat/lhc_web/translations translations
66+
ln -s livehelperchat/lhc_web/var var
67+
68+
- name: Copy settings configuration
69+
run: |
70+
cd public/settings
71+
cp settings.ini.default.php settings.ini.php
72+
3073
- name: Setup PHP
3174
uses: shivammathur/setup-php@v2
3275
with:
3376
php-version: ${{ matrix.php }}
34-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
77+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, pdo_mysql, mysqli
3578
coverage: none
3679

3780
- name: Install Composer dependencies
@@ -43,5 +86,49 @@ jobs:
4386
- name: Generate app key
4487
run: php artisan key:generate
4588

89+
- name: Configure database connection
90+
run: |
91+
php artisan config:clear
92+
env:
93+
DB_CONNECTION: mysql
94+
DB_HOST: 127.0.0.1
95+
DB_PORT: 3306
96+
DB_DATABASE: testing
97+
DB_USERNAME: root
98+
DB_PASSWORD: password
99+
100+
- name: Import SQL database
101+
run: |
102+
mysql -h 127.0.0.1 -u root -ppassword testing < ${{ github.event.inputs.sql_file_path || 'database/schema.sql' }}
103+
104+
- name: Run migrations
105+
run: php artisan migrate --force
106+
env:
107+
LHC_DB_CONNECTION: mysql
108+
LHC_DB_HOST: 127.0.0.1
109+
LHC_DB_PORT: 3306
110+
LHC_DB_DATABASE: testing
111+
LHC_DB_USERNAME: root
112+
LHC_DB_PASSWORD: password
113+
DB_CONNECTION: mysql
114+
DB_HOST: 127.0.0.1
115+
DB_PORT: 3306
116+
DB_DATABASE: testing
117+
DB_USERNAME: root
118+
DB_PASSWORD: password
119+
46120
- name: Execute tests
47121
run: php artisan test
122+
env:
123+
DB_CONNECTION: mysql
124+
DB_HOST: 127.0.0.1
125+
DB_PORT: 3306
126+
DB_DATABASE: testing
127+
DB_USERNAME: root
128+
DB_PASSWORD: password
129+
LHC_DB_CONNECTION: mysql
130+
LHC_DB_HOST: 127.0.0.1
131+
LHC_DB_PORT: 3306
132+
LHC_DB_DATABASE: testing
133+
LHC_DB_USERNAME: root
134+
LHC_DB_PASSWORD: password

0 commit comments

Comments
 (0)