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

Github Action : PHP (PHPCSFixer / PHPStan / PHPUnit) #1

Merged
merged 1 commit into from
Sep 27, 2023
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
116 changes: 116 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: PHP
on:
push:
branches:
- master
pull_request:

jobs:
php-cs-fixer:
name: PHP CS Fixer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: xml

- uses: actions/checkout@v4

- name: Validate composer config
run: composer validate --strict

- name: Composer Install
run: composer global require friendsofphp/php-cs-fixer

- name: Add environment path
run: export PATH="$PATH:$HOME/.composer/vendor/bin"

- name: Run PHPCSFixer
run: php-cs-fixer fix --dry-run --diff

phpstan:
name: PHP Static Analysis
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: xml

- uses: actions/checkout@v4

- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

- name: Run phpstan
run: ./vendor/bin/phpstan analyse -c phpstan.neon.dist

phpunit:
name: PHPUnit
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '7.1'
- '7.2'
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
- '8.3'
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: xml
coverage: ${{ (matrix.php == '8.1') && 'xdebug' || 'none' }}

- uses: actions/checkout@v4

- name: Install dependencies
run: composer install --ansi --prefer-dist --no-interaction --no-progress

- name: Run PHPUnit
if: matrix.php != '8.1'
run: ./vendor/bin/phpunit -c phpunit.xml.dist

- name: Run PHPUnit (w CodeCoverage)
if: matrix.php == '8.1'
run: XDEBUG_MODE=coverage ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/clover.xml

- name: Upload coverage results to Coveralls
if: matrix.php == '8.1'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
chmod +x php-coveralls.phar
php php-coveralls.phar --coverage_clover=build/clover.xml --json_path=build/coveralls-upload.json -vvv

#roave-backwards-compatibility-check:
# name: Roave Backwards Compatibility Check
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: "Check for BC breaks"
# run: docker run -u $(id -u) -v $(pwd):/app nyholm/roave-bc-check-ga
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.phpunit.cache
.phpunit.result.cache
.php-cs-fixer.cache
composer.lock

vendor/
45 changes: 45 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

$config = new PhpCsFixer\Config();

$config
->setUsingCache(true)
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'array_indentation' => true,
'cast_spaces' => [
'space' => 'single',
],
'combine_consecutive_issets' => true,
'concat_space' => [
'spacing' => 'one',
],
'error_suppression' => [
'mute_deprecation_error' => false,
'noise_remaining_usages' => false,
'noise_remaining_usages_exclude' => [],
],
'function_to_constant' => false,
'global_namespace_import' => true,
'method_chaining_indentation' => true,
'no_alias_functions' => false,
'no_superfluous_phpdoc_tags' => false,
'non_printable_character' => [
'use_escape_sequences_in_strings' => true,
],
'phpdoc_align' => [
'align' => 'left',
],
'phpdoc_summary' => false,
'protected_to_private' => false,
'self_accessor' => false,
'yoda_style' => false,
'single_line_throw' => false,
'no_alias_language_construct_call' => false,
])
->getFinder()
->in(__DIR__)
->exclude('vendor');

return $config;
16 changes: 12 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "phpoffice/wmf",
"description": "WMF - Manipulate WMF Images",
"keywords": ["PHP", "wmf", "emf", "image"],
"homepage": "https://phpoffice.github.io/WMF/",
"type": "library",
"require-dev": {
"phpunit/phpunit": "10"
},
"license": "MIT",
"autoload": {
"psr-4": {
Expand All @@ -20,5 +20,13 @@
"name": "Progi1984",
"homepage": "https://lefevre.dev"
}
]
],
"require": {
"php": "^7.1|^8.0",
"ext-gd": "*"
},
"require-dev": {
"phpunit/phpunit": "^7.0 || ^9.0",
"phpstan/phpstan": "^0.12.88 || ^1.0.0"
}
}
9 changes: 9 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
parameters:
level: 6
bootstrapFiles:
- vendor/autoload.php
paths:
- src
- tests
reportUnmatchedIgnoredErrors: false
ignoreErrors:
File renamed without changes.
2 changes: 1 addition & 1 deletion src/WMF/Exception/WMFException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

class WMFException extends Exception
{
}
}
Loading