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