diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..52f37d5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,52 @@ +name: Bug Report +description: Report an Issue or Bug with the Package +title: "[Bug]: " +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + We're sorry to hear you have a problem. Can you help us solve it by providing the following details. + - type: textarea + id: what-happened + attributes: + label: What happened? + description: What did you expect to happen? + placeholder: I cannot currently do X thing because when I do, it breaks X thing. + validations: + required: true + + - type: input + id: package-version + attributes: + label: Package Version + description: What version of our Package are you running? Please be as specific as possible + placeholder: 2.0.0 + validations: + required: true + - type: input + id: php-version + attributes: + label: PHP Version + description: What version of PHP are you running? Please be as specific as possible + placeholder: 8.2.0 + validations: + required: true + - type: input + id: laravel-version + attributes: + label: Laravel Version + description: What version of Laravel are you running? Please be as specific as possible + placeholder: 9.0.0 + validations: + required: true + - type: dropdown + id: operating-systems + attributes: + label: Which operating systems does with happen with? + description: You may select more than one. + multiple: true + options: + - macOS + - Windows + - Linux diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index f7e6494..1e86373 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,11 +1,8 @@ blank_issues_enabled: false contact_links: - - name: Ask a question - url: https://github.com/codebar-ag/laravel-prerender/discussions/new?category=q-a - about: Ask the community for help - - name: Request a feature - url: https://github.com/codebar-ag/laravel-prerender/discussions/new?category=ideas - about: Share ideas for new features - - name: Report a bug + - name: Questions & Feature Requests url: https://github.com/codebar-ag/laravel-prerender/issues/new - about: Report a reproducable bug + about: Ask the community for help + - name: Report a security issue + url: https://github.com/codebar-ag/laravel-prerender/security/policy + about: Learn how to notify us for sensitive bugs diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ce9cb2a..ae885d2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,60 +1,59 @@ name: run-tests -on: [push, pull_request] +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] jobs: test: runs-on: ${{ matrix.os }} strategy: fail-fast: true + max-parallel: 1 matrix: - os: [ubuntu-latest] - php: [7.2, 7.3, 7.4, 8.0] - laravel: [6, 7, 8] - dependency-version: [prefer-lowest, prefer-stable] + os: [ ubuntu-latest, windows-latest ] + php: [ 8.2, 8.3 ] + laravel: [ 10.* ] + stability: [ prefer-lowest, prefer-stable ] include: - - laravel: 8 - testbench: 6.* - - laravel: 7 - testbench: 5.* - - laravel: 6 - testbench: 4.* - exclude: - - laravel: 6 - php: 8.0 - - laravel: 7 - php: 8.0 - - laravel: 8 - php: 7.2 - - laravel: 8 - php: 7.3 - - laravel: 8 - php: 8.0 - dependency-version: prefer-lowest - - name: P${{ matrix.php }} - L${{ matrix.laravel }}.* - ${{ matrix.dependency-version }} - ${{ matrix.os }} + - laravel: 10.* + testbench: 8.* + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - name: Checkout code - uses: actions/checkout@v2 - - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.composer/cache/files - key: dependencies-laravel-${{ matrix.laravel }}.*-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + uses: actions/checkout@v3 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick - coverage: pcov + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + 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 dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}.*" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: Set phpunit.xml + run: cp phpunit.xml.dist phpunit.xml - name: Execute tests - run: vendor/bin/phpunit + run: vendor/bin/pest + + - name: Store test reports + uses: actions/upload-artifact@v2 + with: + name: Store report + retention-days: 1 + path: | + ./reports diff --git a/composer.json b/composer.json index eced8da..c0c7824 100644 --- a/composer.json +++ b/composer.json @@ -28,15 +28,17 @@ } ], "require": { - "php": ">=7.2", - "illuminate/support": "^6.0|^7.0|^8.0|^9.0|^10.0", - "guzzlehttp/guzzle": "^6.0|^7.0", - "symfony/psr-http-message-bridge": "^1.3|^2.0" + "php": "^8.2", + "guzzlehttp/guzzle": "^7.8", + "illuminate/support": "^10.0", + "symfony/psr-http-message-bridge": "^2.3" }, "require-dev": { - "friendsofphp/php-cs-fixer": "3.0.0", - "orchestra/testbench": "^4.0|^5.0|^6.0", - "phpunit/phpunit": "^8.4|^9.0" + "friendsofphp/php-cs-fixer": "^3.46", + "orchestra/testbench": "^8.20", + "pestphp/pest": "^1.23", + "phpunit/phpunit": "^9.6", + "laravel/pint": "^1.13" }, "autoload": { "psr-4": { @@ -54,7 +56,10 @@ "format": "vendor/bin/php-cs-fixer fix --allow-risky=yes --config=.php-cs-fixer.dist.php" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true + } }, "extra": { "laravel": { diff --git a/config/prerender.php b/config/prerender.php index ef64691..fd8b7be 100644 --- a/config/prerender.php +++ b/config/prerender.php @@ -132,7 +132,7 @@ '*.ttf', '*.otf', '*.woff', - '*.woff2' + '*.woff2', ], /* @@ -178,7 +178,7 @@ 'nuzzel', 'Discordbot', 'Google Page Speed', - 'Qwantify' + 'Qwantify', ], ]; diff --git a/src/LaravelPrerenderServiceProvider.php b/src/LaravelPrerenderServiceProvider.php index 9c0442b..4df7624 100644 --- a/src/LaravelPrerenderServiceProvider.php +++ b/src/LaravelPrerenderServiceProvider.php @@ -13,7 +13,7 @@ class LaravelPrerenderServiceProvider extends ServiceProvider public function boot(): void { $this->publishes([ - __DIR__ . '/../config/prerender.php' => config_path('prerender.php'), + __DIR__.'/../config/prerender.php' => config_path('prerender.php'), ], 'config'); if (config('prerender.enable')) { @@ -30,7 +30,7 @@ public function boot(): void public function register(): void { $this->mergeConfigFrom( - __DIR__ . '/../config/prerender.php', + __DIR__.'/../config/prerender.php', 'prerender' ); } diff --git a/src/PrerenderMiddleware.php b/src/PrerenderMiddleware.php index e8fdb1b..a480ba6 100644 --- a/src/PrerenderMiddleware.php +++ b/src/PrerenderMiddleware.php @@ -205,7 +205,7 @@ private function getPrerenderedPageResponse(Request $request): ?ResponseInterfac $path = ''; } - return $this->client->get($this->prerenderUri . '/' . urlencode($protocol.'://'.$host.'/'.$path), compact('headers')); + return $this->client->get($this->prerenderUri.'/'.urlencode($protocol.'://'.$host.'/'.$path), compact('headers')); } catch (RequestException $exception) { if (!$this->returnSoftHttpCodes && !empty($exception->getResponse()) && $exception->getResponse()->getStatusCode() === 404) { abort(404); diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..b3d9bbc --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1 @@ +get('/test-middleware', ['User-Agent' => 'Googlebot/2.1 (+http://www.google.com/bot.html)',]) + $this->get('/test-middleware', ['User-Agent' => 'Googlebot/2.1 (+http://www.google.com/bot.html)']) ->assertHeader('prerender.io-mock', true) ->assertSuccessful(); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 75290a9..b8afc72 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -22,7 +22,7 @@ protected function setUp(): void } /** - * @param Application $app + * @param Application $app */ protected function getPackageProviders($app): array { @@ -32,7 +32,7 @@ protected function getPackageProviders($app): array } /** - * @param Application $app + * @param Application $app */ protected function getEnvironmentSetUp($app): void {