diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index c35a017..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,49 +0,0 @@ -version: 2.1 - -executors: - php83: - docker: - - image: skpr/php-cli:8.3-v2-latest - -workflows: - build: - jobs: - - build: - matrix: - parameters: - php: ["php83"] - composer-opts: ["", "--prefer-lowest"] - -jobs: - build: - parameters: - php: - type: executor - composer-opts: - type: string - executor: << parameters.php >> - working_directory: /data - steps: - - checkout - - restore_cache: - keys: - - deps-{{ arch }} - - run: - name: "Install Dependencies" - command: composer update --prefer-dist --no-progress --no-interaction << parameters.composer-opts >> - - save_cache: - key: deps-{{ arch }} - paths: - - vendor - - run: - name: "Lint" - command: ./bin/phpcs --runtime-set testVersion 8.0- - - run: - name: "Test" - command: | - mkdir -p ~/phpunit - ./bin/phpunit --log-junit ~/phpunit/phpunit.xml - - store_test_results: - path: ~/phpunit - - store_artifacts: - path: ~/phpunit diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3345fec --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,45 @@ +name: ๐Ÿ— Build + +on: + pull_request: + types: [ synchronize, opened, reopened, ready_for_review ] + push: + branches: [ main ] + +permissions: + checks: write + pull-requests: write + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + prefer_lowest: ["", "--prefer-lowest"] + container: + image: skpr/php-cli:8.4-dev-v2-latest + options: + --pull always + --user 1001:1001 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + show-progress: false + - name: ๐Ÿ“ฆ Composer Update + run: composer update --with-all-dependencies --prefer-dist --no-progress --no-interaction ${{ matrix.prefer_lowest }} + - name: ๐Ÿงน PHPCS + run: ./bin/phpcs --report=checkstyle -q | ./bin/cs2pr + - name: ๐Ÿงน PHPStan + run: ./bin/phpstan --error-format=github analyse -v + - name: โž• Add matcher + run: | + cat << 'EOF' > .github/phpunit-failure.json + {"problemMatcher":[{"owner":"phpunit-failure","severity":"error","pattern":[{"regexp":"##teamcity\\[testFailed[^\\]]*message='([^']*)'[^\\]]*details='/data/([^:]+):(\\d+)","message":1,"file":2,"line":3}]}]} + EOF + echo "::add-matcher::.github/phpunit-failure.json" + - name: โšก Run Tests + run: ./bin/phpunit --teamcity + - name: โž– Remove matcher + if: always() + run: echo "::remove-matcher owner=phpunit-failure::" diff --git a/composer.json b/composer.json index 73ec539..e14634f 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,16 @@ ], "require": { "php": "^8.1", - "phpunit/phpunit": "^10.5", - "symfony/console": "^6.4||^7" + "phpunit/phpunit": "^10.5||^11.5", + "symfony/console": "^6.4||^7.4" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", - "drupal/coder": "~8.3.12", - "phpcompatibility/php-compatibility": "^9.3" + "dealerdirect/phpcodesniffer-composer-installer": "^1.2", + "drupal/coder": "~8.3.31", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-deprecation-rules": "^2.0", + "staabm/annotate-pull-request-from-checkstyle": "^1.8" }, "autoload": { "psr-4": {"PhpUnitFinder\\": "src/"} diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..0524186 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,6 @@ +parameters: + paths: + - src + - tests + level: 6 + reportUnmatchedIgnoredErrors: false diff --git a/phpunit.xml b/phpunit.xml index 86e75cb..304454b 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,10 +1,5 @@ - - - + diff --git a/tests/Unit/FinderTest.php b/tests/Unit/FinderTest.php index 2a32874..f134711 100644 --- a/tests/Unit/FinderTest.php +++ b/tests/Unit/FinderTest.php @@ -14,20 +14,14 @@ class FinderTest extends TestCase { /** * A stub test. */ - public function testDiscovery() { + public function testDiscovery(): void { $command = new CommandTester(new FinderCommand()); $command->execute([ '--config-file' => dirname(__DIR__) . '/fixtures/phpunit.xml' ]); $output = $command->getDisplay(); - $this->assertNotNull($output); - if (method_exists($this, 'assertStringContainsString')) { - $this->assertStringContainsString('TestUnitTest.php', $output); - $this->assertStringContainsString('TestFunctionalTest.php', $output); - return; - } - $this->assertContains('TestUnitTest.php', $output); - $this->assertContains('TestFunctionalTest.php', $output); + $this->assertStringContainsString('TestUnitTest.php', $output); + $this->assertStringContainsString('TestFunctionalTest.php', $output); } } diff --git a/tests/fixtures/tests/Functional/TestFunctionalTest.php b/tests/fixtures/tests/Functional/TestFunctionalTest.php index 3ee4ed8..3765978 100644 --- a/tests/fixtures/tests/Functional/TestFunctionalTest.php +++ b/tests/fixtures/tests/Functional/TestFunctionalTest.php @@ -12,7 +12,7 @@ class TestFunctionalTest extends TestCase { /** * Tests something. */ - public function testSomething() { + public function testSomething(): void { $this->addToAssertionCount(1); } diff --git a/tests/fixtures/tests/Unit/TestUnitTest.php b/tests/fixtures/tests/Unit/TestUnitTest.php index 90f0829..e6a2e63 100644 --- a/tests/fixtures/tests/Unit/TestUnitTest.php +++ b/tests/fixtures/tests/Unit/TestUnitTest.php @@ -12,7 +12,7 @@ class TestUnitTest extends TestCase { /** * Tests something. */ - public function testSomething() { + public function testSomething(): void { $this->addToAssertionCount(1); }