Skip to content

Commit

Permalink
Merge branch '4.x' into tv4g2-issue1758-chado_custom_table_functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
laceysanderson authored Feb 9, 2024
2 parents 8296e40 + 08689e4 commit e850e76
Show file tree
Hide file tree
Showing 20 changed files with 429 additions and 22 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ALL-phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ jobs:
php-version:
- "8.1"
- "8.2"
- "8.3"
pgsql-version:
- "13"
drupal-version:
- "10.0.x-dev"
- "10.1.x-dev"
- "10.2.x-dev"
exclude:
- php-version: "8.3"
pgsql-version: "13"
drupal-version: "10.0.x-dev"
- php-version: "8.3"
pgsql-version: "13"
drupal-version: "10.1.x-dev"

steps:
# Check out the repo
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/MAIN-buildDocker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ jobs:
php-version:
- "8.1"
- "8.2"
- "8.3"
pgsql-version:
- "13"
drupal-version:
- "10.0.x-dev"
- "10.1.x-dev"
- "10.2.x-dev"
exclude:
- php-version: "8.3"
pgsql-version: "13"
drupal-version: "10.0.x-dev"
- php-version: "8.3"
pgsql-version: "13"
drupal-version: "10.1.x-dev"
name: Docker Build (drupal${{ matrix.drupal-version }})
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -59,8 +68,8 @@ jobs:
buildArgs: "drupalversion=${{ matrix.drupal-version }}"
labels: 'tripal.branch=4.x,drupal.version.label="${{ matrix.label }}",php.version.label="${{ matrix.php-version }}", postgresql.version.label="${{ matrix.pgsql-version }}"'
- uses: mr-smithers-excellent/docker-build-push@v6
name: Build latest using 10.0.x-dev, PHP 8.1, PgSQL 13
if: ${{ matrix.drupal-version == '10.0.x-dev' && matrix.php-version == '8.1' && matrix.pgsql-version == '13' }}
name: Build latest using 10.2.x-dev, PHP 8.3, PgSQL 13
if: ${{ matrix.drupal-version == '10.2.x-dev' && matrix.php-version == '8.3' && matrix.pgsql-version == '13' }}
with:
image: tripalproject/tripaldocker
tags: latest
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/MAIN-phpunit-php8.1_D10_0x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- 4.x
- tv4g0-issue1673-remove-drupal-9
jobs:
running-tests:
name: "Drupal 10.0: PHP 8.1"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/MAIN-phpunit-php8.1_D10_1x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- 4.x
- tv4g0-issue1673-remove-drupal-9
jobs:
running-tests:
name: "Drupal 10.1: PHP 8.1"
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/MAIN-phpunit-php8.1_D10_2x.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: PHPUnit
on:
push:
branches:
- 4.x
jobs:
running-tests:
name: "Drupal 10.2: PHP 8.1"
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Run Automated testing
uses: tripal/[email protected]
with:
directory-name: 'tripal'
modules: 'tripal tripal_biodb tripal_chado'
php-version: '8.1'
pgsql-version: '13'
drupal-version: '10.2.x-dev'
build-image: true
dockerfile: "UseTripalDockerBackupClause"
1 change: 0 additions & 1 deletion .github/workflows/MAIN-phpunit-php8.2_D10_0x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- 4.x
- tv4g0-issue1673-remove-drupal-9
jobs:
running-tests:
name: "Drupal 10.0: PHP 8.2"
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/MAIN-phpunit-php8.2_D10_1x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
push:
branches:
- 4.x
- tv4g0-issue1673-remove-drupal-9
jobs:
running-tests:
name: "Drupal 10.1: PHP 8.2"
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/MAIN-phpunit-php8.2_D10_2x.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: PHPUnit
on:
push:
branches:
- 4.x
jobs:
running-tests:
name: "Drupal 10.2: PHP 8.2"
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Run Automated testing
uses: tripal/[email protected]
with:
directory-name: 'tripal'
modules: 'tripal tripal_biodb tripal_chado'
php-version: '8.2'
pgsql-version: '13'
drupal-version: '10.2.x-dev'
build-image: true
dockerfile: "UseTripalDockerBackupClause"
22 changes: 22 additions & 0 deletions .github/workflows/MAIN-phpunit-php8.3_D10_2x.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: PHPUnit
on:
push:
branches:
- 4.x
jobs:
running-tests:
name: "Drupal 10.2: PHP 8.3"
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Run Automated testing
uses: tripal/[email protected]
with:
directory-name: 'tripal'
modules: 'tripal tripal_biodb tripal_chado'
php-version: '8.3'
pgsql-version: '13'
drupal-version: '10.2.x-dev'
build-image: true
dockerfile: "UseTripalDockerBackupClause"
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@

