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
|
environment: Testing
|
||||||
|
|
||||||
services:
|
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:
|
mailhog:
|
||||||
image: mailhog/mailhog
|
image: mailhog/mailhog
|
||||||
ports:
|
ports:
|
||||||
- 2525:1025
|
- 1025:1025
|
||||||
- 8025:8025
|
- 8025:8025
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -49,7 +69,11 @@ jobs:
|
|||||||
run: composer install --no-interaction --prefer-dist --optimize-autoloader
|
run: composer install --no-interaction --prefer-dist --optimize-autoloader
|
||||||
|
|
||||||
- name: Copy Environment File
|
- 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
|
- name: Generate Application Key
|
||||||
run: php artisan key:generate
|
run: php artisan key:generate
|
||||||
@@ -57,8 +81,17 @@ jobs:
|
|||||||
- name: Build Assets
|
- name: Build Assets
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Wait for Mailhog
|
- name: Wait for services
|
||||||
run: sleep 5
|
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
|
- name: Run Tests
|
||||||
run: ./vendor/bin/pest
|
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