# Gitlab CI ## Tests & co Maintenant qu'on a des process de vérification, on peut les faire tourner "tout le temps". [Slides](./resources/ci-slides.pdf) Exemple de GitlabCI ``` image: edbizarro/gitlab-ci-pipeline-php:7.4-alpine services: - mysql:5.7 before_script: - composer install -n --prefer-dist variables: # For MySQL service MYSQL_DATABASE: "gitlab_test" MYSQL_ROOT_PASSWORD: "test" # For CakePHP App DATABASE_HOST: "mysql" DATABASE_DB: "gitlab_test" DATABASE_TEST_DB: "gitlab_test" DATABASE_USER: "root" DATABASE_PASSWORD: "test" MAIL_FROM: "gitlabci@cef.fr" cache: paths: - ./vendor/ job:runtests: stage: test script: - composer run test -- --log-junit junit.xml artifacts: reports: junit: junit.xml job:codesniffer: stage: test script: - composer run cs-check -- --report=junit --report-file=codesniffer.xml artifacts: reports: junit: codesniffer.xml ``` ## Déploiement [Joel Test](https://www.joelonsoftware.com/2000/08/09/the-joel-test-12-steps-to-better-code/) - Question #2 Exemple de GitlabCI vers Dokku ``` job:deploy: stage: deploy image: ilyasemenov/gitlab-ci-git-push services: [] before_script: [] environment: name: staging url: https://$DOKKU_APP_NAME.tests.iteracode.com script: - git-push dokku@tests.iteracode.com:$DOKKU_APP_NAME only: - dev ``` ### Build Docker image on Gitlab CI [Doc officielle](https://docs.gitlab.com/ee/ci/docker/using_docker_build.html) [Build + Deploy](https://gist.github.com/t3easy/3ef49a8848338a9cd457f95034a6a16e)