phpunit-tests.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. # Run our PHPUnit tests
  2. name: PHPUnit-Tests
  3. # Controls when the action will run.
  4. # Run this workflow every time a new commit is pushed to your repository
  5. on: [push, pull_request]
  6. # A workflow run is made up of one or more jobs that can run sequentially or in parallel
  7. jobs:
  8. # This workflow contains a single job called "build"
  9. run-tests:
  10. # The type of runner that the job will run on
  11. runs-on: ubuntu-latest
  12. # Matrix Build for this job.
  13. strategy:
  14. matrix:
  15. php-versions: ['7.1', '7.2']
  16. # Name the matrix build so we can tell them apart.
  17. name: PHPUnit Testing of Tripal Core (PHP ${{ matrix.php-versions }})
  18. # Service containers to run with `run-tests`
  19. services:
  20. # Label used to access the service container
  21. postgres:
  22. # Docker Hub image
  23. image: postgres
  24. env:
  25. POSTGRES_USER: postgres
  26. POSTGRES_PASSWORD: dbpass
  27. POSTGRES_DB: test_db
  28. # Set health checks to wait until postgres has started
  29. options: >-
  30. --health-cmd pg_isready
  31. --health-interval 10s
  32. --health-timeout 5s
  33. --health-retries 5
  34. ports:
  35. # Maps tcp port 5432 on service container to the host
  36. - 5432:5432
  37. # Steps represent a sequence of tasks that will be executed as part of the job
  38. steps:
  39. # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
  40. - name: Checkout Repository
  41. uses: actions/checkout@v2
  42. # Sets up the PHP environment for PHP 7.2
  43. - name: Setup PHP
  44. uses: shivammathur/setup-php@v2
  45. with:
  46. php-version: ${{ matrix.php-versions }}
  47. # Install extensions for PHP-PostgreSQL
  48. extensions: mbstring, intl, php-pgsql, php-gd, php-xml
  49. # Increase memory limit to 2G
  50. ini-values: memory_limit=2G
  51. # Enable xdebug for coverage reporting
  52. coverage: xdebug
  53. # Install composer and phpunit globally.
  54. tools: composer, phpunit
  55. # Install Drush 8.x globally
  56. # NOTE: `drush` is not available without the full path.
  57. # I tried adding it to the path but that broke other things.
  58. - name: Install Drush
  59. run: |
  60. composer global require "drush/drush:~8"
  61. /home/runner/.composer/vendor/bin/drush --version
  62. # Install Drupal and Drupal module dependencies for Tripal.
  63. # It also patches Drupal.
  64. - name: Install Drupal
  65. env:
  66. DRUSH: "/home/runner/.composer/vendor/bin/drush"
  67. DRUPAL_ROOT: "/home/runner/work/drupal"
  68. POSTGRES_CONNECTION_STRING: 'pgsql://postgres:dbpass@localhost:5432/test_db'
  69. ACCOUNT_NAME: tripaladmin
  70. ACCOUNT_PASS: somereallysecurepassword
  71. run: |
  72. echo "==> Downloading Drupal"
  73. cd /home/runner/work
  74. $DRUSH dl drupal-7 -y
  75. mv drupal-7* drupal
  76. echo "==> Installing Drupal"
  77. cd $DRUPAL_ROOT
  78. $DRUSH si -y --root=$DRUPAL_ROOT \
  79. --db-url=$POSTGRES_CONNECTION_STRING \
  80. --account-name=$ACCOUNT_NAME \
  81. --account-pass=$ACCOUNT_PASS \
  82. --site-mail=admin@example.com \
  83. --site-name=Tripal3
  84. echo "==> Downloading dependencies"
  85. $DRUSH dl -y views ctools entity redirect date ds field_group field_group_table
  86. echo "==> Enabling Dependencies"
  87. $DRUSH en -y views ctools entity redirect date ds field_group field_group_table
  88. echo "==> Apply Drupal Patch"
  89. cd $DRUPAL_ROOT
  90. wget --no-check-certificate https://drupal.org/files/drupal.pgsql-bytea.27.patch
  91. patch -p1 < drupal.pgsql-bytea.27.patch
  92. # Install Tripal, Chado and prepares the Drupal/Chado databases
  93. # Also patches views.
  94. - name: Install Tripal
  95. env:
  96. DRUSH: "/home/runner/.composer/vendor/bin/drush"
  97. DRUPAL_ROOT: "/home/runner/work/drupal"
  98. POSTGRES_CONNECTION_STRING: 'pgsql://postgres:dbpass@localhost:5432/test_db'
  99. ACCOUNT_NAME: tripaladmin
  100. ACCOUNT_PASS: somereallysecurepassword
  101. run: |
  102. echo "==> Move Tripal into the Drupal modules directory"
  103. ls /home/runner/work/tripal/tripal
  104. cp -R /home/runner/work/tripal/tripal $DRUPAL_ROOT/sites/all/modules
  105. echo "==> Apply Views Patch"
  106. cd $DRUPAL_ROOT/sites/all/modules/views
  107. patch -p1 < ../tripal/tripal_chado_views/views-sql-compliant-three-tier-naming-1971160-30.patch
  108. echo "==> Install Tripal"
  109. cd $DRUPAL_ROOT
  110. $DRUSH en -y tripal tripal_chado tripal_chado_views tripal_ws tripal_ds
  111. echo "==> Install Chado"
  112. $DRUSH eval "module_load_include('inc', 'tripal_chado', 'includes/tripal_chado.install'); tripal_chado_load_drush_submit('Install Chado v1.3');"
  113. $DRUSH trp-run-jobs --username=$ACCOUNT_NAME
  114. echo "==> Prepare Chado"
  115. $DRUSH eval "module_load_include('inc', 'tripal_chado', 'includes/setup/tripal_chado.setup'); tripal_chado_prepare_drush_submit();"
  116. $DRUSH trp-run-jobs --username=$ACCOUNT_NAME
  117. # Runs the PHPUnit tests.
  118. # https://github.com/mheap/phpunit-github-actions-printer is used
  119. # to report PHPUnit fails in a meaningful way to github in PRs.
  120. - name: PHPUnit Tests
  121. env:
  122. DRUSH: "/home/runner/.composer/vendor/bin/drush"
  123. DRUPAL_ROOT: "/home/runner/work/drupal"
  124. POSTGRES_CONNECTION_STRING: 'pgsql://postgres:dbpass@localhost:5432/test_db'
  125. ACCOUNT_NAME: tripaladmin
  126. ACCOUNT_PASS: somereallysecurepassword
  127. run: |
  128. cd $DRUPAL_ROOT/sites/all/modules/tripal
  129. composer require --dev mheap/phpunit-github-actions-printer
  130. composer update
  131. cp tests/.travis.env tests/.env
  132. ./vendor/bin/phpunit --printer mheap\\GithubActionsReporter\\Printer