Merge pull request #65 from UofS-Pulse-Binfo/calls-trials #231
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run PHPUnit Tests | |
# Controls when the workflow will run. | |
# Run this workflow every time a new commit is pushed to your repository | |
on: [push, pull_request] | |
jobs: | |
run-tests: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Matrix Build for this job. | |
strategy: | |
matrix: | |
php-versions: ['7.1', '7.2'] | |
# Name the matrix build so we can tell them apart. | |
name: PHPUnit Testing of Tripal Core (PHP ${{ matrix.php-versions }}) | |
# Service containers to run with `run-tests` | |
services: | |
# Label used to access the service container | |
postgres: | |
# Docker Hub image | |
image: postgres | |
env: | |
POSTGRES_USER: tripaladmin | |
POSTGRES_PASSWORD: somesupersecurepassword | |
POSTGRES_DB: testdb | |
# Set health checks to wait until postgres has started | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
# Maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
steps: | |
# Checkout the repository and setup workspace. | |
- uses: actions/checkout@v2 | |
# Setup the docker environment | |
- name: Spin up Docker | |
run: | | |
wget https://raw.githubusercontent.com/laceysanderson/drupal_dev_CI/master/drupal7dev/.env | |
cat .env | |
docker run --publish=80:80 --name=tripaldocker -tid \ | |
-e DBPASS='somesecurepassword' \ | |
-e ADMINPASS='anothersecurepassword' \ | |
--env-file=.env \ | |
--volume=`pwd`:/var/www/html/sites/all/modules/tripal_ws_brapi \ | |
laceysanderson/drupal7dev:latest | |
docker exec tripaldocker /app/init_scripts/startup_container.sh | |
docker exec --workdir=/var/www/html/vendor/bin tripaldocker ./drush status | |
docker exec --workdir=/var/www/html/vendor/bin tripaldocker ./drush en -y tripal_ws_brapi tripal_ws_brapi_testdata | |
# Runs the PHPUnit tests. | |
# https://github.com/mheap/phpunit-github-actions-printer is used | |
# to report PHPUnit fails in a meaningful way to github in PRs. | |
- name: PHPUnit Tests | |
env: | |
DRUSH: ${{ steps.tripalsetup.outputs.drush_path }} | |
DRUPAL_ROOT: ${{ steps.tripalsetup.outputs.drupal_root }} | |
run: | | |
docker exec tripaldocker service postgresql restart | |
docker exec --workdir=/var/www/html tripaldocker \ | |
./vendor/bin/drush php-script sites/all/modules/tripal_ws_brapi/tripal_ws_brapi_testdata/drush-scripts/loadTestData.php | |
docker exec --workdir=/var/www/html/sites/all/modules/tripal_ws_brapi tripaldocker \ | |
composer require --dev mheap/phpunit-github-actions-printer --quiet | |
docker exec --workdir=/var/www/html/sites/all/modules/tripal_ws_brapi tripaldocker \ | |
composer update --quiet | |
docker exec --workdir=/var/www/html/sites/all/modules/tripal_ws_brapi tripaldocker \ | |
./vendor/bin/phpunit --printer mheap\\GithubActionsReporter\\Printer |