Skip to content

Commit

Permalink
Merge pull request #8 from UofS-Pulse-Binfo/github-actions-integration
Browse files Browse the repository at this point in the history
Implements GitHub Actions
  • Loading branch information
laceysanderson authored Jun 27, 2024
2 parents 9367ed3 + eda99df commit b4ba6f9
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 4 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@

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:
# This key is the name of the job.
run-tests:
# The type of system 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: PHP Unit Testing of Tripal QTL Module (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:
# 1) Checkout the repository and setup workspace.
- uses: actions/checkout@v2

# 2) 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

# 3) Install Drush/Drupal/Tripal
- name: Setup Drush, Drupal 7.x, Tripal 3.x
id: tripalsetup
uses: tripal/[email protected]
with:
postgres_user: tripaladmin
postgres_pass: somesupersecurepassword
postgres_db: testdb

# 4) Install Tripal QTL
- name: Install Tripal QTL
id: installtripalqtl
env:
DRUSH: ${{ steps.tripalsetup.outputs.drush_path }}
DRUPAL_ROOT: ${{ steps.tripalsetup.outputs.drupal_root }}
run: |
mkdir -p $DRUPAL_ROOT/sites/all/modules/tripal_qtl
cp -R * $DRUPAL_ROOT/sites/all/modules/tripal_qtl
cd $DRUPAL_ROOT
$DRUSH en -y tripal_qtl
# 5) 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_qtl
composer require --dev mheap/phpunit-github-actions-printer --quiet
composer update --quiet
./vendor/bin/phpunit --printer mheap\\GithubActionsReporter\\Printer
7 changes: 4 additions & 3 deletions includes/TripalImporter/QTLImporter.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Provides support for loading of MST map files.
*/
class QTLImporter extends TripalImporter {

/**
* The name of this loader.
*
Expand Down Expand Up @@ -130,7 +130,7 @@ class QTLImporter extends TripalImporter {
/**
* Import the map.
*/
public function run() {
public function run($f_id = null) {

// All values provided by the user in the Importer's form widgets are
// made available to us here by the Class' arguments member variable.
Expand All @@ -147,7 +147,8 @@ class QTLImporter extends TripalImporter {
$file_path = $this->arguments['files'][0]['file_path'];

// Retrieve map to add QTL Data to.
$featuremap_id = $arguments['featuremap_name'];
$featuremap_id = ($f_id && $f_id > 1) ? $f_id : $arguments['featuremap_name'];

if (!$featuremap_id) {
$this->logMessage('An Error was encountered retrieving the genetic map.');
return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion tests/QTLImporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function testRun() {
$importer->prepareFiles();

// Now we run the importer!
$success = $importer->run();
$success = $importer->run($mapdetails['featuremap_id']);
$this->assertNotFalse($success,
"The importer returned an error.");

Expand Down

0 comments on commit b4ba6f9

Please sign in to comment.