From 28557aba1ecbf03de6172b9b9a262935b20b76f2 Mon Sep 17 00:00:00 2001 From: xcolacique Date: Fri, 14 Aug 2026 16:22:43 -0300 Subject: [PATCH] Ajustando dusk e docker images --- .github/workflows/dusk.yml | 78 +++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 43 deletions(-) diff --git a/.github/workflows/dusk.yml b/.github/workflows/dusk.yml index dd31f1d..bdc1b48 100644 --- a/.github/workflows/dusk.yml +++ b/.github/workflows/dusk.yml @@ -8,66 +8,58 @@ jobs: dusk: runs-on: ubuntu-latest - services: - mariadb: - image: mariadb:10.11 - env: - MARIADB_DATABASE: salas_dusk - MARIADB_ROOT_PASSWORD: admin - MARIADB_USER: admin - MARIADB_PASSWORD: admin - MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes - ports: - - 3306:3306 - options: >- - --health-cmd="mysqladmin ping --silent" - --health-interval=5s - --health-timeout=5s - --health-retries=10 + env: + SERVICE_NAME: salas steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.3 - extensions: mbstring, dom, pdo, mysql - coverage: none + - name: Create .env + run: cp .env.example .env - - name: Install Composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Remove Dusk visual variables - usadas no modo assistido + - name: Add auth.local to hosts to senhaunica-faker works properly run: | - sed -i '/DUSK_START_MAXIMIZED/d' .env.testing.example || true - sed -i '/DUSK_HEADLESS_DISABLED/d' .env.testing.example || true + echo "127.0.0.1 auth.local" | sudo tee -a /etc/hosts - - name: Copy testing env - run: cp .env.testing.example .env + - name: Set UID/GID + run: | + echo "UID=$(id -u)" >> $GITHUB_ENV + echo "GID=$(id -g)" >> $GITHUB_ENV - - name: Generate APP_KEY - run: php artisan key:generate + - name: Build and start containers + run: docker compose up -d --build - name: Wait for MariaDB run: | - for i in {1..30}; do - mysqladmin ping -h127.0.0.1 -P3306 --silent && break + for i in {1..40}; do + if docker compose exec -T mariadb mariadb -u${{ env.SERVICE_NAME }} -p${{ env.SERVICE_NAME }} -e "SELECT 1;" &> /dev/null; then + echo "MariaDB is ready" + exit 0 + fi + echo "Waiting for MariaDB..." sleep 2 done - - name: Run migrations - run: php artisan migrate --force + - name: Install Composer dependencies + run: docker compose exec -T ${{ env.SERVICE_NAME }} composer install --no-interaction --prefer-dist - - name: Install Chrome - uses: browser-actions/setup-chrome@v1 + - name: Generate APP_KEY + run: docker compose exec -T ${{ env.SERVICE_NAME }} php artisan key:generate - - name: Install ChromeDriver - run: php artisan dusk:chrome-driver --detect + - name: Run migrations + run: docker compose exec -T ${{ env.SERVICE_NAME }} php artisan migrate --force - - name: Start Laravel server - run: php artisan serve --port=47800 & + - name: Install ChromeDriver + run: docker compose exec -T ${{ env.SERVICE_NAME }} php artisan dusk:chrome-driver --detect - name: Run Dusk - run: php artisan dusk --without-tty \ No newline at end of file + run: docker compose exec -T ${{ env.SERVICE_NAME }} php artisan dusk --without-tty + + - name: Show logs on failure + if: failure() + run: docker compose logs + + - name: Stop containers + if: always() + run: docker compose down -v