Update test.yml #39
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Build containers | |
run: docker-compose -f docker-compose.test.yml build --no-cache | |
- name: Start containers | |
run: | | |
docker-compose -f docker-compose.test.yml up -d | |
echo "Waiting for containers to start..." | |
sleep 300 # Increased sleep time to ensure the containers are up | |
- name: Check container status | |
run: docker-compose -f docker-compose.test.yml ps -a | |
- 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: | | |
docker-compose -f docker-compose.test.yml exec -T db mysql -u root -prootpassword -e "CREATE USER IF NOT EXISTS 'humhubuser'@'%' IDENTIFIED BY 'humhubpassword'; 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 |