Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 35 additions & 43 deletions .github/workflows/dusk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Loading