Parcourir la source

Merge pull request #61 from tripal/phpunit-action

Create phpunit test github action.
Lacey-Anne Sanderson il y a 4 ans
Parent
commit
4a8bbd8e6b
4 fichiers modifiés avec 97 ajouts et 41 suppressions
  1. 84 0
      .github/workflows/phpunit.yml
  2. 0 38
      .travis.yml
  3. 10 0
      README.md
  4. 3 3
      tests/tripal_jbrowse_mgmt/ApiTest.php

+ 84 - 0
.github/workflows/phpunit.yml

@@ -0,0 +1,84 @@
+name: PHPUnit
+
+# 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 (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 PHP according to the version passed in.
+    - name: Setup PHP
+      uses: shivammathur/setup-php@v2
+      with:
+        php-version: ${{ matrix.php-versions }}
+        extensions: mbstring, intl, php-pgsql, php-gd, php-xml
+        ini-values: memory_limit=2G
+        coverage: xdebug
+        tools: composer, phpunit
+
+    # Install Drush/Drupal/Tripal
+    - name: Setup Drush, Drupal 7.x, Tripal 3.x
+      id: tripalsetup
+      uses: tripal/setup-tripal-action@7.x-3.x-1.0
+      with:
+        postgres_user: tripaladmin
+        postgres_pass: somesupersecurepassword
+        postgres_db: testdb
+
+    # Install Tripal Extension Module.
+    - name: Install Tripal Extension Module
+      id: installextension
+      env:
+        DRUSH: ${{ steps.tripalsetup.outputs.drush_path }}
+        DRUPAL_ROOT: ${{ steps.tripalsetup.outputs.drupal_root }}
+      run: |
+        mkdir -p $DRUPAL_ROOT/sites/all/modules/tripal_jbrowse
+        cp -R * $DRUPAL_ROOT/sites/all/modules/tripal_jbrowse
+        cd $DRUPAL_ROOT
+        $DRUSH en -y tripal_jbrowse_mgmt tripal_jbrowse_page
+
+    # 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: |
+        cd $DRUPAL_ROOT/sites/all/modules/tripal_jbrowse
+        composer require --dev mheap/phpunit-github-actions-printer --quiet
+        composer update --quiet
+        ./vendor/bin/phpunit --printer mheap\\GithubActionsReporter\\Printer

+ 0 - 38
.travis.yml

@@ -1,38 +0,0 @@
-language: php
-
-# Add php version so composer doesn't complain
-php:
-  - 7.1
-
-services:
-  - docker
-
-env:
-  - DRUPAL_ROOT=/var/www/html JBROWSE_ROOT=/var/www/html/jbrowse IS_TRAVIS=TRUE CC_TEST_REPORTER_ID=1a35bfa282bdb226287eee73c3eb1fdb61f1509117f55417135081624a0366be
-
-before_script:
-  - docker pull statonlab/tripal3
-  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
-  - chmod +x ./cc-test-reporter
-  - ./cc-test-reporter before-build --debug
-  - GIT_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH
-  - GIT_COMMIT_SHA=$TRAVIS_PULL_REQUEST_SHA
-
-script:
-  - docker run -it -d --rm --name tripal -v "$(pwd)":/modules/tripal_jbrowse statonlab/tripal3
-  - sleep 30 # We pause here so postgres and apache complete booting up
-  ## Install JBrowse
-  - docker exec -it tripal bash -c 'sudo yum -y groupinstall "Development Tools"'
-  - docker exec -it tripal bash -c 'sudo yum -y install zlib-devel perl-ExtUtils-MakeMaker'
-  - docker exec -it tripal bash -c 'curl -L -O https://github.com/GMOD/jbrowse/releases/download/1.16.6-release/JBrowse-1.16.6.zip'
-  - docker exec -it tripal bash -c 'unzip JBrowse-1.16.6.zip && sudo mv JBrowse-1.16.6 /var/www/html/jbrowse && cd /var/www/html && sudo chown `whoami` jbrowse'
-  - docker exec -it tripal bash -c 'cd /var/www/html/jbrowse && ./setup.sh'
-  ## Setup XDebug for Code Coverage
-  - docker exec -it tripal yum install -y php-pecl-xdebug.x86_64
-  ## Install tripal_jbrowse package.
-  - docker exec -it tripal drush pm-enable -y tripal_jbrowse_page tripal_jbrowse_mgmt
-  ## Run Tests.
-  - docker exec -it tripal bash -c "cd /modules/tripal_jbrowse && composer install && DRUPAL_ROOT=/var/www/html ./vendor/bin/phpunit --coverage-clover ./clover.xml"
-
-after_script:
-  - ./cc-test-reporter after-build clover.xml --debug -t clover -p /var/www/html/sites/all/modules/custom/tripal_jbrowse --exit-code $TRAVIS_TEST_RESULT

+ 10 - 0
README.md

@@ -1,3 +1,9 @@
+![PHPUnit](https://github.com/tripal/tripal_jbrowse/workflows/PHPUnit/badge.svg)
+![GitHub release (latest by date)](https://img.shields.io/github/v/release/tripal/tripal_jbrowse)
+[![Documentation Status](https://readthedocs.org/projects/tripal-jbrowse/badge/?version=latest)](https://tripal-jbrowse.readthedocs.io/en/latest/?badge=latest)
+
+[![DOI](https://zenodo.org/badge/44405693.svg)](https://zenodo.org/badge/latestdoi/44405693)
+
 # Tripal JBrowse Integration
 
 This package of modules integrates [GMOD JBrowse](https://jbrowse.org/) into your [Tripal](http://tripal.info/) site providing
@@ -30,3 +36,7 @@ This module is open-source and licensed under GPLv3. [Read full license](LICENSE
 - Other contributors (https://github.com/tripal/tripal_jbrowse/graphs/contributors)
 
 *Copyright 2018 University of Saskatchewan and University of Tennessee Knoxville.*
+
+**Citation:**
+
+Lacey-Anne Sanderson, Abdullah Almsaeed, Joe West, & Yichao Shen. (2019). tripal/tripal_jbrowse: Tripal JBrowse 3.0 (Version 7.x-3.0). Zenodo. http://doi.org/10.5281/zenodo.3564724.

+ 3 - 3
tests/tripal_jbrowse_mgmt/ApiTest.php

@@ -226,9 +226,9 @@ class ApiTest extends TripalTestCase {
     $instance_id = tripal_jbrowse_mgmt_create_instance($instance_details);
 
     $testdata = [
-      $faker->word() => $faker->words(3, TRUE),
-      $faker->word() => $faker->words(2, TRUE),
-      $faker->word() => $faker->words(10, TRUE),
+      $faker->word() . '1' => $faker->words(3, TRUE),
+      $faker->word() . '2' => $faker->words(2, TRUE),
+      $faker->word() . '3' => $faker->words(10, TRUE),
     ];
 
     // Create.