Skip to content

Commit

Permalink
feat: add phpunits
Browse files Browse the repository at this point in the history
2 types de tests:
unitaire: tester une classe seule sans dépendance = github workflow phpunit.yml
intégration: tester jeedom en fonctionnement, utilise docker pour démarrer la bdd et le container jeedom = github workflow docker-test.yml
  • Loading branch information
pifou25 committed Mar 1, 2025
1 parent 8d71c40 commit 7995a99
Show file tree
Hide file tree
Showing 21 changed files with 2,308 additions and 523 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
/vendor
/docs
17 changes: 13 additions & 4 deletions .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# build docker image based on debian bullseye and bookworm
# build docker image based on debian bullseye or bookworm
# start both containers and run sick.php
# install composer dev depedencies and run phpunits into running containers
# stop & clean
name: Docker Test Image
name: Integrated PHPUnit

on:
# only trigger CI when pull request on following branches
pull_request:
branches:
- 'alpha'
push:
branches:
- 'feat/run_phpunit'
# this is to manually trigger the worklow
workflow_dispatch:
inputs:
Expand All @@ -30,21 +34,26 @@ jobs:
run: |
docker build -t jeedom:bullseye --build-arg DEBIAN=bullseye --build-arg DATABASE=1 .
- name: run jeedom:bullseye and check
# build current image for bullseye and check it
# run current image for bullseye and check it
run: |
docker run -p 80:80 -d --rm --name jeedom_bullseye jeedom:bullseye
sleep 45
docker exec jeedom_bullseye php sick.php
docker exec jeedom_bullseye /bin/bash -c "COMPOSER_NO_DEV=0 && composer install"
docker exec jeedom_bullseye ./vendor/bin/phpunit --testsuite integration
- name: Build jeedom:bookworm
# build current image for bookworm
run: |
docker build -t jeedom:bookworm --build-arg DEBIAN=bookworm --build-arg DATABASE=1 .
- name: run jeedom:bookworm and check
# build current image for bookworm and check it
# run current image for bookworm and check it
run: |
docker run -p 81:80 -d --rm --name jeedom_bookworm jeedom:bookworm
sleep 45
docker exec jeedom_bookworm php sick.php
docker exec jeedom_bookworm /bin/bash -c "COMPOSER_NO_DEV=0 && composer install"
docker exec jeedom_bookworm ./vendor/bin/phpunit --testsuite integration
- name: Clean docker image
continue-on-error: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ tmp/*

!.htaccess
.env
.phpunit.result.cache
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@ EXPOSE 80
EXPOSE 443
COPY --chown=root:root --chmod=550 install/OS_specific/Docker/init.sh /root/
COPY --chown=root:root --chmod=550 install/bashrc /root/.bashrc
CMD ["bash", "/root/init.sh"]
SHELL ["/bin/bash", "-c"]
CMD ["/root/init.sh"]
17 changes: 8 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
"symfony/expression-language": "5 - 7",
"pragmarx/google2fa-qrcode": "^3",
"bacon/bacon-qr-code": "2 - 3",
"influxdata/influxdb-client-php": "^3",
"psr/log": "^1.1",
"php": ">=7.4"
"influxdb/influxdb-php": "^1.15",
"psr/log": "^1.1"
},
"config": {
"allow-plugins": {
"php-http/discovery": true
},
"platform": {
"php": "7.4"
}
"allow-plugins": {
"php-http/discovery": true
}
},
"require-dev": {
"phpunit/phpunit": "^9.6"
}
}
Loading

0 comments on commit 7995a99

Please sign in to comment.