Skip to content

Commit c388690

Browse files
authored
Merge pull request #79 from systopia/chore-update-from-extension-template
chore: Apply changes from extension template
2 parents 950a71c + a72c07e commit c388690

10 files changed

+56
-18
lines changed

.github/workflows/phpcs.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
name: PHP_CodeSniffer
1414

1515
steps:
16-
- uses: actions/checkout@v3
16+
- uses: actions/checkout@v4
1717

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

3131
- name: Cache dependencies
32-
uses: actions/cache@v3
32+
uses: actions/cache@v4
3333
with:
3434
path: ${{ steps.composer-cache.outputs.dir }}
3535
key: ${{ runner.os }}-composer-${{ hashFiles('tools/phpcs/composer.json') }}

.github/workflows/phpstan.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
name: PHPStan with PHP ${{ matrix.php-versions }} ${{ matrix.prefer }}
2121

2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424

2525
- name: Setup PHP
2626
uses: shivammathur/setup-php@v2
@@ -35,18 +35,18 @@ jobs:
3535
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
3636

3737
- name: Cache dependencies
38-
uses: actions/cache@v3
38+
uses: actions/cache@v4
3939
with:
4040
path: ${{ steps.composer-cache.outputs.dir }}
4141
key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.json') }}
4242
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
4343

4444
- name: Install dependencies
4545
run: |
46-
composer update --no-progress --prefer-dist --${{ matrix.prefer }} &&
46+
composer update --no-progress --prefer-dist --${{ matrix.prefer }} --optimize-autoloader &&
4747
composer composer-phpunit -- update --no-progress --prefer-dist &&
4848
composer composer-phpstan -- update --no-progress --prefer-dist --optimize-autoloader &&
49-
composer --working-dir=ci update --no-progress --prefer-dist --${{ matrix.prefer }} --optimize-autoloader --ignore-platform-req=ext-gd
49+
composer --working-dir=ci update --no-progress --prefer-dist --${{ matrix.prefer }} --ignore-platform-req=ext-gd
5050
5151
- name: Run PHPStan
5252
run: composer phpstan -- analyse -c phpstan.ci.neon

.github/workflows/phpunit.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
- composer.json
88
- tools/phpunit/composer.json
99
- phpunit.xml.dist
10+
- tests/docker-prepare.sh
1011

1112
env:
1213
# On github CI machine creating the "/vendor" volume fails otherwise with: read-only file system: unknown
@@ -23,7 +24,7 @@ jobs:
2324
CIVICRM_IMAGE_TAG: ${{ matrix.civicrm-image-tags }}
2425

2526
steps:
26-
- uses: actions/checkout@v3
27+
- uses: actions/checkout@v4
2728
- name: Pull images
2829
run: docker compose -f tests/docker-compose.yml pull --quiet
2930
- name: Start containers

