diff --git a/.editorconfig b/.editorconfig index 6537ca4..dd9a2b5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,9 +3,9 @@ root = true [*] charset = utf-8 end_of_line = lf -insert_final_newline = true -indent_style = space indent_size = 4 +indent_style = space +insert_final_newline = true trim_trailing_whitespace = true [*.md] diff --git a/.gitattributes b/.gitattributes index 8d3f3b4..82c80c7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,13 +1,22 @@ -* text=auto - # Path-based git attributes # https://git-scm.com/docs/gitattributes +* text=auto # Ignore all test and documentation with "export-ignore". -/.editorconfig export-ignore -/.gitattributes export-ignore -/.github export-ignore -/.gitignore export-ignore -/phpunit.xml export-ignore -/rector.php export-ignore -/tests export-ignore +/.github export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/phpunit.xml.dist export-ignore +/art export-ignore +/docs export-ignore +/tests export-ignore +/.editorconfig export-ignore +/.php_cs.dist.php export-ignore +/psalm.xml export-ignore +/psalm.xml.dist export-ignore +/testbench.yaml export-ignore +/UPGRADING.md export-ignore +/phpstan.neon.dist export-ignore +/phpstan-baseline.neon export-ignore +/docker export-ignore +/docker-compose.yml export-ignore diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..721c28d --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,32 @@ +name: Dependabot Auto-Merge +on: pull_request_target + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v2 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Auto-merge Dependabot PRs for semver-minor updates + if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' }} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Auto-merge Dependabot PRs for semver-patch updates + if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..74a756e --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,47 @@ +name: Static Analysis + +on: + push: + paths: + - '**.php' + - 'phpstan.neon.dist' + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + coverage: none + + - name: Install composer dependencies + uses: ramsey/composer-install@v3 + + - name: Run PHPStan + run: composer test:types + + ecs: + name: ECS + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + coverage: none + + - name: Install Dependencies + run: composer update --prefer-dist --no-interaction --no-progress --ansi + + - name: Run ECS + run: composer test:style diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5906d50..7e6787a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,24 +2,27 @@ name: Tests on: push: + branches: [main] + pull_request: + branches: [main] jobs: - setup: + test: runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: - os: [ ubuntu-latest ] - php: [ 8.2, 8.3 ] - laravel: [ 10.*, 11.* ] - stability: [ prefer-lowest, prefer-stable ] + os: [ubuntu-latest] + php: [8.4, 8.3] + laravel: [12.*, 11.*] + stability: [prefer-lowest, prefer-stable] include: - - laravel: 10.* - testbench: 8.* + - laravel: 12.* + testbench: 10.* - laravel: 11.* testbench: 9.* - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - name: Checkout code @@ -28,13 +31,17 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - extensions: oauth - coverage: none php-version: ${{ matrix.php }} + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Install Composer dependencies + - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --ansi composer update --${{ matrix.stability }} --prefer-dist --no-interaction --ansi - name: Execute tests diff --git a/.gitignore b/.gitignore index dd14e30..72bb0c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,15 @@ +/.idea /build -composer.lock -vendor +/vendor +/.php_cs.cache +/composer.lock +/phpunit.xml +/phpstan.neon +.php_cs +.php_cs.cache .phpunit.cache -.idea +.php-cs-fixer.cache +coverage +docs +node_modules +testbench.yaml diff --git a/composer.json b/composer.json index 3000523..ad623aa 100644 --- a/composer.json +++ b/composer.json @@ -4,14 +4,15 @@ "type": "library", "license": "MIT", "require": { - "php": "^8.2", - "illuminate/support": "^10.0 || ^11.0", - "illuminate/contracts": "^10.0 || ^11.0" + "php": "^8.3", + "illuminate/support": "^11.0 || ^12.0", + "illuminate/contracts": "^11.0 || ^12.0" }, "require-dev": { - "pestphp/pest": "^2.33", - "worksome/coding-style": "^2.8", - "mockery/mockery": "^1.6" + "mockery/mockery": "^1.6", + "orchestra/testbench": "^9.12 || ^10.1", + "pestphp/pest": "^3.1", + "worksome/coding-style": "^3.2" }, "autoload": { "psr-4": { @@ -26,10 +27,12 @@ "scripts": { "lint": "vendor/bin/ecs --fix", "test:unit": "vendor/bin/pest", + "test:types": "vendor/bin/phpstan analyse", "test:coverage": "vendor/bin/pest --coverage --min=95", "test:style": "vendor/bin/ecs", "test": [ "@test:style", + "@test:types", "@test:unit" ] }, diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f23f2c2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +services: + php: + build: ./docker + volumes: + - .:/var/www/html + environment: + - XDEBUG_MODE=${XDEBUG_MODE:-off} + - XDEBUG_CONFIG=${XDEBUG_CONFIG:-client_host=host.docker.internal} + composer: + build: ./docker + entrypoint: ["composer"] + volumes: + - .:/var/www/html diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..172cdec --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,11 @@ +FROM php:8.3-cli-alpine + +RUN apk add --no-cache $PHPIZE_DEPS linux-headers +RUN pecl install xdebug +RUN docker-php-ext-enable xdebug + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +WORKDIR /var/www/html + +ENTRYPOINT ["php"] diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..e69de29 diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..809c287 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,19 @@ +includes: + - ./vendor/worksome/coding-style/larastan.neon + - phpstan-baseline.neon + +parameters: + level: 5 + paths: + - src + - config + tmpDir: build/phpstan + checkModelProperties: true + parallel: + processTimeout: 300.0 + + ignoreErrors: + - + identifier: larastan.noEnvCallsOutsideOfConfig + path: config + reportUnmatched: false diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..7210b2e --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,14 @@ + + + + + tests + + + diff --git a/src/CdnHeadersManager.php b/src/CdnHeadersManager.php index b540f8f..d9124f2 100644 --- a/src/CdnHeadersManager.php +++ b/src/CdnHeadersManager.php @@ -1,5 +1,7 @@ app->singleton( CdnHeadersManager::class, - static fn(Container $container) => new CdnHeadersManager($container) + static fn (Container $container) => new CdnHeadersManager($container) ); $this->app->singleton( CdnHeadersProvider::class, - static fn(Container $app) => $app->get(CdnHeadersManager::class)->driver() + static fn (Container $app) => $app->get(CdnHeadersManager::class)->driver() ); } diff --git a/src/Contracts/CdnHeadersProvider.php b/src/Contracts/CdnHeadersProvider.php index 0629b74..19b8325 100644 --- a/src/Contracts/CdnHeadersProvider.php +++ b/src/Contracts/CdnHeadersProvider.php @@ -1,5 +1,7 @@