Skip to content

Commit 0493c6e

Browse files
Progi1984Progi1984
authored andcommitted
Added coverage
1 parent 4eb24ac commit 0493c6e

File tree

4 files changed

+70
-8
lines changed

4 files changed

+70
-8
lines changed

.github/workflows/integration.yml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@ jobs:
2525
prestashop_version: '9.0.x'
2626
fail-fast: false
2727
steps:
28-
- name: Checkout module code
28+
- name: Checkout Module
2929
uses: actions/checkout@v3
3030
with:
3131
path: ps_apiresources
32-
- uses: actions/checkout@v3
33-
name: Checkout PrestaShop repository
32+
33+
- name: Checkout PrestaShop repository
34+
uses: actions/checkout@v3
3435
with:
3536
fetch-depth: 0
3637
repository: PrestaShop/PrestaShop
3738
path: prestashop
3839
ref: ${{ matrix.prestashop_version }}
40+
3941
- name: Build Docker
4042
timeout-minutes: 15
4143
env:
@@ -48,16 +50,59 @@ jobs:
4850
exit
4951
fi
5052
bash -l -c 'while [[ "$(curl -L -s -o /dev/null -w %{http_code} 'http://localhost:8001/install-dev/')" != "200" ]]; do echo "waiting for shop install"; sleep 5; done'
51-
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 php bin/console prestashop:module uninstall ps_apiresources
53+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 \
54+
php bin/console prestashop:module uninstall ps_apiresources
55+
5256
- name: Install Module
5357
run: |
5458
rm -rf prestashop/modules/ps_apiresources
5559
mkdir -p prestashop/modules/ps_apiresources
5660
cp -r ps_apiresources/* prestashop/modules/ps_apiresources
5761
ls -l prestashop/modules/ps_apiresources
58-
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 composer install --no-interaction --working-dir=/var/www/html/modules/ps_apiresources
59-
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 php bin/console prestashop:module install ps_apiresources
60-
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 composer create-test-db
62+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 \
63+
composer install --no-interaction --working-dir=/var/www/html/modules/ps_apiresources
64+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 \
65+
php bin/console prestashop:module install ps_apiresources
66+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 \
67+
composer create-test-db
68+
69+
- name: Install pcov & git
70+
if: matrix.php == '8.4' && matrix.prestashop_version == 'develop'
71+
run: |
72+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 \
73+
pecl install pcov
74+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 \
75+
docker-php-ext-enable pcov
76+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 \
77+
apt install -y git
78+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 \
79+
git config --global --add safe.directory /var/www/html
80+
6181
- name: Run integration tests
82+
env:
83+
CLI_PHP: ${{ (matrix.php == '8.4' && matrix.prestashop_version == 'develop') && '-d extension=pcov.so -d pcov.enabled=1 -d pcov.directory=./modules/ps_apiresources/ -d pcov.exclude="~(tests|vendor)~" -d memory_limit=-1' || ' ' }}
84+
CLI_PHPUNIT: ${{ (matrix.php == '8.4' && matrix.prestashop_version == 'develop') && ' ' || ' --no-coverage' }}
6285
run : |
63-
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 vendor/bin/phpunit -c modules/ps_apiresources/tests/Integration/phpunit-ci.xml
86+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec prestashop-prestashop-git-1 \
87+
php ${{env.CLI_PHP}} vendor/bin/phpunit -c modules/ps_apiresources/tests/Integration/phpunit-ci.xml${{ env.CLI_PHPUNIT }}
88+
89+
- name: Upload coverage results to Coveralls
90+
if: matrix.php == '8.4' && matrix.prestashop_version == 'develop'
91+
env:
92+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
run: |
94+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec -w /var/www/html/modules/ps_apiresources prestashop-prestashop-git-1 \
95+
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.9.1/php-coveralls.phar
96+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec -w /var/www/html/modules/ps_apiresources prestashop-prestashop-git-1 \
97+
chmod +x php-coveralls.phar
98+
USER_ID=$(id -u) GROUP_ID=$(id -g) docker exec \
99+
-w /var/www/html/modules/ps_apiresources prestashop-prestashop-git-1 \
100+
-e COVERALLS_REPO_TOKEN=${{env.COVERALLS_REPO_TOKEN}} \
101+
-e GITHUB_ACTIONS=true \
102+
-e GITHUB_EVENT_NAME=${{github.event_name}} \
103+
-e GITHUB_REF=${{github.ref}} \
104+
-e GITHUB_RUN_ID=${{github.run_id}} \
105+
php php-coveralls.phar \
106+
--coverage_clover=tests/Integration/clover.xml \
107+
--json_path=tests/Integration/coveralls-upload.json \
108+
-v

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
## Directories
12
/vendor
3+
4+
## Files
25
.php-cs-fixer.cache
36
.phpunit.result.cache
7+
clover.xml
48
tests/local-parameters/parameters.php
59
tests/local-parameters/parameters.yml

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# PrestaShop API Resources
22

3+
[![Coverage Status](https://coveralls.io/repos/github/PrestaShop/ps_apiresources/badge.svg)](https://coveralls.io/github/PrestaShop/ps_apiresources)
4+
35
## About
46

57
Includes the resources allowing using the API for the PrestaShop domain, all endpoints are based on CQRS commands/queries from the Core and we [API Platform](https://api-platform.com/) framework is used as a base.

tests/Integration/phpunit-ci.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,15 @@
1212
<directory>.</directory>
1313
</testsuite>
1414
</testsuites>
15+
<source>
16+
<include>
17+
<directory suffix=".php">../../src</directory>
18+
</include>
19+
</source>
20+
<coverage
21+
includeUncoveredFiles="false">
22+
<report>
23+
<clover outputFile="clover.xml"/>
24+
</report>
25+
</coverage>
1526
</phpunit>

0 commit comments

Comments
 (0)