Hubzilla core code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

148 line
4.4 KiB

  1. # Select image from https://hub.docker.com/_/php/
  2. #image: php:7.2
  3. # Use a prepared Hubzilla image to optimise pipeline duration
  4. image: registry.gitlab.com/dawnbreak/hubzilla/core:php7.2
  5. stages:
  6. - test
  7. - deploy
  8. # Select what we should cache
  9. cache:
  10. paths:
  11. - vendor/
  12. - .cache/
  13. # global variables for all jobs, if no job specific variables
  14. variables:
  15. # Tell composer to use the project workspace .cache folder
  16. COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/.cache/composer"
  17. # Ignore a Composer warning
  18. COMPOSER_ALLOW_SUPERUSER: 1
  19. # Configure MySQL/MariaDB service (https://hub.docker.com/_/mysql/, https://hub.docker.com/_/mariadb/)
  20. MYSQL_DATABASE: hello_world_test
  21. MYSQL_ROOT_PASSWORD: mysql
  22. # Configure PostgreSQL service (https://hub.docker.com/_/postgres/)
  23. POSTGRES_DB: ci-db
  24. POSTGRES_USER: ci-user
  25. POSTGRES_PASSWORD: ci-pass
  26. before_script:
  27. # pecl and composer do not work with PHP production restrictions (from Hubzilla Docker image)
  28. - 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
  29. # Install & enable Xdebug for code coverage reports
  30. - pecl install xdebug
  31. - docker-php-ext-enable xdebug
  32. # Install composer
  33. - curl -sS https://getcomposer.org/installer | php
  34. # Install dev libraries from composer
  35. - php ./composer.phar install --no-progress
  36. # hidden job definition with template for MySQL/MariaDB
  37. .job_template_mysql: &job_definition_mysql
  38. stage: test
  39. script:
  40. - echo "USE $MYSQL_DATABASE; $(cat ./install/schema_mysql.sql)" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
  41. - echo "SHOW DATABASES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
  42. - echo "USE $MYSQL_DATABASE; SHOW TABLES;" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
  43. - vendor/bin/phpunit --configuration tests/phpunit.xml --coverage-text
  44. # hidden job definition with template for PostgreSQL
  45. .job_template_postgres: &job_definition_postgres
  46. stage: test
  47. services:
  48. - postgres:latest
  49. script:
  50. - export PGPASSWORD=$POSTGRES_PASSWORD
  51. - psql --version
  52. - psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT VERSION();"
  53. # Import hubzilla's DB schema
  54. - psql -h "postgres" -U "$POSTGRES_USER" -v ON_ERROR_STOP=1 --quiet "$POSTGRES_DB" < ./install/schema_postgres.sql
  55. # Show databases and relations/tables of hubzilla's database
  56. #- psql -h "postgres" -U "$POSTGRES_USER" -l
  57. #- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "\dt;"
  58. # Run the actual tests
  59. - vendor/bin/phpunit --configuration tests/phpunit-pgsql.xml --testdox
  60. # hidden job definition with artifacts config template
  61. .artifacts_template:
  62. artifacts: &artifacts_template
  63. expire_in: 1 week
  64. # Gitlab should show the results, but has problems parsing PHPUnit's junit file.
  65. reports:
  66. junit: tests/results/junit.xml
  67. # Archive test results (coverage, testdox, junit)
  68. name: "$CI_COMMIT_REF_SLUG-$CI_JOB_NAME"
  69. paths:
  70. - tests/results/
  71. # PHP7.2 with MySQL 5.7
  72. php7.2_mysql5.7:
  73. <<: *job_definition_mysql
  74. services:
  75. - mysql:5.7
  76. # PHP7.2 with MySQL 8 (latest)
  77. php7.2_mysql8:
  78. <<: *job_definition_mysql
  79. services:
  80. - name: mysql:8
  81. command: ["--default-authentication-plugin=mysql_native_password"]
  82. # PHP7.2 with MariaDB 10.2
  83. php7.2_mariadb10.2:
  84. <<: *job_definition_mysql
  85. services:
  86. - name: mariadb:10.2
  87. alias: mysql
  88. # PHP7.3 with MariaDB 10.3 (latest)
  89. php7.3_mariadb10.3:
  90. <<: *job_definition_mysql
  91. image: registry.gitlab.com/dawnbreak/hubzilla/core:php7.3
  92. services:
  93. - name: mariadb:10.3
  94. alias: mysql
  95. # PHP7.2 with PostgreSQL latest (11)
  96. php7.2_postgres11:
  97. <<: *job_definition_postgres
  98. artifacts: *artifacts_template
  99. # PHP7.3 with PostgreSQL latest (11)
  100. php7.3_postgres11:
  101. <<: *job_definition_postgres
  102. image: registry.gitlab.com/dawnbreak/hubzilla/core:php7.3
  103. artifacts: *artifacts_template
  104. # Generate Doxygen API Documentation and deploy it as GitLab pages
  105. pages:
  106. stage: deploy
  107. cache: {}
  108. image: php:7-cli-alpine
  109. before_script:
  110. - apk update
  111. - apk add doxygen ttf-freefont graphviz
  112. script:
  113. - doxygen util/Doxyfile
  114. - mv doc/html/ public/
  115. - echo "API documentation should be accessible at https://hubzilla.frama.io/core/ soon"
  116. artifacts:
  117. paths:
  118. - public
  119. only:
  120. # Only generate it on main repo's master branch
  121. - master@hubzilla/core