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
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.git
.idea
vendor/
civicrm-core/
.phpunit.result.cache
bin/civicrm/
bin/phpcbf.phar
bin/phpcs.phar
23 changes: 23 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Linters

on: pull_request

env:
GITHUB_BASE_REF: ${{ github.base_ref }}

jobs:
run-linters:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install phpcs
run: cd bin && ./install-php-linter

- name: Fetch target branch
run: git fetch -n origin ${GITHUB_BASE_REF}

- name: Run phpcs linter
run: git diff --diff-filter=d origin/${GITHUB_BASE_REF} --name-only -- '*.php' | xargs -r ./bin/phpcs.phar --standard=phpcs-ruleset.xml
96 changes: 96 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: PHPStan

on: pull_request

env:
GITHUB_BASE_REF: ${{ github.base_ref }}

jobs:
run-phpstan:

runs-on: ubuntu-latest
container: compucorp/civicrm-buildkit:1.3.1-php8.0

env:
CIVICRM_EXTENSIONS_DIR: site/web/sites/all/modules/civicrm/tools/extensions

services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Config mysql database as per CiviCRM requirement
run: echo "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));" | mysql -u root --password=root --host=mysql

- name: Composer version downgrade 2.2.5
run: composer self-update 2.2.5

- name: Install missing extension
run: sudo apt update && apt install -y php-bcmath

- name: Config amp
run : amp config:set --mysql_dsn=mysql://root:root@mysql:3306

- name: Build Drupal site
run: civibuild create drupal-clean --civi-ver 6.4.1 --cms-ver 7.100 --web-root $GITHUB_WORKSPACE/site

- uses: actions/checkout@v2
with:
path: ${{ env.CIVICRM_EXTENSIONS_DIR }}/io.compuco.paymentprocessingcore
fetch-depth: 0

- name: Enable Payment Processing Core extension
working-directory: ${{ env.CIVICRM_EXTENSIONS_DIR }}
run: cv en paymentprocessingcore

- name: Install extension dependencies
working-directory: ${{ env.CIVICRM_EXTENSIONS_DIR }}/io.compuco.paymentprocessingcore
run: composer install

- name: Fetch target branch
working-directory: ${{ env.CIVICRM_EXTENSIONS_DIR }}/io.compuco.paymentprocessingcore
run: git fetch -n origin ${GITHUB_BASE_REF}

- name: Download PHPStan
run: |
curl -sL https://github.com/phpstan/phpstan/releases/download/1.12.10/phpstan.phar -o /tmp/phpstan.phar
chmod +x /tmp/phpstan.phar

- name: Run PHPStan
working-directory: ${{ env.CIVICRM_EXTENSIONS_DIR }}/io.compuco.paymentprocessingcore
run: |
# Create phpstan.neon with CI-specific paths
cat > phpstan-ci.neon <<EOF
includes:
- phpstan-baseline.neon
- vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
level: 9
paths:
- Civi
- CRM
- tests
excludePaths:
analyse:
- CRM/Paymentprocessingcore/DAO/*
- paymentprocessingcore.civix.php
- '*.mgd.php'
- tests/bootstrap.php
scanFiles:
- paymentprocessingcore.civix.php
- $GITHUB_WORKSPACE/site/web/sites/all/modules/civicrm/Civi.php
- tests/phpunit/BaseHeadlessTest.php
scanDirectories:
- CRM/Paymentprocessingcore/DAO
- $GITHUB_WORKSPACE/site/web/sites/all/modules/civicrm/Civi
- $GITHUB_WORKSPACE/site/web/sites/all/modules/civicrm/CRM
- $GITHUB_WORKSPACE/site/web/sites/all/modules/civicrm/api
- tests
EOF
php /tmp/phpstan.phar analyse -c phpstan-ci.neon --memory-limit=1G --error-format=github
72 changes: 72 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Tests

on: pull_request

jobs:
run-unit-tests:

runs-on: ubuntu-latest
container: compucorp/civicrm-buildkit:1.3.1-php8.0

env:
CIVICRM_EXTENSIONS_DIR: site/web/sites/all/modules/civicrm/tools/extensions
CIVICRM_SETTINGS_DIR: site/web/sites/default

services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Config mysql database as per CiviCRM requirement
run: echo "SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));" | mysql -u root --password=root --host=mysql

- name: Composer version downgrade 2.2.5
run: composer self-update 2.2.5

- name: Install missing extension
run: sudo apt update && apt install -y php-bcmath

- name: Config amp
run : amp config:set --mysql_dsn=mysql://root:root@mysql:3306

- name: Build Drupal site
run: civibuild create drupal-clean --civi-ver 6.4.1 --cms-ver 7.100 --web-root $GITHUB_WORKSPACE/site

- uses: actions/checkout@v2
with:
path: ${{ env.CIVICRM_EXTENSIONS_DIR }}/io.compuco.paymentprocessingcore

- name: Install extension dependencies
working-directory: ${{ env.CIVICRM_EXTENSIONS_DIR }}/io.compuco.paymentprocessingcore
run: composer install

- name: Enable Payment Processing Core extension
working-directory: ${{ env.CIVICRM_EXTENSIONS_DIR }}
run: cv en paymentprocessingcore

- name: Setup Test DB
run: echo "CREATE DATABASE civicrm_test;" | mysql -u root --password=root --host=mysql

- name: Update civicrm.settings.php
run: |
FILE_PATH="$GITHUB_WORKSPACE/site/web/sites/default/civicrm.settings.php"
INSERT_LINE="\$GLOBALS['_CV']['TEST_DB_DSN'] = 'mysql://root:root@mysql:3306/civicrm_test?new_link=true';"
TMP_FILE=$(mktemp)
while IFS= read -r line
do
echo "$line" >> "$TMP_FILE"
if [ "$line" = "<?php" ]; then
echo "$INSERT_LINE" >> "$TMP_FILE"
fi
done < "$FILE_PATH"
mv "$TMP_FILE" "$FILE_PATH"
echo "File modified successfully."

- name: Run phpunit tests
working-directory: ${{ env.CIVICRM_EXTENSIONS_DIR }}/io.compuco.paymentprocessingcore
run: phpunit9
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/vendor/
.env
civicrm-core/
.idea
.claude/
.phpunit.result.cache
bin/civicrm/
bin/phpcbf.phar
bin/phpcs.phar
phpstan_errors.log
phpstan_output.log
*test_output.log
lint_output.log
Loading