mirror of
https://github.com/elyby/accounts.git
synced 2024-11-16 18:23:29 +05:30
126 lines
3.7 KiB
YAML
126 lines
3.7 KiB
YAML
stages:
|
|
- test
|
|
- build
|
|
- release
|
|
|
|
variables:
|
|
CONTAINER_IMAGE: "registry.ely.by/elyby/accounts"
|
|
|
|
check backend codestyle:
|
|
image: edbizarro/gitlab-ci-pipeline-php:7.2-alpine
|
|
stage: test
|
|
cache:
|
|
key: backend-vendor
|
|
paths:
|
|
- vendor
|
|
script:
|
|
- composer install
|
|
- vendor/bin/php-cs-fixer fix -v --dry-run
|
|
|
|
test backend:
|
|
image: edbizarro/gitlab-ci-pipeline-php:7.2-alpine
|
|
services:
|
|
- name: redis:4.0.10-alpine
|
|
alias: redis
|
|
- name: mariadb:10.2.11
|
|
alias: db
|
|
variables:
|
|
# App config
|
|
DB_HOST: "db"
|
|
DB_DATABASE: "ely_accounts_test"
|
|
DB_USER: "ely_accounts_tester"
|
|
DB_PASSWORD: "ely_accounts_tester_password"
|
|
REDIS_HOST: "redis"
|
|
REDIS_PORT: "6379"
|
|
# MariaDB config
|
|
MYSQL_RANDOM_ROOT_PASSWORD: "true"
|
|
MYSQL_DATABASE: "ely_accounts_test"
|
|
MYSQL_USER: "ely_accounts_tester"
|
|
MYSQL_PASSWORD: "ely_accounts_tester_password"
|
|
stage: test
|
|
cache:
|
|
key: backend-vendor
|
|
paths:
|
|
- vendor
|
|
before_script:
|
|
# While we not counting coverage, xdebug only slow down tests
|
|
- sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
|
script:
|
|
- composer install
|
|
- php yii rbac/generate
|
|
- ./docker/php/wait-for-it.sh "${DB_HOST}:3306" -s -t 0 -- "php yii migrate/up --interactive=0"
|
|
- vendor/bin/codecept run
|
|
|
|
test frontend:
|
|
image: node:9.2.1-alpine
|
|
stage: test
|
|
cache:
|
|
paths:
|
|
- frontend/node_modules
|
|
before_script:
|
|
# Enable SSL support for wget
|
|
- apk add --update openssl
|
|
# https://github.com/facebook/flow/issues/3649#issuecomment-414691014
|
|
- wget -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
|
|
- wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk
|
|
- apk add glibc-2.28-r0.apk
|
|
script:
|
|
- cd frontend
|
|
- yarn run build:install
|
|
- yarn run lint
|
|
- yarn flow
|
|
- yarn test
|
|
|
|
build:production:
|
|
image: docker:18.02
|
|
stage: build
|
|
variables:
|
|
GA_ID: "UA-45299905-3"
|
|
SENTRY_CDN: "https://088e7718236a4f91937a81fb319a93f6@sentry.ely.by/2"
|
|
before_script:
|
|
- docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by
|
|
- export VERSION="${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA:0:7}}"
|
|
- echo "$SSH_PRIVATE_KEY" > id_rsa
|
|
- |
|
|
echo "
|
|
module.exports = {
|
|
version: '$VERSION',
|
|
ga: {id: '$GA_ID'},
|
|
sentryCdn: '$SENTRY_CDN',
|
|
};
|
|
" > frontend/config/env.js
|
|
- sed -i"" -e "s/{{PLACE_VERSION_HERE}}/$VERSION/g" common/config/config.php
|
|
script:
|
|
- export IMAGE_NAME="$CONTAINER_IMAGE:latest"
|
|
- docker build --pull --build-arg build_env=prod -t $IMAGE_NAME .
|
|
only:
|
|
- develop
|
|
- tags
|
|
|
|
release:latest:
|
|
image: docker:18.02
|
|
stage: release
|
|
variables:
|
|
GIT_STRATEGY: none
|
|
before_script:
|
|
- docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by
|
|
script:
|
|
- docker push $CONTAINER_IMAGE:latest
|
|
only:
|
|
- develop
|
|
- tags
|
|
|
|
release:tag:
|
|
image: docker:18.02
|
|
stage: release
|
|
variables:
|
|
GIT_STRATEGY: none
|
|
before_script:
|
|
- docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by
|
|
script:
|
|
- export IMAGE_NAME="$CONTAINER_IMAGE:$CI_BUILD_TAG"
|
|
- docker tag $CONTAINER_IMAGE:latest $IMAGE_NAME
|
|
- docker push $IMAGE_NAME
|
|
only:
|
|
- tags
|