date.chapril.org-framadate/.gitlab-ci.yml
Thomas Citharel 9aaf5b3bbd Merge branch 'ci/lint-verbose' into 'develop'
Add diff option to the linter to see errors/fixes

See merge request framasoft/framadate/framadate!394
2019-04-19 16:41:06 +02:00

151 lines
4.3 KiB
YAML

variables:
TESTING_IMAGE: framasoft/framadate-ci:php-7.2
image: ${TESTING_IMAGE}
cache:
key: "${TESTING_IMAGE}:${CI_PROJECT_ID}"
paths:
- vendor/
before_script:
- composer install -o --no-interaction --no-progress --prefer-dist
stages:
- test
- deploy
- beta
- funky
# Run phpunit on all branches
test:
stage: test
script:
- vendor/bin/phpunit --bootstrap app/tests/bootstrap.php --debug app/tests
# Run php-cs-fixer on all branches
lint:
stage: test
script:
- php vendor/bin/php-cs-fixer fix --verbose --dry-run --diff
# Run doctrine migrations with MySQL
.db:migration:mysql:
stage: test
variables:
APP_ENV: "test"
MYSQL_DATABASE: "fd_test"
MYSQL_ROOT_PASSWORD: "coucou"
FRAMADATE_DB_DRIVER: 'pdo_mysql'
FRAMADATE_DB_HOST: "mysql"
FRAMADATE_DB_NAME: "${MYSQL_DATABASE}"
FRAMADATE_DB_USER: "root"
FRAMADATE_DB_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
script:
- docker-php-ext-install "${FRAMADATE_DB_DRIVER}"
- bin/doctrine migrations:status -vvv
- bin/doctrine migrations:migrate --no-interaction -vvv
- bin/doctrine migrations:status -vvv
db:migration:mysql:5.6:
extends: .db:migration:mysql
services:
- 'mysql:5.6'
db:migration:mysql:5.7:
extends: .db:migration:mysql
services:
- 'mysql:5.7'
db:migration:mysql:8:
extends: .db:migration:mysql
services:
- name: 'mysql:8'
command: ['--default-authentication-plugin=mysql_native_password']
# Run doctrine migrations with PostgreSQL
.db:migration:postgresql:
stage: test
variables:
APP_ENV: "test"
POSTGRES_DB: "fd_test"
POSTGRES_USER: "marmotte"
POSTGRES_PASSWORD: "sleeping"
FRAMADATE_DB_DRIVER: 'pdo_pgsql'
FRAMADATE_DB_HOST: "postgres"
FRAMADATE_DB_NAME: "${POSTGRES_DB}"
FRAMADATE_DB_USER: "${POSTGRES_USER}"
FRAMADATE_DB_PASSWORD: "${POSTGRES_PASSWORD}"
script:
- docker-php-ext-install "${FRAMADATE_DB_DRIVER}"
- bin/doctrine migrations:status -vvv
- bin/doctrine migrations:migrate --no-interaction -vvv
- bin/doctrine migrations:status -vvv
db:migration:postgresql:9.6:
extends: .db:migration:postgresql
services:
- 'postgres:9.6'
# Create artifacts on master
pages:
stage: deploy
script:
- latesttag=$(git describe --tags)
- git checkout ${latesttag}
- composer install -o --no-interaction --no-progress --prefer-dist --no-dev
- composer dump-autoload --optimize --no-dev --classmap-authoritative
- mkdir framadate
- mv `ls -A | grep -v framadate` ./framadate
- find framadate/ -type d -exec chmod 750 {} \;
- find framadate/ -type f -exec chmod 640 {} \;
- rm -rf framadate/.git
- zip -r latest.zip framadate
- mkdir .public
- cp latest.zip .public
- mv .public public
artifacts:
paths:
- public
only:
- tags
except:
- (beta|alpha)
# Deploy on develop
beta:
stage: beta
script:
- composer install -o --no-interaction --no-progress --prefer-dist --no-dev
- composer dump-autoload --optimize --no-dev --classmap-authoritative
- mkdir .public
- cp -r * .public
- cp -r .git .public
- mv .public public
- mkdir "${HOME}/.ssh"
- chmod 700 "${HOME}/.ssh"
- if [ ! -z ${DEPLOYEMENT_KNOWN_HOSTS+x} ]; then echo -e "${DEPLOYEMENT_KNOWN_HOSTS}" > ${HOME}/.ssh/known_hosts; fi
- eval `ssh-agent -s`
- if [ ! -z ${BETA_KEY+x} ]; then ssh-add <(echo "${BETA_KEY}" | base64 --decode -i); fi
- if [ ! -z ${BETA_KEY+x} ]; then rsync -a --delete --exclude admin/.stdout.log --exclude admin/.htpasswd --exclude app/inc/config.php --exclude stats/ --exclude error/ public/ ${BETA_USER}@${DEPLOYEMENT_HOST}:../../web/; fi
only:
- develop
# Deploy on funky
funky:
stage: funky
script:
- composer install
- mkdir tpl_c
- mkdir .public
- cp -r * .public
- mv .public public
- mkdir "${HOME}/.ssh"
- chmod 700 "${HOME}/.ssh"
- if [ ! -z ${DEPLOYEMENT_KNOWN_HOSTS+x} ]; then echo -e "${DEPLOYEMENT_KNOWN_HOSTS}" > ${HOME}/.ssh/known_hosts; fi
- eval `ssh-agent -s`
- if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then ssh-add <(echo "${DEPLOYEMENT_KEY}" | base64 --decode -i); fi
- if [ ! -z ${DEPLOYEMENT_KEY+x} ]; then rsync -a --delete --exclude admin/.stdout.log --exclude admin/.htpasswd --exclude app/inc/config.php --exclude stats/ --exclude error/ public/ ${DEPLOYEMENT_USER}@${DEPLOYEMENT_HOST}:../../web/; fi
only:
- funky