Skip to content

Instantly share code, notes, and snippets.

@roberto-butti
Created May 22, 2021 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roberto-butti/6a09b001936a7d9300da396fed93a186 to your computer and use it in GitHub Desktop.
Save roberto-butti/6a09b001936a7d9300da396fed93a186 to your computer and use it in GitHub Desktop.
Gitlab CI for Laravel
cache:
paths:
- vendor/
variables:
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: mysql_user
MYSQL_PASSWORD: mysql_password
MYSQL_DATABASE: mysql_db
DB_HOST: mysql
.laravelsetup: &stepsetup
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- cp .env.example .env
- php artisan key:generate
- npm ci
- npm run dev
.laraveltest:
only:
refs:
- master
- develop
- /^features\/.*$/
before_script:
- *stepsetup
services:
- name: mysql:8.0
command: ["--default-authentication-plugin=mysql_native_password"]
variables:
DB_CONNECTION: mysql
DB_DATABASE: $MYSQL_DATABASE
DB_USERNAME: $MYSQL_USER
DB_PASSWORD: $MYSQL_PASSWORD
DB_HOST: mysql
artifacts:
reports:
codequality: phpcs-quality-report.json
junit: phpunit-report.xml
script:
- phpunit --log-junit phpunit-report.xml
- composer require --dev squizlabs/php_codesniffer
- composer require --dev micheh/phpcs-gitlab
- vendor/bin/phpcs --report-\\Micheh\\PhpCodeSniffer\\Report\\Gitlab=phpcs-quality-report.json --standard=PSR12 --extensions=php app
- composer require --dev nunomaduro/larastan
- vendor/phpstan/phpstan/phpstan analyse --error-format=junit --level=1 --no-progress app > phpstan-report.xml
phpunit:8.0:
extends: .laraveltest
image: lorisleiva/laravel-docker:8.0
variables:
MYSQL_DATABASE: db_laravel_php80
phpunit:7.4:
extends: .laraveltest
image: lorisleiva/laravel-docker:7.4
variables:
MYSQL_DATABASE: db_laravel_php74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment