From 5e592d54b5b947e283de48c350bce3b4bd1a323c Mon Sep 17 00:00:00 2001 From: Thibault Debatty <thibault.debatty@gmail.com> Date: Mon, 19 Oct 2020 10:46:08 +0200 Subject: [PATCH] add gitlab-ci with phpunit, phpcs and docker build and push --- .gitlab-ci.yml | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..5091aea --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,64 @@ +stages: + - test + - build + +## Cache composer packages between all jobs and all branches +## of this project... +cache: + key: one-key-to-rull-them-all + paths: + - composer-cache/ + +before_script: + - cp env.gitlab-ci .env + - touch storage/app/db.sqlite + - COMPOSER_CACHE_DIR=composer-cache composer install + - php artisan key:generate + - php artisan migrate + +# Test with PHP7.4 +test:php74: + image: cylab/php74 + stage: test + script: + - vendor/bin/phpunit --coverage-text --colors=never --coverage-html build/coverage + - vendor/bin/phpcs + artifacts: + paths: + - build/ + expire_in: 1 month + +build: + image: docker:19.03.1 + stage: build + tags: + - dind + services: + - docker:19.03.1-dind + variables: + DOCKER_TLS_CERTDIR: "/certs" + before_script: + - docker info + script: + - docker build -t cylab/ctf . + + +build:tagged: + only: + - tags + image: docker:19.03.1 + stage: build + tags: + - dind + services: + - docker:19.03.1-dind + variables: + DOCKER_TLS_CERTDIR: "/certs" + before_script: + - docker info + script: + - docker build -t cylab/ctf:$CI_COMMIT_TAG . + - docker tag cylab/ctf:$CI_COMMIT_TAG cylab/ctf:latest + - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + - docker push cylab/ctf:$CI_COMMIT_TAG + - docker push cylab/ctf:latest -- GitLab