ci: add mongodb, redis, and mailhog services to test workflow
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled

This commit is contained in:
idevakk
2026-03-09 23:14:06 +05:30
parent a7d9ff9c3f
commit 371be069db

View File

@@ -16,10 +16,30 @@ jobs:
environment: Testing
services:
mongo:
image: mongo:latest
ports:
- 27017:27017
options: >-
--health-cmd="mongosh --eval 'db.runCommand({ ping: 1 })'"
--health-interval=10s
--health-timeout=5s
--health-retries=3
redis:
image: redis:latest
ports:
- 6379:6379
options: >-
--health-cmd="redis-cli ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
mailhog:
image: mailhog/mailhog
ports:
- 2525:1025
- 1025:1025
- 8025:8025
steps:
@@ -49,7 +69,11 @@ jobs:
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Copy Environment File
run: cp .env.example .env
run: |
cp .env.example .env
sed -i 's/MONGODB_URI=mongodb:\/\/localhost:27017/MONGODB_URI=mongodb:\/\/127.0.0.1:27017/' .env
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/' .env
sed -i 's/MAIL_MAILER=log/MAIL_MAILER=smtp/' .env
- name: Generate Application Key
run: php artisan key:generate
@@ -57,8 +81,17 @@ jobs:
- name: Build Assets
run: npm run build
- name: Wait for Mailhog
run: sleep 5
- name: Wait for services
run: |
until nc -z 127.0.0.1 27017; do echo "Waiting for MongoDB..."; sleep 2; done
until nc -z 127.0.0.1 6379; do echo "Waiting for Redis..."; sleep 2; done
until nc -z 127.0.0.1 1025; do echo "Waiting for MailHog..."; sleep 2; done
- name: Run Tests
run: ./vendor/bin/pest
env:
MAIL_HOST: 127.0.0.1
MAIL_PORT: 1025
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
MONGODB_URI: mongodb://127.0.0.1:27017