Commit 250fb79a authored by Alexandre Morin's avatar Alexandre Morin
Browse files

Functional tests of digital safe

parent e3243821
......@@ -15,5 +15,12 @@ data/maarchRM/conf/confvars.ini
vendor/*
node_modules
cypress/videos
cypress/screenshots
tests/cypress/videos/*
!tests/cypress/videos/.gitignore
tests/cypress/screenshots/*
!tests/cypress/screenshots/.gitignore
composer.lock
package-lock.json
\ No newline at end of file
services:
- postgres:9.4
stages:
- tests
- push
variables:
POSTGRES_DB: "maarchRM"
POSTGRES_DB: "maarchRMtest"
POSTGRES_USER: maarch
POSTGRES_PASSWORD: ""
npm_config_cache: /builds/cypress-io/cypress-example-docker-gitlab/.npm
......@@ -18,158 +19,55 @@ cache:
- .npm
- cache/Cypress
- node_modules
- vendor/
#unit-tests:php-7.3:
# image: php:7.3-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
# - apt-get install libreoffice -yqq > /dev/null
# - bash ci/docker_install_php.sh > /dev/null
# - bash ci/docker_install_database.sh > /dev/null
# script:
# - useradd -m -g www-data maarch
# - export APACHE_RUN_USER=maarch
# - 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
# - 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 775 /var/www
# - cd /etc/apache2/sites-available/
# - touch maarchRM.conf
# - echo "Include /var/www/laabs/data/maarchRM/conf/vhost.conf" >> maarchRM.conf
# - a2ensite maarchRM.conf
# - a2dissite 000-default.conf
# - a2enmod rewrite
# - a2enmod env
# - service apache2 start
# - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
# - chmod +x /usr/local/bin/phpunit
# - phpunit --coverage-text --colors=never -c /var/www/laabs/phpunit.xml
# except:
# - master
#
#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
# - apt-get install libreoffice -yqq > /dev/null
# - bash ci/docker_install_php.sh > /dev/null
# - bash ci/docker_install_database.sh > /dev/null
# script:
# - useradd -m -g www-data maarch
# - export APACHE_RUN_USER=maarch
# - 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
# - 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 775 /var/www
# - cd /etc/apache2/sites-available/
# - touch maarchRM.conf
# - echo "Include /var/www/laabs/data/maarchRM/conf/vhost.conf" >> maarchRM.conf
# - a2ensite maarchRM.conf
# - a2dissite 000-default.conf
# - a2enmod rewrite
# - a2enmod env
# - service apache2 start
# - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
# - chmod +x /usr/local/bin/phpunit
# - phpunit --coverage-text --colors=never -c /var/www/laabs/phpunit.xml
# only:
# - develop
#
#unit-tests:php-7.1:
# image: php:7.1-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
# - apt-get install libreoffice -yqq > /dev/null
# - bash ci/docker_install_php.sh > /dev/null
# - bash ci/docker_install_database.sh > /dev/null
# script:
# - useradd -m -g www-data maarch
# - export APACHE_RUN_USER=maarch
# - 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
# - 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 775 /var/www
# - cd /etc/apache2/sites-available/
# - touch maarchRM.conf
# - echo "Include /var/www/laabs/data/maarchRM/conf/vhost.conf" >> maarchRM.conf
# - a2ensite maarchRM.conf
# - a2dissite 000-default.conf
# - a2enmod rewrite
# - a2enmod env
# - service apache2 start
# - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
# - chmod +x /usr/local/bin/phpunit
# - phpunit --coverage-text --colors=never -c /var/www/laabs/phpunit.xml
# only:
# - develop
#
#unit-tests:php-7.0:
# image: php:7.0-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
# - apt-get install libreoffice -yqq > /dev/null
# - bash ci/docker_install_php.sh > /dev/null
# - bash ci/docker_install_database.sh > /dev/null
# script:
# - useradd -m -g www-data maarch
# - export APACHE_RUN_USER=maarch
# - 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
# - 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 775 /var/www
# - cd /etc/apache2/sites-available/
# - touch maarchRM.conf
# - echo "Include /var/www/laabs/data/maarchRM/conf/vhost.conf" >> maarchRM.conf
# - a2ensite maarchRM.conf
# - a2dissite 000-default.conf
# - a2enmod rewrite
# - a2enmod env
# - service apache2 start
# - curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
# - chmod +x /usr/local/bin/phpunit
# - phpunit --coverage-text --colors=never -c /var/www/laabs/phpunit.xml
# only:
# - develop
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
only:
- develop
- master
artifacts:
paths:
- tests/codeception/_output/
expire_in: 1 week
when: always
functional-test:cypress:
image: cypress/base:10
......@@ -177,18 +75,20 @@ functional-test:cypress:
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
- develop
- master
artifacts:
expire_in: 1 week
when: always
paths:
- cypress/screenshots
- cypress/videos
- tests/cypress/screenshots
- tests/cypress/videos
syntax-test:php-metrics:
image: jakzal/phpqa
......@@ -234,11 +134,11 @@ syntax-test:php-deprecation-detector:
#build-dockerhub:
# stage: push
# script:
# - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
# - docker build dockerfile/version/ -t "$CI_REGISTRY_IMAGE"
# - 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"
# only:
# - feat/gitlab_ci
# - feat/codeception
# except:
# - schedules
\ No newline at end of file
services:
- postgres:9.4
variables:
POSTGRES_DB: "maarchRM"
POSTGRES_USER: maarch
POSTGRES_PASSWORD: ""
npm_config_cache: /builds/cypress-io/cypress-example-docker-gitlab/.npm
CYPRESS_CACHE_FOLDER: ~/.cache/Cypress
stages:
- build
- test
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .npm
- cache/Cypress
- node_modules
job_build_php-7.3:
image: php:7.3-apache
stage: build
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
- apt-get install libreoffice -yqq > /dev/null
- bash ci/docker_install_php.sh > /dev/null
- bash ci/docker_install_database.sh > /dev/null
script:
- useradd -m -g www-data maarch
- export APACHE_RUN_USER=maarch
- 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
- 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 775 /var/www
- cd /etc/apache2/sites-available/
- touch maarchRM.conf
- echo "Include /var/www/laabs/data/maarchRM/conf/vhost.conf" >> maarchRM.conf
- a2ensite maarchRM.conf
- a2dissite 000-default.conf
- a2enmod rewrite
- a2enmod env
- service apache2 start
- curl --location -s --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit-7.phar
- chmod +x /usr/local/bin/phpunit
except:
- master
functional-test:cypress-e2e:
image: cypress/base:10
stage: test
script:
- $(npm bin)/cypress install
- $(npm bin)/cypress verify
- $(npm bin)/cypress run
artifacts:
expire_in: 1 week
when: always
paths:
- cypress/screenshots
- cypress/videos
<?xml version="1.0" encoding="UTF-8"?>
<project name="Laabs Framework [trunk]" default="build">
<property name="workspace" value="${basedir}" />
<property name="sourcedir" value="${basedir}/core" />
<property name="builddir" value="${workspace}/build" />
<!-- CLEAN -->
<target name="clean" description="Cleanup build artifacts">
<delete dir="${builddir}/logs"/>
<delete dir="${builddir}/pdepend"/>
<delete dir="${builddir}/docs/*"/>
<delete dir="${builddir}/code-browser"/>
<delete dir="${builddir}/coverage"/>
</target>
<!-- BUILD -->
<target name="build" depends="prepare,lint,phploc,pdepend,phpcpd,phpmd,phpcs,phpdoc,phpunit,phpcb"/>
<!-- BUILD-PARALLEL -->
<!-- target name="build-parallel" depends="prepare,lint,tools-parallel,phpunit,phpcb"/ -->
<!-- TOOLS-PARALLEL -->
<!-- target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend"/>
<antcall target="phpmd"/>
</sequential>
<antcall target="phploc"/>
<antcall target="phpcpd"/>
<antcall target="phpcs"/>
<antcall target="phpdoc"/>
</parallel>
</target -->
<!-- PREPARE -->
<target name="prepare" depends="clean" description="Prepare for build">
<exec executable="svn">
<arg value="up" />
<arg path="${workspace}" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_authentication/trunk" />
<arg path="${workspace}/dependency/authentication" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_authorization/trunk" />
<arg path="${workspace}/dependency/authorization" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_datasource/trunk" />
<arg path="${workspace}/dependency/datasource" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_fileSystem/trunk" />
<arg path="${workspace}/dependency/fileSystem" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_html/trunk" />
<arg path="${workspace}/dependency/html" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_json/trunk" />
<arg path="${workspace}/dependency/json" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_localisation/trunk" />
<arg path="${workspace}/dependency/localisation" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_logger/trunk" />
<arg path="${workspace}/dependency/logger" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_repository/trunk" />
<arg path="${workspace}/dependency/repository" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_sdo/trunk" />
<arg path="${workspace}/dependency/sdo" />
</exec>
<exec executable="svn">
<arg value="co" />
<arg value="http://svn.laabs-framework.in/dependency_xml/trunk" />
<arg path="${workspace}/dependency/xml" />
</exec>
<mkdir dir="${builddir}/logs"/>
<mkdir dir="${builddir}/pdepend"/>
<mkdir dir="${builddir}/code-browser"/>
<mkdir dir="${builddir}/coverage"/>
</target>
<!-- LINT -->
<target name="lint" description="Perform syntax check of sourcecode files">
<apply executable="php" failonerror="false">
<arg value="-l" />
<fileset dir="${sourcedir}">
<include name="**/*.php" />
<modified />
</fileset>
</apply>
</target>
<!-- PHPLOC -->
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv" />
<arg value="${builddir}/logs/phploc.csv" />
<arg path="${sourcedir}" />
</exec>
</target>
<!-- PDEPEND -->
<target name="pdepend" description="Calculate software metrics using PHP_Depend">
<exec executable="pdepend">
<arg value="--jdepend-xml=${builddir}/logs/jdepend.xml" />
<arg value="--jdepend-chart=${builddir}/pdepend/dependencies.svg" />
<arg value="--overview-pyramid=${builddir}/pdepend/overview-pyramid.svg" />
<arg path="${sourcedir}" />
</exec>
</target>
<!-- PHPCPD -->
<target name="phpcpd" description="Find duplicate code using PHPCPD">
<exec executable="phpcpd">
<arg value="--log-pmd" />
<arg value="${builddir}/logs/pmd-cpd.xml" />
<arg path="${sourcedir}" />
</exec>
</target>
<!-- PHPMD -->
<target name="phpmd" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
<exec executable="phpmd">
<arg path="${sourcedir}" />
<arg value="xml" />
<arg value="${workspace}/phpmd.xml" />
<arg value="--reportfile" />
<arg value="${builddir}/logs/pmd.xml" />
<arg value="--minimumpriority" />
<arg value="3" />
</exec>
</target>
<!-- PHPCS -->
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
<exec executable="phpcs" output="/dev/null">
<arg value="--report=checkstyle" />
<arg value="--report-file=${builddir}/logs/checkstyle.xml" />
<arg value="--standard=Symfony2" />
<arg value="--extensions=php" />
<arg value="--error-severity=5" />
<arg value="--warning-severity=8" />
<arg path="${sourcedir}" />
</exec>
</target>
<!-- PHPDOC -->
<target name="phpdoc" description="Generate API documentation using phpDocumentor">
<exec executable="phpdoc">
<arg line="-d '${sourcedir}' -t '${builddir}/docs' --title='Laabs Framework [trunk]' " />
</exec>
</target>
<!-- PHPDOX -->
<!-- target name="phpdox" description="Generate API documentation using phpDox">
<exec executable="phpdox"/>
</target -->
<!-- PHPUNIT -->
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit" failonerror="false">
<arg value="-c" />
<arg path="${basedir}/phpunit.xml" />
</exec>
</target>
<!-- PHPCB -->
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="phpcb">
<arg value="--log" />
<arg path="${builddir}/logs" />
<arg value="--source" />
<arg path="${sourcedir}" />
<arg value="--output" />
<arg path="${builddir}/code-browser" />
</exec>
</target>
</project>
# 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=localhost;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
# 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
{
"require-dev": {
"codeception/codeception": "^3.0",
"flow/jsonpath" : "^0.4"
}
}
{
"baseUrl" : "http://maarchrm/"
"baseUrl" : "http://maarchrm/",
"fixturesFolder": "tests/cypress/fixtures",
"integrationFolder": "tests/cypress/integration",
"pluginsFile": "tests/cypress/plugins/index.js",
"screenshotsFolder": "tests/cypress/screenshots",
"videosFolder": "tests/cypress/videos",
"supportFile": "tests/cypress/support/index.js"
}
\ No newline at end of file
{
"baseUrl" : "http://preview.maarchrm.com/"
"baseUrl" : "http://preview.maarchrm.com/",
"fixturesFolder": "tests/cypress/fixtures",
"integrationFolder": "tests/cypress/integration",
"pluginsFile": "tests/cypress/plugins/index.js",
"screenshotsFolder": "tests/cypress/screenshots",