Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ on:
- '**.php'
- tools/phpcs/composer.json
- phpcs.xml.dist
- .github/workflows/phpcs.yml

jobs:
phpcs:
runs-on: ubuntu-latest
name: PHP_CodeSniffer

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -29,7 +30,7 @@ jobs:
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('tools/phpcs/composer.json') }}
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ on:
- ci/composer.json
- phpstan.ci.neon
- phpstan.neon.dist
- .github/workflows/phpstan.yml

jobs:
phpstan:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.4', '8.0', '8.3']
php-versions: ['8.1', '8.4']
prefer: ['prefer-stable', 'prefer-lowest']
name: PHPStan with PHP ${{ matrix.php-versions }} ${{ matrix.prefer }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -35,7 +36,7 @@ jobs:
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.json') }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- tools/phpunit/composer.json
- phpunit.xml.dist
- tests/docker-prepare.sh
- .github/workflows/phpunit.yml

env:
# On github CI machine creating the "/vendor" volume fails otherwise with: read-only file system: unknown
Expand All @@ -18,13 +19,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
civicrm-image-tags: [ '5-drupal-php8.1', '5-drupal-php7.4', '5.45-drupal-php7.4' ]
civicrm-image-tags: [ 'drupal', '5.55-drupal-php8.1' ]
name: PHPUnit with Docker image michaelmcandrew/civicrm:${{ matrix.civicrm-image-tags }}
env:
CIVICRM_IMAGE_TAG: ${{ matrix.civicrm-image-tags }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Pull images
run: docker compose -f tests/docker-compose.yml pull --quiet
- name: Start containers
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ The extension is licensed under [AGPL-3.0](LICENSE.txt).

## Requirements

* PHP v7.4+
* CiviCRM 5
* PHP v8.1+
* CiviCRM 5.55+

## Installation (Web UI)

Expand Down
4 changes: 2 additions & 2 deletions ci/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"sort-packages": true
},
"require": {
"civicrm/civicrm-core": "^5.55",
"civicrm/civicrm-packages": "^5.55"
"civicrm/civicrm-core": ">=5.55",
"civicrm/civicrm-packages": ">=5.55"
}
}
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "systopia/activity-entity",
"description": "Connect activities with other entities",
"type": "civicrm-ext",
"license": "AGPL-3.0-or-later",
"authors": [
Expand All @@ -13,9 +14,12 @@
"prefer-stable": true,
"config": {
"prepend-autoloader": false,
"sort-packages": true
"sort-packages": true,
"platform": {
}
},
"require": {
"php": "^8.1",
"webmozart/assert": "^1.11"
},
"scripts": {
Expand All @@ -40,7 +44,7 @@
"@php tools/phpcs/vendor/bin/phpcbf"
],
"phpstan": [
"@php tools/phpstan/vendor/bin/phpstan"
"@php tools/phpstan/vendor/bin/phpstan -v"
],
"phpunit": [
"@php tools/phpunit/vendor/bin/simple-phpunit --coverage-text"
Expand Down
2 changes: 1 addition & 1 deletion info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<version>0.1-dev</version>
<develStage>dev</develStage>
<compatibility>
<ver>5.54</ver>
<ver>5.55</ver>
</compatibility>
<classloader>
<psr0 prefix="CRM_" path="."/>
Expand Down
6 changes: 4 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ parameters:
- Civi\Core\Event\GenericHookEvent
- CRM_Core_Config
- CRM_Core_DAO
earlyTerminatingMethodCalls:
CRM_Queue_Runner:
- runAllViaWeb
checkTooWideReturnTypesInProtectedAndPublicMethods: true
checkUninitializedProperties: true
checkMissingCallableSignature: true
Expand All @@ -38,7 +41,6 @@ parameters:

# Tests
- # Accessing results of API requests
message: "#^Offset '[^']+' does not exist on array[^\\|]+\\|null.$#"
identifier: offsetAccess.notFound
path: */tests/phpunit/Civi/**/*Test.php
- '#^Method Civi\\Fixtures\\[^\s]+Fixture::[^\s]+\(\) should return array{[^}]+} but returns array\|null.$#'
tmpDir: .phpstan
18 changes: 10 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
colors="true"
failOnRisky="true"
failOnWarning="true"
Expand All @@ -17,15 +17,17 @@
<directory>./tests/phpunit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>

<coverage>
<include>
<directory suffix=".php">CRM</directory>
<directory suffix=".php">Civi</directory>
<exclude>
<directory>CRM/*/DAO</directory>
</exclude>
</whitelist>
</filter>
</include>
<exclude>
<directory>CRM/ActivityEntity/DAO</directory>
</exclude>
</coverage>

<listeners>
<listener class="Civi\Test\CiviTestListener">
<arguments/>
Expand Down
4 changes: 3 additions & 1 deletion tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
civicrm:
image: michaelmcandrew/civicrm:${CIVICRM_IMAGE_TAG:-5-drupal}
image: michaelmcandrew/civicrm:${CIVICRM_IMAGE_TAG:-drupal}
environment:
- PROJECT_NAME=test
- BASE_URL=http://localhost
Expand All @@ -9,6 +9,8 @@ services:
- CIVICRM_DB_PASS=secret
- CIVICRM_DB_HOST=mysql
- CIVICRM_DB_PORT=3306
- CIVICRM_CRED_KEYS=aes-cbc::test
- CIVICRM_SIGN_KEYS=jwt-hs256::test
- CIVICRM_SITE_KEY=TEST_KEY
- DRUPAL_DB_NAME=test
- DRUPAL_DB_USER=root
Expand Down
8 changes: 8 additions & 0 deletions tests/docker-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ set -eu -o pipefail
EXT_DIR=$(dirname "$(dirname "$(realpath "$0")")")
EXT_NAME=$(basename "$EXT_DIR")

if ! type git >/dev/null 2>&1; then
apt -y update
apt -y install git
fi

# Prevent this git error: The repository does not have the correct ownership and git refuses to use it
git config --global --add safe.directory "/var/www/html/sites/default/files/civicrm/ext/$EXT_NAME"

i=0
while ! mysql -h "$CIVICRM_DB_HOST" -P "$CIVICRM_DB_PORT" -u "$CIVICRM_DB_USER" --password="$CIVICRM_DB_PASS" -e 'SELECT 1;' >/dev/null 2>&1; do
i=$((i+1))
Expand Down
3 changes: 2 additions & 1 deletion tests/phpunit/Civi/Fixtures/ActivityFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ final class ActivityFixture {
* @throws \CRM_Core_Exception
*/
public static function addFixture(array $values = []): array {
// @phpstan-ignore return.type
return Activity::create()->setValues([
'activity_type_id' => 1,
'source_contact_id' => 1,
] + $values)->execute()->first();
] + $values)->execute()->single();
}

}
3 changes: 2 additions & 1 deletion tests/phpunit/Civi/Fixtures/GroupFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ final class GroupFixture {
* @throws \CRM_Core_Exception
*/
public static function addFixture(array $values = []): array {
// @phpstan-ignore return.type
return Group::create()->setValues([
'title' => 'Test',
] + $values)->execute()->first();
] + $values)->execute()->single();
}

}
Loading