![PostgreSQL 13](https://img.shields.io/badge/PostreSQL-13-success)

| Drupal | 10.0.x | 10.1.x |
|-------------|-----------------|-----------------|
| **PHP 8.1** | ![Grid1A-Badge] | ![Grid1B-Badge] |
| **PHP 8.2** | ![Grid2A-Badge] | ![Grid2B-Badge] |
| Drupal | 10.0.x | 10.1.x | 10.2.x |
|-------------|-----------------|-----------------|-----------------|
| **PHP 8.1** | ![Grid1A-Badge] | ![Grid1B-Badge] | ![Grid1C-Badge] |
| **PHP 8.2** | ![Grid2A-Badge] | ![Grid2B-Badge] | ![Grid2C-Badge] |
| **PHP 8.3** | | | ![Grid3C-Badge] |

[Grid1A-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.1_D10_0x.yml/badge.svg
[Grid1B-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.1_D10_1x.yml/badge.svg
[Grid1C-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.1_D10_2x.yml/badge.svg

[Grid2A-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.2_D10_0x.yml/badge.svg
[Grid2B-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.2_D10_1x.yml/badge.svg
[Grid2C-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.2_D10_2x.yml/badge.svg

[Grid3C-Badge]: https://github.com/tripal/tripal/actions/workflows/MAIN-phpunit-php8.3_D10_2x.yml/badge.svg

### Code Coverage

Expand Down
Binary file added tripal/.tripal.routing.yml.swp
Binary file not shown.
3 changes: 2 additions & 1 deletion tripal/src/TripalDBX/TripalDbx.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public function getDrupalSchemaName() :string {
// Get Drupal connection details.
$drupal_database = \Drupal::database();
$connection_options = $drupal_database->getConnectionOptions();
if (array_key_exists('driver', $connection_options) AND ($connection_options['driver'] != 'pgsql')) {
// Drupal <= 10.1 driver will be 'pgsql', Drupal 10.2 it will be 'Drupal\pgsql\Driver\Database\pgsql'
if (array_key_exists('driver', $connection_options) AND (!preg_match('/pgsql$/', $connection_options['driver']))) {
// Not using PostgreSQL. There might be something wrong!
// @todo we may want to evaluate this further as it does tie our Drupal
// database to being in pgsql. It doesn't support the case where Drupal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ public function testTripalAdminPages() {
'Tripal' => 'admin/tripal',
'Registration' => 'admin/tripal/register',
'Jobs' => 'admin/tripal/tripal_jobs',
'Data Loaders' => 'admin/tripal/loaders',
'Data Collections' => 'admin/tripal/data-collections',
'Tripal Managed Files' => 'admin/tripal/files',
'Tripal Content Terms' => 'admin/tripal/config/terms',
'Data Storage' => 'admin/tripal/storage',
'Extensions' => 'admin/tripal/extension',
// Under Drupal ~10.2, if there are no extensions present, and there aren't, then
// we won't be able to access the 'admin/tripal/extension' menu, even as admin.
// To test, we would have to create an extension first.
// 'Extensions' => 'admin/tripal/extension',
];

$userAuthenticatedOnly = $this->drupalCreateUser();
$userTripalAdmin = $this->drupalCreateUser(['administer tripal']);
// Drupal 10.2 tightens permissions, second permission is needed to access files path
$userTripalAdmin = $this->drupalCreateUser(['administer tripal', 'admin tripal files']);

// First check all the URLs with no user logged in.
// This checks the anonymous user cannot access these pages.
Expand Down
1 change: 1 addition & 0 deletions tripal_chado/src/Plugin/TripalImporter/GFF3Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,7 @@ private function getCachedFeature($findex) {
['%findex' => $findex, '%file' -> $this->gff_cache_file]));
}
$feature = fgets($this->gff_cache_file);
$feature = rtrim($feature, "\n");
$feature = unserialize($feature);
return $feature;
}
Expand Down
2 changes: 1 addition & 1 deletion tripal_chado/src/Task/ChadoPreparer.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function performTask() :bool {
$this->chado_schema_main = $schema_name;
$chado = \Drupal::service('tripal_chado.database');
$chado->setSchemaName($schema_name);
$chado->useTripalDbxSchemaFor(get_class());
$chado->useTripalDbxSchemaFor(self::class);

try
{
Expand Down
2 changes: 1 addition & 1 deletion tripal_chado/src/TripalImporter/ChadoImporterBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function getChadoConnection() {
if ($chado->getSchemaName() != $schema_name) {
$chado->setSchemaName($schema_name);
}
$chado->useTripalDbxSchemaFor(get_class());
$chado->useTripalDbxSchemaFor(self::class);

return $chado;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace Drupal\Tests\tripal\Functional;

use Drupal\Tests\BrowserTestBase;
use Drupal\file\Entity\File;
use Drupal\user\Entity\Role;
use Drupal\Core\Url;

/**
* Tests the basic functions of the TripalTerm Entity Type.
*
* @group Tripal
* @group Tripal Chado
* @group Tripal Chado Permissions
*/
class TripalChadoRoutePermissionsTest extends BrowserTestBase {

protected $defaultTheme = 'stark';

protected static $modules = ['tripal', 'tripal_chado'];

/**
* Test all the base Tripal Chado admin paths.
*
*/
public function testTripalChadoAdminPages() {
$session = $this->getSession();

// The URLs to check with the key being the label expected in the
// Tripal admin menu listing.
$urls = [
'Data Loaders' => 'admin/tripal/loaders',
'Data Storage' => 'admin/tripal/storage',
];

$userAuthenticatedOnly = $this->drupalCreateUser();
// Drupal 10.2 tightens permissions, second permission is needed to access importers
$userTripalAdmin = $this->drupalCreateUser(['administer tripal', 'allow tripal import']);

// First check all the URLs with no user logged in.
// This checks the anonymous user cannot access these pages.
foreach ($urls as $title => $path) {
$html = $this->drupalGet($path);
$status_code = $session->getStatusCode();
$this->assertEquals(403, $status_code, "The anonymous user should not be able to access this admin page: $title.");
}

// Next check all the URLs with the authenticated, unprivileged user.
// This checks generic authenticated users cannot access these pages.
$this->drupalLogin($userAuthenticatedOnly);
$this->assertFalse($userAuthenticatedOnly->hasPermission('administer tripal'), "The unprivileged user should not have the 'administer tripal' permission.");
foreach ($urls as $title => $path) {
$html = $this->drupalGet($path);
$status_code = $session->getStatusCode();
$this->assertEquals(403, $status_code, "The unprivileged user should not be able to access this admin page: $title.");
}

// Finally check all URLs with the authenticated, privileged user.
// This checks privileged users can access these pages.
$this->drupalLogin($userTripalAdmin);
$this->assertTrue($this->drupalUserIsLoggedIn($userTripalAdmin), "The privileged user should be logged in.");
$this->assertTrue($userTripalAdmin->hasPermission('administer tripal'), "The privileged user should have the 'administer tripal' permission.");
foreach ($urls as $title => $path) {
$html = $this->drupalGet($path);
$status_code = $session->getStatusCode();
$this->assertEquals(200, $status_code, "The privileged user should be able to access this admin page: $title which should be at '$path'.");
}

// Test that the Tripal admin menu includes the above links.
// We use try/catch here because WebAssert throws exceptions which are not very readable.
$assert = $this->assertSession();
$html = $this->drupalGet('admin/tripal');
unset($urls['Tripal']);
foreach ($urls as $label => $path) {
// -- Find links with the label.
try {
$assert->linkExists($label, 0);
}
catch (Exception $e) {
$this->assertTrue(FALSE, "The '$label' link should exist in the Tripal admin listing.");
}

// -- Find links with the URL/path.
try {
$assert->linkByHrefExists($path, 0);
}
catch (Exception $e) {
$this->assertTrue(FALSE, "The '$path' link should exist in the Tripal admin listing.");
}
}
}

}
8 changes: 4 additions & 4 deletions tripaldocker/Dockerfile-php8.1-pgsql13
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
FROM php:8.1-apache-bullseye

ARG drupalversion='10.0.x-dev'
ARG drupalversion='~10.1.0'
ARG modules='devel devel_php'
ARG chadoschema='chado'
ARG installchado=TRUE

# Label docker image
LABEL drupal.version=${drupalversion}
LABEL drupal.stability="development"
LABEL drupal.stability="production"
LABEL tripal.version="4.x-dev"
LABEL tripal.stability="development"
LABEL os.version="bullseye"
Expand Down Expand Up @@ -178,7 +178,7 @@ RUN cd /var/www/drupal \
--account-name=drupaladmin \
--account-pass=some_admin_password \
--site-mail="drupaladmin@localhost" \
--site-name="Tripal 4 on Drupal 10 DEVELOPMENT" \
--site-name="Tripal 4.x-dev on Drupal ${drupalversion}" \
&& service apache2 stop \
&& service postgresql stop

Expand Down Expand Up @@ -210,7 +210,7 @@ RUN mv /app/tripaldocker/init_scripts/supervisord.conf /etc/supervisord.conf \
&& mv /app/tripaldocker/default_files/xdebug/xdebug_toggle.sh /usr/bin/xdebug_toggle.sh \
&& echo "\$config['system.logging']['error_level'] = 'verbose';" >> /var/www/drupal/web/sites/default/settings.php

## Make global commands.
## Make global commands. Symlink for drupal9 is for backward compatibility.
RUN ln -s /var/www/drupal/vendor/phpunit/phpunit/phpunit /usr/local/bin/ \
&& ln -s /var/www/drupal/vendor/drush/drush/drush /usr/local/bin/ \
&& ln -s /var/www/drupal /var/www/drupal9
Expand Down
2 changes: 1 addition & 1 deletion tripaldocker/Dockerfile-php8.2-pgsql13
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ RUN mv /app/tripaldocker/init_scripts/supervisord.conf /etc/supervisord.conf \
&& mv /app/tripaldocker/default_files/xdebug/xdebug_toggle.sh /usr/bin/xdebug_toggle.sh \
&& echo "\$config['system.logging']['error_level'] = 'verbose';" >> /var/www/drupal/web/sites/default/settings.php

## Make global commands.
## Make global commands. Symlink for drupal9 is for backward compatibility.
RUN ln -s /var/www/drupal/vendor/phpunit/phpunit/phpunit /usr/local/bin/ \
&& ln -s /var/www/drupal/vendor/drush/drush/drush /usr/local/bin/ \
&& ln -s /var/www/drupal /var/www/drupal9
Expand Down
Loading

0 comments on commit e850e76

Please sign in to comment.