Created
October 17, 2017 00:09
-
-
Save ionixjunior/978463f649b7ccada1af046a0826218a to your computer and use it in GitHub Desktop.
Exemplo de configuração do Gitlab CI. Ferramentas utilizadas: PHPMD, PHPCPD, PHPCS, PHPUnit e ApiDOC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: php:5.6 | |
cache: | |
paths: | |
- vendor/ | |
stages: | |
- qa | |
- test | |
- doc | |
- deploy | |
phpmd: | |
stage: qa | |
script: | |
- apt-get update -yqq | |
- apt-get install -yqq git | |
- php composer.phar install --dev --no-plugins --no-scripts | |
- vendor/bin/phpmd src/ text tools/phpmd_ruleset.xml | |
phpcpd: | |
stage: qa | |
script: | |
- apt-get update -yqq | |
- apt-get install -yqq git | |
- php composer.phar install --dev --no-plugins --no-scripts | |
- vendor/bin/phpcpd --min-tokens=30 src/ | |
phpcs: | |
stage: qa | |
script: | |
- apt-get update -yqq | |
- apt-get install -yqq git | |
- php composer.phar install --dev --no-plugins --no-scripts | |
- vendor/bin/phpcs --encoding=UTF-8 --report=full --report-width=75 --tab-width=4 -p --standard=tools/phpcs_ruleset.xml src/ | |
phpunit: | |
stage: test | |
script: | |
- apt-get update -yqq | |
- apt-get install -yqq libsqlite3-dev git | |
- pecl install xdebug | |
- docker-php-ext-enable xdebug | |
- docker-php-ext-install pdo_sqlite | |
- php composer.phar install --no-plugins --no-scripts | |
- vendor/bin/phpunit --coverage-text --colors=always -c tools/phpunit.xml.dist | |
documentacao: | |
stage: doc | |
script: | |
- curl -sL https://deb.nodesource.com/setup_6.x | bash - | |
- apt-get install -y nodejs | |
- npm install | |
- nodejs node_modules/apidoc/bin/apidoc -i src/ -o build/documentacao | |
artifacts: | |
paths: | |
- build/ | |
homologacao: | |
stage: deploy | |
artifacts: | |
paths: | |
- build/projeto/ | |
environment: | |
name: homologacao | |
url: $HOMOLOGACAO_HOST | |
allow_failure: false | |
only: | |
- dev | |
script: | |
- apt-get update -yqq | |
- apt-get install -yqq zip | |
- mkdir -p build/projeto | |
- zip -r build/projeto/projeto.zip * | |
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' | |
- eval $(ssh-agent -s) | |
- ssh-add <(echo "$HOMOLOGACAO_PRIVATE_KEY" | base64 --decode) | |
- mkdir -p ~/.ssh | |
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' | |
- scp -r build/projeto/projeto.zip $HOMOLOGACAO_USER@$HOMOLOGACAO_HOST:/home/ubuntu | |
- ssh $HOMOLOGACAO_USER@$HOMOLOGACAO_HOST "unzip /home/ubuntu/projeto.zip -d /home/ubuntu/projeto" | |
- ssh $HOMOLOGACAO_USER@$HOMOLOGACAO_HOST "cd /home/ubuntu/projeto && php composer.phar install --no-dev" | |
- # Outros comandos necessários.. migrations, configurações, exclusão de cache... | |
producao: | |
stage: deploy | |
artifacts: | |
paths: | |
- build/projeto/ | |
environment: | |
name: producao | |
url: $PRODUCAO_HOST | |
when: manual | |
allow_failure: false | |
only: | |
- master | |
script: | |
- apt-get update -yqq | |
- apt-get install -yqq zip | |
- mkdir -p build/projeto | |
- zip -r build/projeto/projeto.zip * | |
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' | |
- eval $(ssh-agent -s) | |
- ssh-add <(echo "$PRODUCAO_PRIVATE_KEY" | base64 --decode) | |
- mkdir -p ~/.ssh | |
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' | |
- scp -r build/projeto/projeto.zip $PRODUCAO_USER@$PRODUCAO_HOST:/home/ubuntu | |
- ssh $PRODUCAO_USER@$PRODUCAO_HOST "unzip /home/ubuntu/projeto.zip -d /home/ubuntu/projeto" | |
- ssh $PRODUCAO_USER@$PRODUCAO_HOST "cd /home/ubuntu/projeto && php composer.phar install --no-dev" | |
- # Outros comandos necessários.. migrations, configurações, exclusão de cache... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment