Skip to content

Instantly share code, notes, and snippets.

@Konafets
Last active October 5, 2019 19:08
Show Gist options
  • Save Konafets/cb8c540c6b763a93413ef6a907061ac4 to your computer and use it in GitHub Desktop.
Save Konafets/cb8c540c6b763a93413ef6a907061ac4 to your computer and use it in GitHub Desktop.
Sylius GitLab CI
stages:
- test
variables:
MYSQL_DATABASE: sylius_test_cached
MYSQL_ROOT_PASSWORD: root
MYSQL_USER: root
# This is normally provided by the .env file. But since we have to use "mysql" as host name, its defined
# here. We not using any .env file!
# The pattern is: mysql://user:password@host/database
DATABASE_URL: mysql://$MYSQL_USER:$MYSQL_ROOT_PASSWORD@mysql/$MYSQL_DATABASE
# Set memory limit to infinite to avoid running out of memory issues
COMPOSER_MEMORY_LIMIT: -1
# Set the environments variables manually
APP_ENV: test_cached
APP_DEBUG: 1
APP_SECRET: 1542752314
MAILER_URL: smtp://localhost
PHP_DATE_TIMEZONE: Europe/Copenhagen
cache:
key: $CI_COMMIT_REF_NAME
paths:
- vendor
- node_modules
- public
- .yarn
test:
stage: test
allow_failure: false # Its there for easy switching
services:
- mysql:5.7
- memcached
# This image was made for Laravel but works for Sylius as well
# https://github.com/edbizarro/gitlab-ci-pipeline-php
image: edbizarro/gitlab-ci-pipeline-php:7.2-alpine
before_script:
- sudo yarn config set cache-folder .yarn
- mkdir -p public/media/cache && mkdir -p public/media/image # Avoiding error: public/media/image folder not found
script:
# Install the dependencies. Don't execute scripts because the cache clean up take too long, sometimes times out
- composer install --prefer-dist --no-ansi --no-scripts --no-interaction --no-progress --no-suggest
- bin/console doctrine:database:create --if-not-exists --env=test_cached -vvv # Have to run with debug = true, to omit generation proxies before setting up the database
- yarn install
- bin/console sylius:theme:assets:install public
- bin/console sylius:install:assets
- yarn build
- bin/console cache:warmup --env=test_cached --no-debug -vvv
- bin/console doctrine:migrations:migrate --no-interaction --env=test_cached --no-debug -vvv
# Running checks
- vendor/bin/phpcs -n --standard=PSR2 src
- vendor/bin/security-checker security:chec
- vendor/bin/phpspec run --no-interaction -f dot
# Set up a frontend with fixture data
- bin/console sylius:fixtures:load --no-interaction --env=test_cached --no-debug -vvv
- bin/console server:run 127.0.0.1:8080 -d web --env test_cached > /dev/null 2>&1 &
# Running tests
- echo "Starting BEHAT tests."
- cp behat.yml.dist behat.yml
- php bin/behat
- echo "BEHAT tests done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment