Add extension template with PHPStan, PHPUnit and phpcs
This commit is contained in:
parent
b4c6581d4f
commit
8cd928caa9
22 changed files with 825 additions and 1 deletions
42
.github/workflows/phpcs.yml
vendored
Normal file
42
.github/workflows/phpcs.yml
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
name: PHP_CodeSniffer
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '**.php'
|
||||
- tools/phpcs/composer.json
|
||||
- phpcs.xml.dist
|
||||
|
||||
jobs:
|
||||
phpcs:
|
||||
runs-on: ubuntu-latest
|
||||
name: PHP_CodeSniffer
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: 8.1
|
||||
coverage: none
|
||||
tools: cs2pr
|
||||
env:
|
||||
fail-fast: true
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('tools/phpcs/composer.json') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer composer-phpcs -- update --no-progress --prefer-dist
|
||||
|
||||
- name: Run PHP_CodeSniffer
|
||||
run: composer phpcs -- -q --report=checkstyle | cs2pr
|
52
.github/workflows/phpstan.yml
vendored
Normal file
52
.github/workflows/phpstan.yml
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
name: PHPStan
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '**.php'
|
||||
- composer.json
|
||||
- tools/phpstan/composer.json
|
||||
- ci/composer.json
|
||||
- phpstan.ci.neon
|
||||
- phpstan.neon.dist
|
||||
|
||||
jobs:
|
||||
phpstan:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ['7.4', '8.0', '8.1']
|
||||
prefer: ['prefer-stable', 'prefer-lowest']
|
||||
name: PHPStan with PHP ${{ matrix.php-versions }} ${{ matrix.prefer }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
coverage: none
|
||||
env:
|
||||
fail-fast: true
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.json') }}
|
||||
restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
composer update --no-progress --prefer-dist --${{ matrix.prefer }} &&
|
||||
composer composer-phpunit -- update --no-progress --prefer-dist &&
|
||||
composer composer-phpstan -- update --no-progress --prefer-dist --optimize-autoloader &&
|
||||
composer --working-dir=ci update --no-progress --prefer-dist --${{ matrix.prefer }} --optimize-autoloader --ignore-platform-req=ext-gd
|
||||
|
||||
- name: Run PHPStan
|
||||
run: composer phpstan -- analyse -c phpstan.ci.neon
|
37
.github/workflows/phpunit.yml
vendored
Normal file
37
.github/workflows/phpunit.yml
vendored
Normal file
|
@ -0,0 +1,37 @@
|
|||
name: PHPUnit
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '**.php'
|
||||
- composer.json
|
||||
- tools/phpunit/composer.json
|
||||
- phpunit.xml.dist
|
||||
- tests/docker-prepare.sh
|
||||
|
||||
env:
|
||||
# On github CI machine creating the "/vendor" volume fails otherwise with: read-only file system: unknown
|
||||
BIND_VOLUME_PERMISSIONS: rw
|
||||
|
||||
jobs:
|
||||
phpunit:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
civicrm-image-tags: [ '5-drupal-php8.1', '5-drupal-php7.4', '5.56-drupal-php7.4' ]
|
||||
name: PHPUnit with Docker image michaelmcandrew/civicrm:${{ matrix.civicrm-image-tags }}
|
||||
env:
|
||||
CIVICRM_IMAGE_TAG: ${{ matrix.civicrm-image-tags }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Pull images
|
||||
run: docker compose -f tests/docker-compose.yml pull --quiet
|
||||
- name: Start containers
|
||||
run: docker compose -f tests/docker-compose.yml up -d
|
||||
- name: Prepare environment
|
||||
run: docker compose -f tests/docker-compose.yml exec civicrm sites/default/files/civicrm/ext/de.systopia.twingle/tests/docker-prepare.sh
|
||||
- name: Run PHPUnit
|
||||
run: docker compose -f tests/docker-compose.yml exec civicrm sites/default/files/civicrm/ext/de.systopia.twingle/tests/docker-phpunit.sh
|
||||
- name: Remove containers
|
||||
run: docker compose -f tests/docker-compose.yml down -v
|
Loading…
Add table
Add a link
Reference in a new issue