Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20240530 - next version #40

Merged
merged 14 commits into from
Jun 3, 2024
101 changes: 101 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Test
on: [pull_request]
env:
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_DATABASE: drupal
MYSQL_ROOT_PASSWORD: root
SIMPLETEST_DB: "mysql://root:root@localhost:3306/drupal"
SIMPLETEST_BASE_URL: "http://127.0.0.1:8080"

jobs:
testing:
name: Drupal ${{ matrix.drupal-core }} - PHP ${{ matrix.php-versions }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
drupal-core: ['10.2.x', '10.3.x']
php-versions: ['8.2', '8.3']
steps:
- name: Checkout Drupal core
uses: actions/checkout@v2
with:
repository: drupal/drupal
ref: ${{ matrix.drupal-core }}

- name: Checkout module
uses: actions/checkout@v2
with:
path: modules/custom/ocha_ai

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
coverage: xdebug

- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Drupal core dependencies
run: |
composer --no-interaction --no-progress --prefer-dist --optimize-autoloader install

- name: Install module dependencies
run: |
composer --no-interaction --no-progress require \
drupal/datetime_range_timezone drupal/date_recur

- name: Patch Drupal - https://www.drupal.org/project/drupal/issues/3004425
run: |
curl https://www.drupal.org/files/issues/2021-12-25/3004425-41.patch | patch -p1

- name: Install Coder module
run: |
composer --dev --no-interaction --no-progress require \
drupal/coder:8.3.13 phpunit/phpunit

- name: Define DRUPAL_ROOT env variable
run: |
echo "DRUPAL_ROOT=$HOME/drupal" >> $GITHUB_ENV

- name: Install drush
run: composer require "drush/drush ^12.0"

- name: Start MySql service
run: |
sudo /etc/init.d/mysql start

- name: Install Drupal
run: |
php -d sendmail_path=$(which true); vendor/bin/drush --yes -v \
site-install minimal --db-url="$SIMPLETEST_DB"
vendor/bin/drush en $DRUPAL_MODULE_NAME -y

- name: Run tests
run: |
vendor/bin/phpunit --bootstrap core/tests/bootstrap.php \
--coverage-clover ./clover.xml \
-c modules/custom/ocha_ai/phpunit.xml modules/custom/ocha_ai

- name: Monitor coverage for Drupal ${{ matrix.drupal-core }} - PHP ${{ matrix.php-versions }}
id: coveralls
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
status_context: Monitor coverage for Drupal ${{ matrix.drupal-core }} - PHP ${{ matrix.php-versions }}
comment_context: Monitor coverage for Drupal ${{ matrix.drupal-core }} - PHP ${{ matrix.php-versions }}
coverage_path: "./clover.xml"
threshold_alert: 0
threshold_warning: 50
threshold_metric: "lines"
comment_footer: false
10 changes: 10 additions & 0 deletions modules/ocha_ai_tag/src/Services/OchaAiTagTagger.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,14 @@ protected function getSimilarityScoreCutOff(array $similarity_scores, ?float $al
return min($cutoff, max($similarity_scores));
}

/**
* Clear the cache.
*/
public function clearCache(): self {
$cid = $this->getSetting(['plugins', 'embedding', 'plugin_id']);
$this->cacheBackend->delete($cid);

return $this;
}

}
26 changes: 26 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutChangesToGlobalState="true"
failOnWarning="true"
cacheResult="false">
<php>
<ini name="error_reporting" value="32767"/>
<ini name="memory_limit" value="-1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<env name="BROWSERTEST_OUTPUT_BASE_URL" value=""/>
</php>
<coverage includeUncoveredFiles="false"
processUncoveredFiles="false"
pathCoverage="false"
ignoreDeprecatedCodeUnits="true"
disableCodeCoverageIgnore="false">
<include>
<!-- Relative to this file! -->
<directory suffix=".php">src</directory>
<directory suffix=".module">.</directory>
</include>
</coverage>
</phpunit>
Loading
Loading