phpunit-tests.yml 5.6 KB

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