Skip to content

Commit

Permalink
[TASK] Update to use compose.yml and integrate PHPUnit
Browse files Browse the repository at this point in the history
- Rename docker-compose.yml to compose.yml
- Add PHPUnit 11.2.1 to composer.json
- Update README.md with setup instructions for Docker Compose and PHPUnit
- Ensure .gitignore includes vendor directory
- Adjust GitHub Actions workflow to use compose.yml
  • Loading branch information
Marc Wolf committed Jun 11, 2024
1 parent 35611fc commit 4d92869
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:

- name: Build and test services
run: |
docker-compose -f docker-compose.yml up --build -d
docker compose -f compose.yml up --build -d
- name: Test Xdebug
run: |
sleep 10 # Wait for the containers to fully initialize
sleep 5 # Wait for the containers to fully initialize
XDEBUG_OUTPUT=$(curl -s http://localhost/index.php)
if [[ ! "$XDEBUG_OUTPUT" =~ "Xdebug" ]]; then
echo "Xdebug test failed. Not found in phpinfo() output."
Expand All @@ -42,16 +42,16 @@ jobs:
- name: Install Composer dependencies
run: |
docker-compose exec -T php-fpm composer install
docker compose exec -T php-fpm composer install
- name: Run PHPUnit tests
run: |
docker-compose exec -T php-fpm ./vendor/bin/phpunit tests
docker compose exec -T php-fpm ./vendor/bin/phpunit tests
- name: Test Redis
run: |
sleep 5 # Wait for Redis to fully initialize
REDIS_TEST=$(docker-compose exec -T redis redis-cli ping)
REDIS_TEST=$(docker compose exec -T redis redis-cli ping)
if [[ "$REDIS_TEST" != "PONG" ]]; then
echo "Redis test failed. No PONG response."
exit 1
Expand All @@ -65,8 +65,8 @@ jobs:
MARIADB_PASSWORD: ${{ secrets.MARIADB_PASSWORD }}
MARIADB_DATABASE: ${{ secrets.MARIADB_DATABASE }}
run: |
sleep 10 # Wait for MariaDB to fully initialize
MARIADB_TEST=$(docker-compose exec -T mariadb mariadb -u${MARIADB_USER} -p${MARIADB_PASSWORD} -e "SHOW DATABASES LIKE '${MARIADB_DATABASE}';")
sleep 5 # Wait for MariaDB to fully initialize
MARIADB_TEST=$(docker compose exec -T mariadb mariadb -u${MARIADB_USER} -p${MARIADB_PASSWORD} -e "SHOW DATABASES LIKE '${MARIADB_DATABASE}';")
if [[ "$MARIADB_TEST" != *"${MARIADB_DATABASE}"* ]]; then
echo "MariaDB test failed. Database not found."
exit 1
Expand All @@ -76,4 +76,4 @@ jobs:
- name: Cleanup
run: |
docker-compose -f docker-compose.yml down
docker compose -f compose.yml down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Docker compose PHP 8.3.8, Xdebug 3.4.0, Nginx 1.27.0, Redis 7.2.5 and MariaDB 11.4.2
# Docker compose PHP 8.3.8, Xdebug 3.3.2, Nginx 1.27.0, Redis 7.2.5 and MariaDB 11.4.2

![docker](https://img.shields.io/badge/Docker-compose-brightgreen.svg)
![nginx](https://img.shields.io/badge/nginx-1.27.0-brightgreen.svg)
Expand All @@ -8,7 +8,7 @@
![redis](https://img.shields.io/badge/Redis-7.2.5-brightgreen.svg)
![mariadb](https://img.shields.io/badge/MariaDB-11.4.2-brightgreen.svg)

* Easy setup with [docker-compose](https://docs.docker.com/compose/) and [Dockerfile](https://docs.docker.com/engine/reference/builder/) under usage from [Docker](https://www.docker.com)
* Easy setup with [docker compose](https://docs.docker.com/compose/) and [Dockerfile](https://docs.docker.com/engine/reference/builder/) under usage from [Docker](https://www.docker.com)
* Uses [PHP 8.3.8](https://www.php.net) for better performance, lower CPU and memory usage
* And [composer the dependency manager for PHP](https://getcomposer.org) to start easy your project
* Built on the lightweight [nginx 1.27.0](https://nginx.org) webserver
Expand All @@ -27,17 +27,17 @@

2. **Build and start the Docker containers:**
```sh
docker-compose up --build -d
docker compose up --build -d
```

3. **Install Composer dependencies:**
```sh
docker-compose exec -T php-fpm composer install
docker compose exec -T php-fpm composer install
```

4. **Run PHPUnit tests:**
```sh
docker-compose exec -T php-fpm ./vendor/bin/phpunit tests
docker compose exec -T php-fpm ./vendor/bin/phpunit tests
```

## Example PHPUnit Test
Expand Down
File renamed without changes.

0 comments on commit 4d92869

Please sign in to comment.