From 9c5e763b68be40f9c9a99da481f1538c046a1194 Mon Sep 17 00:00:00 2001 From: Alexandre Morin Date: Thu, 28 Nov 2019 17:25:17 +0100 Subject: [PATCH 1/2] feat (12468) : auto update docker image --- .gitlab-ci.yml | 235 +++++++++++++++------------- codeception.yml | 4 +- codeception.yml.ci | 31 ---- tests/ci/docker_install_database.sh | 19 --- tests/ci/docker_install_php.sh | 13 -- tests/dockerfile/Dockerfile | 0 6 files changed, 132 insertions(+), 170 deletions(-) delete mode 100644 codeception.yml.ci delete mode 100644 tests/ci/docker_install_database.sh delete mode 100644 tests/ci/docker_install_php.sh delete mode 100644 tests/dockerfile/Dockerfile diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab50a905e..62f58794a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,18 +1,21 @@ -services: - - postgres:9.4 +image: docker:19.03.1 +services: + - docker:19.03.1-dind stages: + - build - tests - push variables: - POSTGRES_DB: "maarchRMtest" - POSTGRES_USER: maarch - POSTGRES_PASSWORD: "" npm_config_cache: /builds/cypress-io/cypress-example-docker-gitlab/.npm CYPRESS_CACHE_FOLDER: /builds/cypress-io/cypress-example-docker-gitlab/cache/Cypress +before_script: + - docker info + - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin + cache: key: ${CI_COMMIT_REF_SLUG} paths: @@ -21,119 +24,141 @@ cache: - node_modules - vendor/ -unit-tests:php-7.2: - image: php:7.2-apache - stage: tests - before_script: - - apt-get update > /dev/null - - mkdir -p /usr/share/man/man1 - - mkdir -p /usr/share/man/man7 - - apt-get install cron -yqq > /dev/null - - bash tests/ci/docker_install_php.sh > /dev/null - - bash tests/ci/docker_install_database.sh > /dev/null - - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +build: + stage: build script: - - useradd -m -g www-data maarch - - echo "export APACHE_RUN_USER=maarch" >> /etc/apache2/envvars - - mkdir -p /var/www/html/ - - cp -R /builds/maarch/maarchRM/ /var/www/maarchRM/ - - mv /var/www/maarchRM/ /var/www/laabs/ - - cd /var/www/laabs - - cp data/maarchRM/conf/vhost.conf.default data/maarchRM/conf/vhost.conf - - cp data/maarchRM/conf/configuration.ini.default data/maarchRM/conf/configuration.ini - - cp data/maarchRM/conf/confvars.ini.default data/maarchRM/conf/confvars.ini - - sed -i -e 's!localhost!postgres!' data/maarchRM/conf/confvars.ini - - sed -i -e 's!maarchRM!maarchRMtest!' data/maarchRM/conf/confvars.ini - - mkdir -p /var/www/laabs/data/maarchRM/repository/archives_1 /var/www/laabs/data/maarchRM/repository/archives_2 - - chown -R maarch:www-data /var/www - - chmod -R 777 /var/www - - cd /etc/apache2/sites-available/ - - touch maarchRM.conf - - echo "Include /var/www/laabs/data/maarchRM/conf/vhost.conf" >> maarchRM.conf - - echo "127.0.0.1 maarchrm" >> /etc/hosts - - a2ensite maarchRM.conf - - a2dissite 000-default.conf - - a2enmod rewrite - - a2enmod env - - service apache2 start - - cd /var/www/laabs - - composer install - - sed -i -e 's!pgsql:host=localhost;dbname=maarchRMtest;port=5432!pgsql:host=postgres;dbname=maarchRMtest;port=5432!' /var/www/laabs/codeception.yml - - vendor/bin/codecept run - artifacts: - paths: - - tests/codeception/_output/ - expire_in: 1 week - when: always - -functional-test:cypress: - image: cypress/base:10 - stage: tests - script: - - mv /builds/maarch/maarchRM/cypress.json /builds/maarch/maarchRM/cypress.json.old - - mv /builds/maarch/maarchRM/cypress.json.ci /builds/maarch/maarchRM/cypress.json - - npm install - - npm ci - - $(npm bin)/cypress verify - - $(npm bin)/cypress run - only: - - schedules - artifacts: - expire_in: 1 week - when: always - paths: - - tests/cypress/screenshots - - tests/cypress/videos - -syntax-test:php-metrics: - image: jakzal/phpqa - stage: tests - script: phpmetrics --report-html=var/php-metrics src + - docker build --build-arg APP_VERSION=${CI_COMMIT_REF_NAME} --build-arg CACHE_DATE="$(date)" $CI_DOCKERFILE -t "$CI_REGISTRY_IMAGE_TEST" + - docker push "$CI_REGISTRY_IMAGE_TEST" except: - schedules - only: - - develop - artifacts: - paths: - - var/php-metrics/ - allow_failure: true -syntax-test:php-phpmd: - image: jakzal/phpqa +tests: stage: tests script: - - mkdir var/ - - phpmd src html phpmd.xml --reportfile var/phpmd.html --exclude --ignore-violations-on-exit - except: - - schedules - only: - - develop + - docker pull "$CI_REGISTRY_IMAGE_TEST" + - docker run $CI_REGISTRY_IMAGE_TEST bash -c "echo \"127.0.0.1 maarchrm\" >> /etc/hosts + && service apache2 start + && service postgresql start + && cd /var/www/laabs/ + && composer install + && vendor/bin/codecept run" artifacts: paths: - - var/phpmd.html - allow_failure: true - + - tests/codeception/_output/ + expire_in: 1 week + when: always -syntax-test:php-deprecation-detector: - image: jakzal/phpqa - stage: tests +push: + stage: push script: - - deprecation-detector check src vendor/ + - docker pull "$CI_REGISTRY_IMAGE_TEST" + - docker tag "$CI_REGISTRY_IMAGE_TEST" "$CI_REGISTRY_IMAGE" + - docker push "$CI_REGISTRY_IMAGE" + only: + - feat/autopush_dockerhub except: - schedules - only: - - develop - allow_failure: true - -#build-dockerhub: -# stage: push +#unit-tests:php-7.2: +# image: php:7.2-apache +# stage: tests +# before_script: +# - apt-get update > /dev/null +# - mkdir -p /usr/share/man/man1 +# - mkdir -p /usr/share/man/man7 +# - apt-get install cron -yqq > /dev/null +# - bash tests/ci/docker_install_php.sh > /dev/null +# - bash tests/ci/docker_install_database.sh > /dev/null +# - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +# script: +# - useradd -m -g www-data maarch +# - echo "export APACHE_RUN_USER=maarch" >> /etc/apache2/envvars +# - mkdir -p /var/www/html/ +# - cp -R /builds/maarch/maarchRM/ /var/www/maarchRM/ +# - mv /var/www/maarchRM/ /var/www/laabs/ +# - cd /var/www/laabs +# - cp data/maarchRM/conf/vhost.conf.default data/maarchRM/conf/vhost.conf +# - cp data/maarchRM/conf/configuration.ini.default data/maarchRM/conf/configuration.ini +# - cp data/maarchRM/conf/confvars.ini.default data/maarchRM/conf/confvars.ini +# - sed -i -e 's!localhost!postgres!' data/maarchRM/conf/confvars.ini +# - sed -i -e 's!maarchRM!maarchRMtest!' data/maarchRM/conf/confvars.ini +# - mkdir -p /var/www/laabs/data/maarchRM/repository/archives_1 /var/www/laabs/data/maarchRM/repository/archives_2 +# - chown -R maarch:www-data /var/www +# - chmod -R 777 /var/www +# - cd /etc/apache2/sites-available/ +# - touch maarchRM.conf +# - echo "Include /var/www/laabs/data/maarchRM/conf/vhost.conf" >> maarchRM.conf +# - echo "127.0.0.1 maarchrm" >> /etc/hosts +# - a2ensite maarchRM.conf +# - a2dissite 000-default.conf +# - a2enmod rewrite +# - a2enmod env +# - service apache2 start +# - cd /var/www/laabs +# - composer install +# - sed -i -e 's!pgsql:host=localhost;dbname=maarchRMtest;port=5432!pgsql:host=postgres;dbname=maarchRMtest;port=5432!' /var/www/laabs/codeception.yml +# - vendor/bin/codecept run +# artifacts: +# paths: +# - tests/codeception/_output/ +# expire_in: 1 week +# when: always +# +#functional-test:cypress: +# image: cypress/base:10 +# stage: tests +# script: +# - mv /builds/maarch/maarchRM/cypress.json /builds/maarch/maarchRM/cypress.json.old +# - mv /builds/maarch/maarchRM/cypress.json.ci /builds/maarch/maarchRM/cypress.json +# - npm install +# - npm ci +# - $(npm bin)/cypress verify +# - $(npm bin)/cypress run +# only: +# - schedules +# artifacts: +# expire_in: 1 week +# when: always +# paths: +# - tests/cypress/screenshots +# - tests/cypress/videos +# +#syntax-test:php-metrics: +# image: jakzal/phpqa +# stage: tests +# script: phpmetrics --report-html=var/php-metrics src +# except: +# - schedules +# only: +# - develop +# artifacts: +# paths: +# - var/php-metrics/ +# allow_failure: true +# +#syntax-test:php-phpmd: +# image: jakzal/phpqa +# stage: tests # script: -# - echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin -# - docker build tests/dockerfile/ -t "$CI_REGISTRY_IMAGE" -# - docker tag "$CI_REGISTRY_IMAGE" -# - docker push "$CI_REGISTRY_IMAGE" +# - mkdir var/ +# - phpmd src html phpmd.xml --reportfile var/phpmd.html --exclude --ignore-violations-on-exit +# except: +# - schedules # only: -# - feat/codeception +# - develop +# artifacts: +# paths: +# - var/phpmd.html +# allow_failure: true +# +# +#syntax-test:php-deprecation-detector: +# image: jakzal/phpqa +# stage: tests +# script: +# - deprecation-detector check src vendor/ # except: -# - schedules \ No newline at end of file +# - schedules +# only: +# - develop +# allow_failure: true diff --git a/codeception.yml b/codeception.yml index 404364fa5..9f4accc0c 100644 --- a/codeception.yml +++ b/codeception.yml @@ -22,10 +22,10 @@ settings: modules: enabled: - Db: - dsn: 'pgsql:host=localhost;dbname=maarchRMtest;port=5432' + dsn: 'pgsql:host=localhost;dbname=maarchRM;port=5432' user: 'maarch' password: 'maarch' dump: 'tests/codeception/_data/dump.sql' cleanup: false # run populator before each test populate: true # run populator before all test - populator: 'psql -U $user -h $host -d $dbname < $dump' \ No newline at end of file + populator: 'PGPASSWORD=maarch psql -U $user -h $host -d $dbname < $dump' \ No newline at end of file diff --git a/codeception.yml.ci b/codeception.yml.ci deleted file mode 100644 index c185903cf..000000000 --- a/codeception.yml.ci +++ /dev/null @@ -1,31 +0,0 @@ -# suite config -suites: - api: - actor: ApiTester - path: . - modules: - enabled: - - REST: - url: http://maarchrm - depends: PhpBrowser - -paths: - tests: tests/codeception - output: tests/codeception/_output - data: tests/codeception/_data - support: tests/codeception/_support - -settings: - shuffle: false - lint: true - -modules: - enabled: - - Db: - dsn: 'pgsql:host=postgres;dbname=maarchRMtest;port=5432' - user: 'maarch' - password: 'maarch' - dump: 'tests/codeception/_data/dump.sql' - cleanup: false # run populator before each test - populate: true # run populator before all test - populator: 'psql -U $user -h $host -d $dbname < $dump' \ No newline at end of file diff --git a/tests/ci/docker_install_database.sh b/tests/ci/docker_install_database.sh deleted file mode 100644 index 0ae223a91..000000000 --- a/tests/ci/docker_install_database.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -[[ ! -e /.dockerenv ]] && exit 0 - -set -xe - -apt-get install postgresql-client -yqq - -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/src/bundle/audit/Resources/sql/schema.pgsql.sql -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/src/bundle/auth/Resources/sql/schema.pgsql.sql -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/src/bundle/batchProcessing/Resources/sql/schema.pgsql.sql -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/src/bundle/contact/Resources/sql/schema.pgsql.sql -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/src/bundle/filePlan/Resources/sql/schema.pgsql.sql -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/src/bundle/lifeCycle/Resources/sql/schema.pgsql.sql -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/src/bundle/organization/Resources/sql/schema.pgsql.sql -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/src/bundle/recordsManagement/Resources/sql/schema.pgsql.sql -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/src/bundle/digitalResource/Resources/sql/schema.pgsql.sql - -psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -w < /builds/maarch/maarchRM/data/maarchRM/sql/pgsql/demo.sql diff --git a/tests/ci/docker_install_php.sh b/tests/ci/docker_install_php.sh deleted file mode 100644 index 320cf57fb..000000000 --- a/tests/ci/docker_install_php.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -# We need to install dependencies only for Docker -[[ ! -e /.dockerenv ]] && exit 0 - -set -xe - -apt-get update -yqq -apt-get install git p7zip-full default-jre -yqq - -apt-get install -y libpq-dev libxml2-dev libxslt1-dev libpng-dev \ -&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ -&& docker-php-ext-install pdo_pgsql pgsql xsl zip diff --git a/tests/dockerfile/Dockerfile b/tests/dockerfile/Dockerfile deleted file mode 100644 index e69de29bb..000000000 -- GitLab From 42b8ce065d7afc9048032317bd6845ad1c330b5b Mon Sep 17 00:00:00 2001 From: Alexandre Morin Date: Thu, 28 Nov 2019 17:26:01 +0100 Subject: [PATCH 2/2] feat (12468) : auto update docker image --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 62f58794a..ed4b712dd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -55,7 +55,7 @@ push: - docker tag "$CI_REGISTRY_IMAGE_TEST" "$CI_REGISTRY_IMAGE" - docker push "$CI_REGISTRY_IMAGE" only: - - feat/autopush_dockerhub + - master except: - schedules -- GitLab