From Abkrim, 3 Weeks ago, written in YAML.
Embed
  1. stages:
  2.  - preparation
  3.   - building
  4.   - testing
  5.   - security
  6.  
  7. variables:
  8.   MYSQL_ROOT_PASSWORD: root
  9.   MYSQL_USER: root
  10.   MYSQL_PASSWORD: scret
  11.   MYSQL_DATABASE: laravel
  12.   DB_HOST: mysql
  13.  
  14. cache:
  15.   key: $CI_BUILD_REF_NAM
  16.  
  17. composer:
  18.   stage: preparation
  19.   services:
  20.    - mysql:8.0
  21.   image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
  22.   script:
  23.    - php -v
  24.     - composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
  25.     - cp .env.example .env
  26.     - php artisan key:generate
  27.   artifacts:
  28.     paths:
  29.      - vendor/
  30.       - .env
  31.     expire_in: 5 days
  32.     when: always
  33.   cache:
  34.     paths:
  35.      - vendor/
  36.  
  37. yarn:
  38.   stage: preparation
  39.   image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
  40.   script:
  41.    - yarn --version
  42.     - yarn install --pure-lockfile
  43.   artifacts:
  44.     paths:
  45.      - node_modules/
  46.     expire_in: 1 days
  47.     when: always
  48.   cache:
  49.     paths:
  50.      - node_modules/
  51.  
  52. build-assets:
  53.   stage: building
  54.   image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
  55.   # Download the artifacts for these jobs
  56.   dependencies:
  57.    - composer
  58.     - yarn
  59.   script:
  60.    - yarn --version
  61.     - yarn run production --progress false
  62.   artifacts:
  63.     paths:
  64.      - public/css/
  65.       - public/js/
  66.       - public/fonts/
  67.       - public/mix-manifest.json
  68.     expire_in: 1 days
  69.     when: always
  70.  
  71. db-seeding:
  72.   stage: building
  73.   services:
  74.    - mysql:8.0
  75.   image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
  76.   # Download the artifacts for these jobs
  77.   dependencies:
  78.    - composer
  79.     - yarn
  80.   script:
  81.    - php artisan migrate:fresh --seed
  82.   artifacts:
  83.     paths:
  84.      - ./storage/logs # for debugging
  85.     expire_in: 1 days
  86.     when: on_failure
  87.  
  88. phpunit:
  89.   stage: testing
  90.   services:
  91.    - mysql:8.0
  92.   image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
  93.   # Download the artifacts for these jobs
  94.   dependencies:
  95.    - build-assets
  96.     - composer
  97.     - db-seeding
  98.   script:
  99.    - php -v
  100.     - sudo cp /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.bak
  101.     - echo "" | sudo tee /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
  102.     - ./vendor/phpunit/phpunit/phpunit --version
  103.     - php -d short_open_tag=off ./vendor/phpunit/phpunit/phpunit -v --colors=never --stderr
  104.     - sudo cp /usr/local/etc/php/conf.d/docker-php-ext-xdebug.bak /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
  105.   artifacts:
  106.     paths:
  107.      - ./storage/logs # for debugging
  108.     expire_in: 1 days
  109.     when: on_failure