ci/composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"civicrm/composer-compile-plugin": false,
77
"civicrm/composer-downloads-plugin": true,
88
"cweagans/composer-patches": true
9-
}
9+
},
10+
"sort-packages": true
1011
},
1112
"require": {
1213
"civicrm/civicrm-core": "^5.54"

composer.json

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
{
22
"name": "systopia/de.systopia.civioffice",
3+
"type": "civicrm-ext",
4+
"license": "AGPL-3.0-or-later",
35
"description": "CiviCRM integration for various exchangeable office suites",
4-
"license": "AGPL-3.0",
56
"authors": [
67
{
7-
"name": "SYSTOPIA",
8-
"email": "[email protected]"
8+
"name": "SYSTOPIA GmbH",
9+
"email": "[email protected]",
10+
"homepage": "https://www.systopia.de"
911
}
1012
],
13+
"minimum-stability": "dev",
14+
"prefer-stable": true,
15+
"config": {
16+
"prepend-autoloader": false,
17+
"sort-packages": true
18+
},
1119
"require": {
1220
"beberlei/assert": "^3"
1321
},
@@ -33,7 +41,7 @@
3341
"@php tools/phpcs/vendor/bin/phpcbf"
3442
],
3543
"phpstan": [
36-
"@php tools/phpstan/vendor/bin/phpstan"
44+
"@php tools/phpstan/vendor/bin/phpstan -v"
3745
],
3846
"phpunit": [
3947
"@php tools/phpunit/vendor/bin/simple-phpunit --coverage-text"

phpstan.neon.dist

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ parameters:
44
- Civi
55
#- CRM
66
- tests
7+
#- civioffice.php
78
excludePaths:
89
analyse:
9-
- CRM/*/DAO/*
10+
- CRM/Civioffice/DAO/*
1011
- tests/phpunit/bootstrap.php
1112
scanFiles:
1213
- civioffice.civix.php
@@ -16,11 +17,12 @@ parameters:
1617
- tools/phpunit/vendor/bin/.phpunit/phpunit/src/Framework
1718
bootstrapFiles:
1819
- tools/phpunit/vendor/bin/.phpunit/phpunit/vendor/autoload.php
19-
- vendor/autoload.php
2020
- phpstanBootstrap.php
2121
level: 9
2222
universalObjectCratesClasses:
2323
- Civi\Core\Event\GenericHookEvent
24+
- CRM_Core_Config
25+
- CRM_Core_DAO
2426
checkTooWideReturnTypesInProtectedAndPublicMethods: true
2527
checkUninitializedProperties: true
2628
checkMissingCallableSignature: true

phpstanBootstrap.php

+4
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@
4141
}
4242
}
4343
}
44+
45+
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
46+
require_once __DIR__ . '/vendor/autoload.php';
47+
}

tests/docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
version: "3"
21
services:
32
civicrm:
4-
image: michaelmcandrew/civicrm:${CIVICRM_IMAGE_TAG:-5-drupal-php8.1}
3+
image: michaelmcandrew/civicrm:${CIVICRM_IMAGE_TAG:-5-drupal}
54
environment:
65
- PROJECT_NAME=test
76
- BASE_URL=http://localhost
@@ -10,6 +9,7 @@ services:
109
- CIVICRM_DB_PASS=secret
1110
- CIVICRM_DB_HOST=mysql
1211
- CIVICRM_DB_PORT=3306
12+
- CIVICRM_SITE_KEY=TEST_KEY
1313
- DRUPAL_DB_NAME=test
1414
- DRUPAL_DB_USER=root
1515
- DRUPAL_DB_PASS=secret

tests/docker-phpunit.sh

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ if [ ! -e tools/phpunit/vendor/bin ]; then
99
"$SCRIPT_DIR/docker-prepare.sh"
1010
fi
1111

12+
# CIVICRM_SMARTY_AUTOLOAD_PATH is not set in the container's civicrm.settings.php so we have to do it here.
13+
# Otherwise this results in this error:
14+
# Fatal error: Cannot declare class Smarty, because the name is already in use in /var/www/html/sites/all/modules/civicrm/packages/smarty5/Smarty.php on line 4
15+
smarty=$(printf '%s\n' /var/www/html/sites/all/modules/civicrm/packages/smarty* | sort -r | head -n1)
16+
if [ -e "$smarty/Smarty.php" ]; then
17+
export CIVICRM_SMARTY_AUTOLOAD_PATH="$smarty/Smarty.php"
18+
elif [ -e "$smarty/vendor/autoload.php" ]; then
19+
export CIVICRM_SMARTY_AUTOLOAD_PATH="$smarty/vendor/autoload.php"
20+
fi
21+
1222
export XDEBUG_MODE=coverage
1323
# TODO: Remove when not needed, anymore.
1424
# In Docker container with CiviCRM 5.5? all deprecations are reported as direct

tests/docker-prepare.sh

+14-2
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,25 @@ else
2727
-i /var/www/html/sites/default/civicrm.settings.php
2828
civicrm-docker-install
2929

30-
cv ext:enable "$EXT_NAME"
30+
# Avoid this error:
31+
# The autoloader expected class "Civi\ActionSchedule\Mapping" to be defined in
32+
# file "[...]/Civi/ActionSchedule/Mapping.php". The file was found but the
33+
# class was not in it, the class name or namespace probably has a typo.
34+
#
35+
# Necessary for CiviCRM 5.66.0 - 5.74.x.
36+
# https://github.com/civicrm/civicrm-core/blob/5.66.0/Civi/ActionSchedule/Mapping.php
37+
if [ -e /var/www/html/sites/all/modules/civicrm/Civi/ActionSchedule/Mapping.php ] \
38+
&& grep -q '// Empty file' /var/www/html/sites/all/modules/civicrm/Civi/ActionSchedule/Mapping.php; then
39+
rm /var/www/html/sites/all/modules/civicrm/Civi/ActionSchedule/Mapping.php
40+
fi
3141

3242
# For headless tests these files need to exist.
3343
touch /var/www/html/sites/all/modules/civicrm/sql/test_data.mysql
3444
touch /var/www/html/sites/all/modules/civicrm/sql/test_data_second_domain.mysql
45+
46+
cv ext:enable "$EXT_NAME"
3547
fi
3648

3749
cd "$EXT_DIR"
38-
composer update --no-progress --prefer-dist --optimize-autoloader --no-dev
50+
composer update --no-progress --prefer-dist --optimize-autoloader
3951
composer composer-phpunit -- update --no-progress --prefer-dist

0 commit comments

Comments
 (0)