-
Notifications
You must be signed in to change notification settings - Fork 20
79 lines (67 loc) · 2.72 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Docker Compose Test
on:
push:
branches:
- master
pull_request:
branches:
- "*"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and test services
run: |
docker compose -f compose.yml up --build -d
- name: Test Xdebug
run: |
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."
exit 1
else
echo "Xdebug test successful."
fi
- name: Install Composer dependencies
run: |
docker compose exec -T php-fpm composer install
- name: Run PHPUnit tests
run: |
docker compose exec -T php-fpm ./vendor/bin/phpunit --coverage-text --testdox tests
- name: Test Redis
run: |
sleep 5 # Wait for Redis to fully initialize
REDIS_TEST=$(docker compose exec -T redis redis-cli ping)
if [[ "$REDIS_TEST" != "PONG" ]]; then
echo "Redis test failed. No PONG response."
exit 1
else
echo "Redis test successful."
fi
- name: Test MariaDB
env:
MARIADB_USER: ${{ secrets.MARIADB_USER }}
MARIADB_PASSWORD: ${{ secrets.MARIADB_PASSWORD }}
MARIADB_DATABASE: ${{ secrets.MARIADB_DATABASE }}
run: |
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
else
echo "MariaDB test successful."
fi
- name: Cleanup
run: |
docker compose -f compose.yml down