ci: add mongodb, redis, and mailhog services to test workflow
This commit is contained in:
41
.github/workflows/tests.yml
vendored
41
.github/workflows/tests.yml
vendored
@@ -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
|
||||
Reference in New Issue
Block a user