108 lines
2.9 KiB
YAML
108 lines
2.9 KiB
YAML
# GitLab CI for Laravel
|
|
# GitLab reads this file automatically when it is committed at the repository root as `.gitlab-ci.yml`.
|
|
|
|
workflow:
|
|
rules:
|
|
- if: '$CI_COMMIT_MESSAGE =~ /(\[ci skip\]|\[skip ci\])/i'
|
|
when: never
|
|
- if: '$CI_PIPELINE_SOURCE == "push"'
|
|
when: always
|
|
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
when: always
|
|
- if: '$CI_COMMIT_TAG'
|
|
when: always
|
|
- when: never
|
|
|
|
stages:
|
|
- test
|
|
|
|
variables:
|
|
APP_ENV: testing
|
|
APP_DEBUG: "false"
|
|
LOG_CHANNEL: stderr
|
|
DB_CONNECTION: mysql
|
|
DB_HOST: mysql
|
|
DB_PORT: "3306"
|
|
DB_DATABASE: school_api_test
|
|
DB_USERNAME: school_api
|
|
DB_PASSWORD: school_api
|
|
MYSQL_DATABASE: school_api_test
|
|
MYSQL_USER: school_api
|
|
MYSQL_PASSWORD: school_api
|
|
MYSQL_ROOT_PASSWORD: root
|
|
CACHE_DRIVER: array
|
|
CACHE_STORE: array
|
|
SESSION_DRIVER: array
|
|
QUEUE_CONNECTION: sync
|
|
MAIL_MAILER: array
|
|
BROADCAST_CONNECTION: log
|
|
FILESYSTEM_DISK: local
|
|
COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/.composer-cache"
|
|
XDEBUG_MODE: coverage
|
|
|
|
cache:
|
|
key:
|
|
files:
|
|
- composer.lock
|
|
paths:
|
|
- .composer-cache/
|
|
- vendor/
|
|
|
|
phpunit:
|
|
image: php:8.3-cli
|
|
stage: test
|
|
services:
|
|
- name: mysql:8.4
|
|
alias: mysql
|
|
before_script:
|
|
- apt-get update
|
|
- apt-get install -y --no-install-recommends git unzip curl default-mysql-client libzip-dev libpng-dev libonig-dev libxml2-dev libcurl4-openssl-dev
|
|
- docker-php-ext-install curl dom gd mbstring pdo pdo_mysql xml xmlwriter zip
|
|
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
|
- php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
|
- rm composer-setup.php
|
|
- composer install --prefer-dist --no-interaction --no-progress
|
|
- |
|
|
cat > .env <<EOF
|
|
APP_NAME=school_api
|
|
APP_ENV=testing
|
|
APP_KEY=
|
|
APP_DEBUG=false
|
|
APP_URL=http://localhost
|
|
LOG_CHANNEL=stderr
|
|
LOG_LEVEL=debug
|
|
DB_CONNECTION=mysql
|
|
DB_HOST=mysql
|
|
DB_PORT=3306
|
|
DB_DATABASE=school_api_test
|
|
DB_USERNAME=school_api
|
|
DB_PASSWORD=school_api
|
|
CACHE_DRIVER=array
|
|
CACHE_STORE=array
|
|
SESSION_DRIVER=array
|
|
QUEUE_CONNECTION=sync
|
|
MAIL_MAILER=array
|
|
BROADCAST_CONNECTION=log
|
|
FILESYSTEM_DISK=local
|
|
JWT_SECRET=ci_dummy_secret_not_for_production
|
|
EOF
|
|
- mkdir -p database storage/framework/cache storage/framework/sessions storage/framework/views storage/logs bootstrap/cache reports
|
|
- |
|
|
until mysqladmin ping -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USERNAME" -p"$DB_PASSWORD" --silent; do
|
|
echo "Waiting for MySQL..."
|
|
sleep 2
|
|
done
|
|
- php artisan key:generate --force
|
|
- php artisan config:clear
|
|
- php artisan migrate --force
|
|
script:
|
|
- php artisan test --no-interaction --log-junit reports/phpunit.xml
|
|
artifacts:
|
|
when: always
|
|
expire_in: 7 days
|
|
reports:
|
|
junit: reports/phpunit.xml
|
|
paths:
|
|
- reports/
|
|
- storage/logs/
|