-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (128 loc) · 5.8 KB
/
test.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Test Dockerfile
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Test on Ubuntu
runs-on: ubuntu-latest
steps:
- name: Check Docker daemon
run: docker info || sudo service docker start
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.7.1
- name: Install Docker Compose
run: |
sudo curl -L "https://github.com/docker/compose/releases/download/v2.30.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
- name: Create test docker-compose file
run: |
cat > docker-compose.test.yml << 'EOF'
services:
humhub:
build: .
ports:
- "80:80"
- "443:443"
environment:
- PHP_MEMORY_LIMIT=512M
- PHP_MAX_EXECUTION_TIME=300
- HUMHUB_DB_HOST=db
- HUMHUB_DB_NAME=humhub_test
- HUMHUB_DB_USER=humhubuser
- HUMHUB_DB_PASSWORD=humhubpassword
- SERVER_NAME=:80
- PHP_INI_MEMORY_LIMIT=512M
- PHP_INI_MAX_EXECUTION_TIME=300
depends_on:
- db
networks:
- humhub_test_network
db:
image: mysql:8
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: humhub_test
MYSQL_USER: humhubuser
MYSQL_PASSWORD: humhubpassword
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "humhubuser", "-phumhubpassword"]
interval: 5s
timeout: 5s
retries: 10
networks:
- humhub_test_network
networks:
humhub_test_network:
driver: bridge
EOF
- name: Build containers
run: docker-compose -f docker-compose.test.yml build --no-cache
- name: Start containers and debug
run: |
docker-compose -f docker-compose.test.yml up -d
echo "Waiting for containers to start..."
sleep 10
echo "Docker compose ps:"
docker-compose -f docker-compose.test.yml ps
echo "Docker compose logs:"
docker-compose -f docker-compose.test.yml logs
echo "Container status:"
docker ps -a
- name: Debug container startup
if: failure()
run: |
echo "Checking humhub container logs..."
docker-compose -f docker-compose.test.yml logs humhub
echo "Checking container filesystem..."
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app || true
echo "Checking Caddyfile..."
docker-compose -f docker-compose.test.yml exec -T humhub cat /etc/caddy/Caddyfile || true
echo "Checking FrankenPHP processes..."
docker-compose -f docker-compose.test.yml exec -T humhub ps aux || true
- name: Verify MySQL is ready
run: |
echo "Waiting for MySQL to be ready..."
timeout 60s bash -c 'until docker-compose -f docker-compose.test.yml exec -T db mysqladmin -u root -prootpassword ping; do sleep 1; done'
- name: Grant MySQL privileges
run: |
RETRIES=5
until docker-compose -f docker-compose.test.yml exec -T db mysql -u root -prootpassword -e "CREATE USER IF NOT EXISTS 'humhubuser'@'%' IDENTIFIED BY 'humhubpassword';" || [ $RETRIES -eq 0 ]; do
echo "Retrying MySQL user creation..."
((RETRIES--))
sleep 5
done
docker-compose -f docker-compose.test.yml exec -T db mysql -u root -prootpassword -e "GRANT ALL PRIVILEGES ON humhub_test.* TO 'humhubuser'@'%'; FLUSH PRIVILEGES;"
- name: Verify PHP and FrankenPHP
run: |
docker-compose -f docker-compose.test.yml exec -T humhub php -v || echo "::error::PHP verification failed"
docker-compose -f docker-compose.test.yml exec -T humhub frankenphp version || echo "::error::FrankenPHP verification failed"
- name: Verify PHP extensions
run: |
docker-compose -f docker-compose.test.yml exec -T humhub php -m || echo "::error::Unable to list PHP extensions"
- name: Verify HumHub files
run: |
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app || echo "::error::HumHub files verification failed"
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app/protected/config || echo "::error::Config directory not found"
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app/protected/modules || echo "::error::Modules directory not found"
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /app/protected || echo "::error::Protected directory not found"
- name: Verify cron setup
run: |
docker-compose -f docker-compose.test.yml exec -T humhub ps aux | grep cron || echo "::error::Cron service is not running"
docker-compose -f docker-compose.test.yml exec -T humhub cat /etc/cron.d/humhub || echo "::error::Crontab is missing or not configured correctly"
docker-compose -f docker-compose.test.yml exec -T humhub ls -la /usr/local/bin/humhub-cron.sh || echo "::error::Cron script not found"
- name: Show container logs
if: always()
run: docker-compose -f docker-compose.test.yml logs
- name: Cleanup
if: always()
run: |
docker-compose -f docker-compose.test.yml down -v
docker-compose -f docker-compose.test.yml rm -f -v