@@ -12,160 +12,194 @@ on:
1212
1313jobs :
1414 unit-tests :
15- name : Unit Tests - ${{ matrix.module }} (PHP ${{ matrix.php -version }})
15+ name : Unit Tests - ${{ matrix.module }} (PS ${{ matrix.ps -version }})
1616 runs-on : ubuntu-latest
1717
1818 strategy :
1919 fail-fast : false
2020 matrix :
2121 include :
2222 - module : ps17
23+ ps-version : ' 1.7.7.0'
2324 php-version : ' 7.2'
2425 - module : ps8
26+ ps-version : ' 8.1.5'
2527 php-version : ' 8.1'
2628 - module : ps9
29+ ps-version : ' 9.0.0'
2730 php-version : ' 8.4'
2831
32+ services :
33+ mysql :
34+ image : mariadb:10.9.4
35+ env :
36+ MYSQL_ROOT_PASSWORD : prestashop
37+ MYSQL_DATABASE : prestashop
38+ options : >-
39+ --health-cmd="mysqladmin ping -h127.0.0.1 -uroot -pprestashop --silent"
40+ --health-interval=10s
41+ --health-timeout=5s
42+ --health-retries=5
43+
2944 steps :
3045 - name : Checkout code
3146 uses : actions/checkout@v4
3247
33- - name : Setup PHP
34- uses : shivammathur/setup-php@v2
35- with :
36- php-version : ${{ matrix.php-version }}
37- extensions : mbstring, xml, ctype, json, zip
38- coverage : none
39-
40- - name : Get Composer cache directory
41- id : composer-cache
42- run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
43-
44- - name : Cache Composer dependencies
45- uses : actions/cache@v4
46- with :
47- path : ${{ steps.composer-cache.outputs.dir }}
48- key : ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
49- restore-keys : |
50- ${{ runner.os }}-php-${{ matrix.php-version }}-composer-
51-
52- - name : Install root dependencies
53- run : composer install --prefer-dist --no-progress --no-interaction
54-
55- - name : Install ${{ matrix.module }} module dependencies
56- working-directory : ${{ matrix.module }}
57- run : composer install --prefer-dist --no-progress --no-interaction
58-
59- - name : Copy monorepo directories to vendor
60- working-directory : ${{ matrix.module }}
61- run : |
62- mkdir -p vendor/invertus
63- cp -r ${{ github.workspace }}/api vendor/invertus/
64- cp -r ${{ github.workspace }}/core vendor/invertus/
65- cp -r ${{ github.workspace }}/infrastructure vendor/invertus/
66- cp -r ${{ github.workspace }}/presentation vendor/invertus/
67- cp -r ${{ github.workspace }}/utility vendor/invertus/
48+ - name : Pull PrestaShop Docker image
49+ run : docker pull prestashop/prestashop:${{ matrix.ps-version }}
50+
51+ - name : Start PrestaShop container
52+ run : |
53+ docker run -tid --rm \
54+ --name prestashop-${{ matrix.module }} \
55+ --network ${{ job.container.network }} \
56+ -e DB_SERVER=mysql \
57+ -e DB_NAME=prestashop \
58+ -e DB_USER=root \
59+ -e DB_PASSWD=prestashop \
60+ -e PS_INSTALL_AUTO=0 \
61+ prestashop/prestashop:${{ matrix.ps-version }}
62+
63+ - name : Wait for PrestaShop to be ready
64+ run : |
65+ timeout 60 bash -c 'until docker exec prestashop-${{ matrix.module }} test -f /var/www/html/config/config.inc.php 2>/dev/null || docker exec prestashop-${{ matrix.module }} test -f /var/www/html/app/config/parameters.php 2>/dev/null; do sleep 2; done' || true
66+ sleep 5
67+
68+ - name : Install module dependencies
69+ run : |
70+ docker exec prestashop-${{ matrix.module }} bash -c "cd /tmp && composer create-project --no-dev ${{ matrix.module }}-module"
71+ docker cp ${{ matrix.module }}/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/
72+
73+ - name : Install Composer dependencies in container
74+ run : |
75+ docker exec prestashop-${{ matrix.module }} bash -c "cd /var/www/html/modules/ps_checkout && composer install --no-interaction --prefer-dist"
76+
77+ - name : Copy monorepo directories to module vendor
78+ run : |
79+ docker exec prestashop-${{ matrix.module }} bash -c "mkdir -p /var/www/html/modules/ps_checkout/vendor/invertus"
80+ docker cp api/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/api/
81+ docker cp core/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/core/
82+ docker cp infrastructure/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/infrastructure/
83+ docker cp presentation/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/presentation/
84+ docker cp utility/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/utility/
6885
6986 - name : Run Infrastructure Unit Tests
70- working-directory : ${{ matrix.module }}
7187 run : |
72- php vendor/bin/phpunit \
88+ docker exec prestashop-${{ matrix.module }} bash -c "cd /var/www/html/modules/ps_checkout && php vendor/bin/phpunit \
7389 --configuration=vendor/invertus/infrastructure/tests/phpunit.xml \
74- --bootstrap=vendor/invertus/infrastructure/tests/bootstrap.php
90+ --bootstrap=vendor/invertus/infrastructure/tests/bootstrap.php"
7591
7692 - name : Run Utility Unit Tests
77- working-directory : ${{ matrix.module }}
7893 run : |
79- php vendor/bin/phpunit \
94+ docker exec prestashop-${{ matrix.module }} bash -c "cd /var/www/html/modules/ps_checkout && php vendor/bin/phpunit \
8095 --configuration=vendor/invertus/utility/tests/phpunit.xml \
81- --bootstrap=vendor/invertus/utility/tests/bootstrap.php
96+ --bootstrap=vendor/invertus/utility/tests/bootstrap.php"
8297
8398 - name : Run Core Unit Tests
84- working-directory : ${{ matrix.module }}
8599 run : |
86- php vendor/bin/phpunit \
100+ docker exec prestashop-${{ matrix.module }} bash -c "cd /var/www/html/modules/ps_checkout && php vendor/bin/phpunit \
87101 --configuration=vendor/invertus/core/tests/phpunit.xml \
88- --bootstrap=vendor/invertus/core/tests/bootstrap.php
102+ --bootstrap=vendor/invertus/core/tests/bootstrap.php"
89103
90104 - name : Run Presentation Unit Tests
91- working-directory : ${{ matrix.module }}
92105 run : |
93- php vendor/bin/phpunit \
106+ docker exec prestashop-${{ matrix.module }} bash -c "cd /var/www/html/modules/ps_checkout && php vendor/bin/phpunit \
94107 --configuration=vendor/invertus/presentation/tests/phpunit.xml \
95- --bootstrap=vendor/invertus/presentation/tests/bootstrap.php
108+ --bootstrap=vendor/invertus/presentation/tests/bootstrap.php"
109+
110+ - name : Cleanup
111+ if : always()
112+ run : docker stop prestashop-${{ matrix.module }} || true
96113
97114 integration-tests :
98- name : Integration Tests - ${{ matrix.module }} (PHP ${{ matrix.php -version }})
115+ name : Integration Tests - ${{ matrix.module }} (PS ${{ matrix.ps -version }})
99116 runs-on : ubuntu-latest
100117
101118 strategy :
102119 fail-fast : false
103120 matrix :
104121 include :
105122 - module : ps17
123+ ps-version : ' 1.7.7.0'
106124 php-version : ' 7.2'
107125 - module : ps8
126+ ps-version : ' 8.1.5'
108127 php-version : ' 8.1'
109128 - module : ps9
129+ ps-version : ' 9.0.0'
110130 php-version : ' 8.4'
111131
132+ services :
133+ mysql :
134+ image : mariadb:10.9.4
135+ env :
136+ MYSQL_ROOT_PASSWORD : prestashop
137+ MYSQL_DATABASE : prestashop
138+ options : >-
139+ --health-cmd="mysqladmin ping -h127.0.0.1 -uroot -pprestashop --silent"
140+ --health-interval=10s
141+ --health-timeout=5s
142+ --health-retries=5
143+
112144 steps :
113145 - name : Checkout code
114146 uses : actions/checkout@v4
115147
116- - name : Setup PHP
117- uses : shivammathur/setup-php@v2
118- with :
119- php-version : ${{ matrix.php-version }}
120- extensions : mbstring, xml, ctype, json, zip
121- coverage : none
122-
123- - name : Get Composer cache directory
124- id : composer-cache
125- run : echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
126-
127- - name : Cache Composer dependencies
128- uses : actions/cache@v4
129- with :
130- path : ${{ steps.composer-cache.outputs.dir }}
131- key : ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.lock') }}
132- restore-keys : |
133- ${{ runner.os }}-php-${{ matrix.php-version }}-composer-
134-
135- - name : Install root dependencies
136- run : composer install --prefer-dist --no-progress --no-interaction
137-
138- - name : Install ${{ matrix.module }} module dependencies
139- working-directory : ${{ matrix.module }}
140- run : composer install --prefer-dist --no-progress --no-interaction
141-
142- - name : Copy monorepo directories to vendor
143- working-directory : ${{ matrix.module }}
144- run : |
145- mkdir -p vendor/invertus
146- cp -r ${{ github.workspace }}/api vendor/invertus/
147- cp -r ${{ github.workspace }}/core vendor/invertus/
148- cp -r ${{ github.workspace }}/infrastructure vendor/invertus/
149- cp -r ${{ github.workspace }}/presentation vendor/invertus/
150- cp -r ${{ github.workspace }}/utility vendor/invertus/
148+ - name : Pull PrestaShop Docker image
149+ run : docker pull prestashop/prestashop:${{ matrix.ps-version }}
150+
151+ - name : Start PrestaShop container
152+ run : |
153+ docker run -tid --rm \
154+ --name prestashop-${{ matrix.module }} \
155+ --network ${{ job.container.network }} \
156+ -e DB_SERVER=mysql \
157+ -e DB_NAME=prestashop \
158+ -e DB_USER=root \
159+ -e DB_PASSWD=prestashop \
160+ -e PS_INSTALL_AUTO=0 \
161+ prestashop/prestashop:${{ matrix.ps-version }}
162+
163+ - name : Wait for PrestaShop to be ready
164+ run : |
165+ timeout 60 bash -c 'until docker exec prestashop-${{ matrix.module }} test -f /var/www/html/config/config.inc.php 2>/dev/null || docker exec prestashop-${{ matrix.module }} test -f /var/www/html/app/config/parameters.php 2>/dev/null; do sleep 2; done' || true
166+ sleep 5
167+
168+ - name : Copy module to PrestaShop
169+ run : |
170+ docker cp ${{ matrix.module }}/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/
171+
172+ - name : Install Composer dependencies in container
173+ run : |
174+ docker exec prestashop-${{ matrix.module }} bash -c "cd /var/www/html/modules/ps_checkout && composer install --no-interaction --prefer-dist"
175+
176+ - name : Copy monorepo directories to module vendor
177+ run : |
178+ docker exec prestashop-${{ matrix.module }} bash -c "mkdir -p /var/www/html/modules/ps_checkout/vendor/invertus"
179+ docker cp api/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/api/
180+ docker cp core/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/core/
181+ docker cp infrastructure/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/infrastructure/
182+ docker cp presentation/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/presentation/
183+ docker cp utility/. prestashop-${{ matrix.module }}:/var/www/html/modules/ps_checkout/vendor/invertus/utility/
151184
152185 - name : Run Infrastructure Integration Tests
153- working-directory : ${{ matrix.module }}
154186 run : |
155- php vendor/bin/phpunit \
187+ docker exec prestashop-${{ matrix.module }} bash -c "cd /var/www/html/modules/ps_checkout && php vendor/bin/phpunit \
156188 --configuration=vendor/invertus/infrastructure/tests/phpunit-integration.xml \
157- --bootstrap=vendor/invertus/infrastructure/tests/bootstrap-integration.php
189+ --bootstrap=vendor/invertus/infrastructure/tests/bootstrap-integration.php"
158190
159191 - name : Run Core Integration Tests
160- working-directory : ${{ matrix.module }}
161192 run : |
162- php vendor/bin/phpunit \
193+ docker exec prestashop-${{ matrix.module }} bash -c "cd /var/www/html/modules/ps_checkout && php vendor/bin/phpunit \
163194 --configuration=vendor/invertus/core/tests/phpunit-integration.xml \
164- --bootstrap=vendor/invertus/core/tests/bootstrap-integration.php
195+ --bootstrap=vendor/invertus/core/tests/bootstrap-integration.php"
165196
166197 - name : Run Module Integration Tests
167- working-directory : ${{ matrix.module }}
168198 run : |
169- php vendor/bin/phpunit \
199+ docker exec prestashop-${{ matrix.module }} bash -c "cd /var/www/html/modules/ps_checkout && php vendor/bin/phpunit \
170200 --configuration=tests/phpunit-integration.xml \
171- --bootstrap=tests/bootstrap-integration.php
201+ --bootstrap=tests/bootstrap-integration.php"
202+
203+ - name : Cleanup
204+ if : always()
205+ run : docker stop prestashop-${{ matrix.module }} || true
0 commit comments