|
| 1 | + |
| 2 | +name: Run PHPUnit Tests |
| 3 | + |
| 4 | +# Controls when the workflow will run. |
| 5 | +# Run this workflow every time a new commit is pushed to your repository |
| 6 | +on: [push, pull_request] |
| 7 | + |
| 8 | +jobs: |
| 9 | + # This key is the name of the job. |
| 10 | + run-tests: |
| 11 | + # The type of system that the job will run on. |
| 12 | + runs-on: ubuntu-latest |
| 13 | + # Matrix Build for this job. |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + php-versions: ['7.1', '7.2'] |
| 17 | + # Name the matrix build so we can tell them apart. |
| 18 | + name: PHP Unit Testing of Tripal Germplasm Importer Module (PHP ${{ matrix.php-versions }}) |
| 19 | + |
| 20 | + # Service containers to run with `run-tests` |
| 21 | + services: |
| 22 | + # Label used to access the service container |
| 23 | + postgres: |
| 24 | + # Docker Hub image |
| 25 | + image: postgres |
| 26 | + env: |
| 27 | + POSTGRES_USER: tripaladmin |
| 28 | + POSTGRES_PASSWORD: somesupersecurepassword |
| 29 | + POSTGRES_DB: testdb |
| 30 | + # Set health checks to wait until postgres has started |
| 31 | + options: >- |
| 32 | + --health-cmd pg_isready |
| 33 | + --health-interval 10s |
| 34 | + --health-timeout 5s |
| 35 | + --health-retries 5 |
| 36 | + ports: |
| 37 | + # Maps tcp port 5432 on service container to the host |
| 38 | + - 5432:5432 |
| 39 | + |
| 40 | + steps: |
| 41 | + # 1) Checkout the repository and setup workspace. |
| 42 | + - uses: actions/checkout@v2 |
| 43 | + |
| 44 | + # 2) Setup PHP according to the version passed in. |
| 45 | + - name: Setup PHP |
| 46 | + uses: shivammathur/setup-php@v2 |
| 47 | + with: |
| 48 | + php-version: ${{ matrix.php-versions }} |
| 49 | + extensions: mbstring, intl, php-pgsql, php-gd, php-xml |
| 50 | + ini-values: memory_limit=2G |
| 51 | + coverage: xdebug |
| 52 | + tools: composer, phpunit |
| 53 | + |
| 54 | + # 3) Install Drush/Drupal/Tripal |
| 55 | + - name: Setup Drush, Drupal 7.x, Tripal 3.x |
| 56 | + id: tripalsetup |
| 57 | + |
| 58 | + with: |
| 59 | + postgres_user: tripaladmin |
| 60 | + postgres_pass: somesupersecurepassword |
| 61 | + postgres_db: testdb |
| 62 | + |
| 63 | + # 4) Install Tripal Germpasm Importer |
| 64 | + - name: Install Tripal Germplasm Importer |
| 65 | + id: installtripalgermplasmimporter |
| 66 | + env: |
| 67 | + DRUSH: ${{ steps.tripalsetup.outputs.drush_path }} |
| 68 | + DRUPAL_ROOT: ${{ steps.tripalsetup.outputs.drupal_root }} |
| 69 | + run: | |
| 70 | + mkdir -p $DRUPAL_ROOT/sites/all/modules/tripal_germplasm_importer |
| 71 | + cp -R * $DRUPAL_ROOT/sites/all/modules/tripal_germplasm_importer |
| 72 | + cd $DRUPAL_ROOT |
| 73 | + $DRUSH en -y tripal_germplasm_importer |
| 74 | +
|
| 75 | + # 5) Runs the PHPUnit tests. |
| 76 | + # https://github.com/mheap/phpunit-github-actions-printer is used |
| 77 | + # to report PHPUnit fails in a meaningful way to github in PRs. |
| 78 | + - name: PHPUnit Tests |
| 79 | + env: |
| 80 | + DRUSH: ${{ steps.tripalsetup.outputs.drush_path }} |
| 81 | + DRUPAL_ROOT: ${{ steps.tripalsetup.outputs.drupal_root }} |
| 82 | + run: | |
| 83 | + cd $DRUPAL_ROOT/sites/all/modules/tripal_germplasm_importer |
| 84 | + composer require --dev mheap/phpunit-github-actions-printer --quiet |
| 85 | + composer update --quiet |
| 86 | + ./vendor/bin/phpunit --printer mheap\\GithubActionsReporter\\Printer |
0 commit comments