Skip to content

Instantly share code, notes, and snippets.

@exileed
Created September 25, 2020 14:24
Show Gist options
  • Save exileed/5e4931b9bf9387ba14d337eb8ba413c3 to your computer and use it in GitHub Desktop.
Save exileed/5e4931b9bf9387ba14d337eb8ba413c3 to your computer and use it in GitHub Desktop.
image: exileed/php-testing:7.4
variables:
MYSQL_DATABASE: notification
MYSQL_ROOT_PASSWORD: secret
DB_HOST: mysql
DB_USERNAME: root
DB_PASSWORD: $MYSQL_ROOT_PASSWORD
DB_DATABASE: $MYSQL_DATABASE
COVERAGE_PERCENTAGE: '45'
CI_PHP_IMAGE: "$CI_REGISTRY_IMAGE/php:$CI_COMMIT_REF_NAME"
CI_PHP_IMAGE_WITH_TAG: "$CI_REGISTRY_IMAGE/php:$CI_COMMIT_REF_NAME-${CI_COMMIT_SHORT_SHA}"
CI_NGINX_IMAGE: "$CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_NAME"
CI_NGINX_IMAGE_WITH_TAG: "$CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_NAME-${CI_COMMIT_SHORT_SHA}"
CI_WORKER_IMAGE: "$CI_REGISTRY_IMAGE/worker:$CI_COMMIT_REF_NAME"
CI_WORKER_IMAGE_WITH_TAG: "$CI_REGISTRY_IMAGE/worker:$CI_COMMIT_REF_NAME-${CI_COMMIT_SHORT_SHA}"
DOCKER_API_VERSION: "1.39" #https://gitlab.com/gitlab-org/gitlab-runner/-/issues/25803 #todo temp fix
before_script:
- mkdir -p ~/.ssh
- echo "$PACKAGE_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- eval "$(ssh-agent -s)"
- ssh-add ~/.ssh/id_rsa
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
stages:
- prepare
- code-analyze
- test
- after-test
- build-docker-php
- build-docker
- deploy
cache:
paths:
- vendor/
composer:
stage: prepare
cache:
key: ${CI_COMMIT_REF_SLUG}-composer
paths:
- vendor/
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
artifacts:
expire_in: 3 days
paths:
- vendor/
- .env
only:
- merge_requests
- develop
- master
- demo
codestyle:
stage: code-analyze
dependencies:
- composer
script:
- composer phpcs
only:
- merge_requests
- develop
- master
- demo
phpstan:
stage: code-analyze
dependencies:
- composer
script:
- composer phpstan
only:
- merge_requests
- develop
- master
- demo
psalm:
stage: code-analyze
dependencies:
- composer
script:
- composer psalm
only:
- merge_requests
- develop
- master
- demo
phpunit:
stage: test
services:
- mysql:5.7
dependencies:
- composer
artifacts:
expire_in: 1 days
paths:
- clover.xml
script:
- php artisan migrate:refresh --force
- vendor/bin/phpunit --coverage-text --colors=never
only:
- merge_requests
- develop
- master
- demo
Coverage:
stage: after-test
dependencies:
- composer
- phpunit
script:
- vendor/bin/coverage-check clover.xml $COVERAGE_PERCENTAGE --only-percentage
only:
- merge_requests
- develop
- master
- demo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment