aboutsummaryrefslogtreecommitdiffstats
path: root/.gitlab-ci.yml
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2024-01-06 16:34:38 +0000
committerMario <mario@mariovavti.com>2024-01-06 16:34:38 +0000
commite3d30763dabdf12f961ed3d1d7cf4eaee44c65a9 (patch)
treeed3d493e8423ad9ccbde5e8e199e65164820e70f /.gitlab-ci.yml
parent6252340804bee66736e49de4bdc08755510f1c70 (diff)
downloadvolse-hubzilla-e3d30763dabdf12f961ed3d1d7cf4eaee44c65a9.tar.gz
volse-hubzilla-e3d30763dabdf12f961ed3d1d7cf4eaee44c65a9.tar.bz2
volse-hubzilla-e3d30763dabdf12f961ed3d1d7cf4eaee44c65a9.zip
tests: Integrate the DB in "unit" tests.
Diffstat (limited to '.gitlab-ci.yml')
-rw-r--r--.gitlab-ci.yml165
1 files changed, 66 insertions, 99 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1354a5de7..9825c1e8a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,10 +1,3 @@
-# Select image from https://hub.docker.com/_/php/
-#image: php:7.3
-# Use a prepared Hubzilla image to optimise pipeline duration
-# image: registry.gitlab.com/dawnbreak/hubzilla/core:php7.3
-
-image: php:8.1
-
stages:
- test
- deploy
@@ -33,58 +26,64 @@ variables:
before_script:
-# pecl and composer do not work with PHP production restrictions (from Hubzilla Docker image)
-- if [ -f /usr/local/etc/php/conf.d/z_prod.ini ]; then mv /usr/local/etc/php/conf.d/z_prod.ini /usr/local/etc/php/conf.d/z_prod.ini.off; fi
-# Install & enable Xdebug for code coverage reports
-- pecl install xdebug
-- apt-get update
-- apt-get install zip unzip libjpeg-dev libpng-dev -yqq
-- docker-php-ext-enable xdebug
-- docker-php-ext-install gd
-
-# Install composer
-- curl -sS https://getcomposer.org/installer | php
-# Install dev libraries from composer
-- php ./composer.phar install --no-progress
-# php.ini settings
-- echo 'xdebug.mode=coverage' >> /usr/local/etc/php/php.ini
-
-# hidden job definition with template for PHP
-.job_template_php: &job_definition_php
+ # Install & enable Xdebug for code coverage reports
+ - pecl install xdebug
+ - apt-get update
+ - apt-get install -yqq libjpeg-dev libpng-dev libpq-dev libzip-dev mariadb-client postgresql-client unzip zip
+ - docker-php-ext-enable xdebug
+ - docker-php-ext-install gd pdo_mysql pdo_pgsql zip
+
+ # Install composer
+ - curl -sS https://getcomposer.org/installer | php
+ # Install dev libraries from composer
+ - php ./composer.phar install --no-progress
+ # php.ini settings
+ - echo 'xdebug.mode=coverage' >> /usr/local/etc/php/php.ini
+
+# hidden job definition with template for MySQL/MariaDB
+.job_template_mysql: &job_definition_mysql
stage: test
+ variables:
+ HZ_TEST_DB_HOST: mysql
+ HZ_TEST_DB_TYPE: mysql
+ HZ_TEST_DB_USER: root
+ HZ_TEST_DB_PASS: $MYSQL_ROOT_PASSWORD
+ HZ_TEST_DB_DATABASE: $MYSQL_DATABASE
script:
- - vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text
-
+ - echo "USE $MYSQL_DATABASE; $(cat ./install/schema_mysql.sql)" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
+ - echo "SHOW DATABASES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
+ - echo "USE $MYSQL_DATABASE; SHOW TABLES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
+ - touch dbfail.out
+ - vendor/bin/phpunit --configuration tests/phpunit.xml --verbose --stop-on-error --coverage-text --colors=never --log-junit tests/results/junit.xml
+ coverage: '/^\s*Lines:\s*\d+.\d+\%/'
-# hidden job definition with template for MySQL/MariaDB
-#.job_template_mysql: &job_definition_mysql
-# stage: test
-# script:
-# - echo "USE $MYSQL_DATABASE; $(cat ./install/schema_mysql.sql)" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
-# - echo "SHOW DATABASES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
-# - echo "USE $MYSQL_DATABASE; SHOW TABLES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
-# - vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text
# hidden job definition with template for PostgreSQL
-#.job_template_postgres: &job_definition_postgres
-# stage: test
-# services:
-# - postgres:latest
-# script:
-# - export PGPASSWORD=$POSTGRES_PASSWORD
-# - psql --version
-# - psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT VERSION();"
- # Import hubzilla's DB schema
-# - psql -h "postgres" -U "$POSTGRES_USER" -v ON_ERROR_STOP=1 --quiet "$POSTGRES_DB" < ./install/schema_postgres.sql
- # Show databases and relations/tables of hubzilla's database
- #- psql -h "postgres" -U "$POSTGRES_USER" -l
- #- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "\dt;"
- # Run the actual tests
-# - vendor/bin/phpunit --configuration tests/phpunit-pgsql.xml --testdox
+.job_template_postgres: &job_definition_postgres
+ stage: test
+ variables:
+ HZ_TEST_DB_HOST: postgres
+ HZ_TEST_DB_TYPE: postgres
+ HZ_TEST_DB_USER: $POSTGRES_USER
+ HZ_TEST_DB_PASS: $POSTGRES_PASSWORD
+ HZ_TEST_DB_DATABASE: $POSTGRES_DB
+ script:
+ - export PGPASSWORD=$POSTGRES_PASSWORD
+ - psql --version
+ - psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT VERSION();"
+ # Import hubzilla's DB schema
+ - psql -h "postgres" -U "$POSTGRES_USER" -v ON_ERROR_STOP=1 --quiet "$POSTGRES_DB" < ./install/schema_postgres.sql
+ # Show databases and relations/tables of hubzilla's database
+ #- psql -h "postgres" -U "$POSTGRES_USER" -l
+ #- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "\dt;"
+ # Run the actual tests
+ - touch dbfail.out
+ - vendor/bin/phpunit --configuration tests/phpunit.xml --verbose --stop-on-error --coverage-text --colors=never --log-junit tests/results/junit.xml
+ coverage: '/^\s*Lines:\s*\d+.\d+\%/'
# hidden job definition with artifacts config template
-.artifacts_template:
- artifacts: &artifacts_template
+.artifacts_template: &artifacts_template
+ artifacts:
expire_in: 1 week
# Gitlab should show the results, but has problems parsing PHPUnit's junit file.
reports:
@@ -95,54 +94,22 @@ before_script:
- tests/results/
-# PHP8.1
-php8.1:
- <<: *job_definition_php
-
# PHP8.0 with MySQL 5.7
-#php8.0_mysql5.7:
-# <<: *job_definition_mysql
-# services:
-# - mysql:5.7
-
-
-# PHP8.0 with MySQL 8 (latest)
-#php8.0_mysql8:
-# <<: *job_definition_mysql
-# services:
-# - name: mysql:8
-# command: ["--default-authentication-plugin=mysql_native_password"]
-
-
-# PHP8.0 with MariaDB 10.2
-#php8.0_mariadb10.2:
-# <<: *job_definition_mysql
-# services:
-# - name: mariadb:10.2
-# alias: mysql
-
-
-# PHP8.0 with MariaDB 10.3 (latest)
-#php8.0_mariadb10.3:
-# <<: *job_definition_mysql
-# image: php:8.0
- #image: registry.gitlab.com/dawnbreak/hubzilla/core:php7.3
-# services:
-# - name: mariadb:10.3
-# alias: mysql
-
-
-# PHP7.3 with PostgreSQL latest (11)
-#php7.3_postgres11:
-# <<: *job_definition_postgres
-# artifacts: *artifacts_template
-
-
-# PHP7.3 with PostgreSQL latest (11)
-#php7.3_postgres11:
-# <<: *job_definition_postgres
-# image: registry.gitlab.com/dawnbreak/hubzilla/core:php7.3
-# artifacts: *artifacts_template
+php8.1_mysql5.7:
+ <<: *job_definition_mysql
+ <<: *artifacts_template
+ image: php:8.1
+ services:
+ - mysql:5.7
+
+
+# PHP8.1 with PostgreSQL 12
+php8.1_postgres12:
+ <<: *job_definition_postgres
+ <<: *artifacts_template
+ image: php:8.1
+ services:
+ - postgres:12-alpine
# Generate Doxygen API Documentation and deploy it as GitLab pages