From d87c13c0d5dab6b681a35dd215de97e9fe8ae7cb Mon Sep 17 00:00:00 2001 From: Thibaut Selingue Date: Fri, 26 Apr 2024 10:44:44 +0200 Subject: [PATCH] chore(actions): add test github action --- .editorconfig | 15 +++++++ .github/workflows/test.yml | 42 +++++++++++++++++++ .gitignore | 1 + DependencyInjection/Configuration.php | 2 +- .../EmailReportSubscriberTest.php | 2 +- composer.json | 13 +++++- phpstan.neon.dist | 5 +++ phpunit.xml.dist | 2 +- 8 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/workflows/test.yml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..89ded63 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{js,json,vue,css,less,scss}] +indent_size = 2 + +[Makefile] +indent_style = tab diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..cba409c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,42 @@ +name: Tests + +on: + push: + branches: ["master"] + pull_request: + branches: ["*"] + +permissions: + contents: read + +jobs: + tests: + + strategy: + matrix: + php_version: ["7.4", "8.0", "8.1", "8.2", "8.3"] + + runs-on: ubuntu-latest + container: + image: "lephare/php:${{ matrix.php_version }}" + env: + XDEBUG_MODE: coverage + + steps: + - uses: actions/checkout@v3 + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Install dependencies (PHP ${{ matrix.php_version }}) + run: | + composer config --global cache-dir .composer + composer install --prefer-dist --no-interaction --no-progress + + - name: Coding Style (PHP ${{ matrix.php_version }}) + run: | + composer run-script lint:ci + composer run-script analyse + + - name: Unit Tests (PHP ${{ matrix.php_version }}) + run: composer run-script test:ci diff --git a/.gitignore b/.gitignore index b47dbfa..7fef540 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor .idea *.cache +composer.lock diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 7f2baaf..a17088f 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -17,7 +17,7 @@ public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('lephare_import'); - /** @var ArrayNodeDefinition */ + /** @var ArrayNodeDefinition $rootNode */ $rootNode = $treeBuilder->getRootNode(); $rootNode diff --git a/Tests/EventSubscriber/EmailReportSubscriberTest.php b/Tests/EventSubscriber/EmailReportSubscriberTest.php index 8da51fc..8ef59c7 100644 --- a/Tests/EventSubscriber/EmailReportSubscriberTest.php +++ b/Tests/EventSubscriber/EmailReportSubscriberTest.php @@ -148,7 +148,7 @@ public function testPostExecuteWithEmailRecipients(): void $this->createSubscriber()->onPostExecute($event); } - public function provideEmails(): iterable + public static function provideEmails(): iterable { $f = Factory::create(); diff --git a/composer.json b/composer.json index 03e0af3..744749d 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ }, "extra": { "branch-alias": { - "dev-main": "2.0-dev" + "dev-master": "2.0-dev" } }, "config": { @@ -35,14 +35,25 @@ }, "require-dev": { "doctrine/collections": "^1.6|^2.0", + "fakerphp/faker": "^1.23", "friendsofphp/php-cs-fixer": "^3.3", + "phpspec/prophecy-phpunit": "^2.2", "phpstan/phpstan": "^1.4", + "phpunit/phpunit": "^9.6", "symfony/config": "^5.4|^6.0|^7.0", "symfony/event-dispatcher": "^5.4|^6.0|^7.0", "symfony/mailer": "^5.4|^6.0|^7.0", "symfony/maker-bundle": "^1.36", "symfony/twig-bridge": "^5.4|^6.0|^7.0" }, + "scripts": { + "analyse": "./vendor/bin/phpstan analyse --no-progress", + "lint": "./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --dry-run", + "lint:ci": "@lint:fix --using-cache=no --dry-run", + "lint:fix": "./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php", + "test:ci": "@test --colors=never --coverage-text", + "test": "./vendor/bin/phpunit" + }, "suggest": { "symfony/mailer": "to enable support for email reports", "symfony/twig-bridge": "to enable support for templated emails reports" diff --git a/phpstan.neon.dist b/phpstan.neon.dist index a0b8fc4..11b80e7 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -9,4 +9,9 @@ parameters: - vendor/ - node_modules/ - Resources/ + ignoreErrors: + - + message: '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::.+\(\)#' + paths: + - DependencyInjection/Configuration.php tmpDir: .phpstan.cache diff --git a/phpunit.xml.dist b/phpunit.xml.dist index df7fed1..62d65b9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ - +