Skip to content

Commit

Permalink
Feature/php8.3 support (#16)
Browse files Browse the repository at this point in the history
* Fix styling

* Updated style linting

Set style type to 'per'

Removed phpcpd

* update deps

* disabled phpmd check

@see: pdepend/pdepend#695

* Updated workflows

* Install pestphp for verison dependent tests

---------

Co-authored-by: LaravelFreelancerNL <[email protected]>
  • Loading branch information
LaravelFreelancerNL and LaravelFreelancerNL authored Dec 3, 2023
1 parent 87bd5c0 commit b682d88
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
extensions: mbstring, intl
ini-values: post_max_size=256M, short_open_tag=On
coverage: xdebug
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/fix-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Checkout
uses: actions/checkout@v3

- name: Cache dependencies
uses: actions/cache@v3
with:
Expand All @@ -25,7 +22,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
extensions: mbstring, intl
ini-values: post_max_size=256M, short_open_tag=On
coverage: none
Expand All @@ -41,6 +38,6 @@ jobs:
"${GITHUB_WORKSPACE}/vendor/bin/pint"
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
4 changes: 2 additions & 2 deletions .github/workflows/quality-assurance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache dependencies
uses: actions/cache@v3
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.3
extensions: mbstring, intl
ini-values: post_max_size=256M, short_open_tag=On
coverage: none
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.1, 8.2]
php: [8.1, 8.2, 8.3]
laravel: [9.*, 10.*]
stability: [prefer-stable]
include:
- laravel: 9.*
testbench: 7.*
illuminate-contracts: 9.*
phpunit: 9.*
pestphp: 1.*
- laravel: 10.*
testbench: 8.*
illuminate-contracts: 10.*
pestphp: 2.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}

steps:
- name: Checkout code
Expand All @@ -40,6 +43,7 @@ jobs:
- name: Install dependencies
run: |
composer require pestphp/pest:${{ matrix.pestphp }} --dev --with-all-dependencies
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "illuminate/contracts:${{ matrix.illuminate-contracts }}" --no-interaction --no-update --dev
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: next

Expand Down
6 changes: 2 additions & 4 deletions bin/qa.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env bash
printf "\nRun PHPMD\n"
./vendor/bin/phpmd src/ text phpmd-ruleset.xml

printf "\nRun PHPCPD\n"
./vendor/bin/phpcpd src
# disabled for now @see: https://github.com/pdepend/pdepend/issues/695
#./vendor/bin/phpmd src/ text phpmd-ruleset.xml

printf "\nRun PHPStan\n"
composer analyse
16 changes: 5 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,20 @@
"guzzlehttp/guzzle": "^7.4",
"illuminate/contracts": "^9.0|^10.0",
"nunomaduro/termwind": "^1.10",
"phpmd/phpmd": "^2.12",
"spatie/laravel-package-tools": "^1.9.2"
},
"require-dev": {
"laravel/pint": "^1.2.1",
"nunomaduro/collision": "^6.0",
"laravel/pint": "^1.13",
"nunomaduro/larastan": "^2.2.0",
"orchestra/testbench": "^7.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-faker": "^1.0",
"pestphp/pest-plugin-laravel": "^1.1|^2.0",
"orchestra/testbench": "^8.0",
"pestphp/pest": "^2.26",
"phpmd/phpmd": "^2.14",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5",
"scrutinizer/ocular": "^1.9",
"sebastian/phpcpd": "^6.0",
"spatie/laravel-ray": "^1.26",
"spatie/pest-plugin-test-time": "^1.1",
"timacdonald/log-fake": "^2.0"
},
"autoload": {
Expand All @@ -57,7 +51,7 @@
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes"
"format": "vendor/bin/pint"
},
"config": {
"sort-packages": true,
Expand Down
3 changes: 3 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "per"
}
2 changes: 1 addition & 1 deletion src/Commands/GenerateKeyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function handle(): int

$this->info('The keyfile was generated. Please add the following key to your .env file:');
$this->newLine();
$this->info('INDEXNOW_KEY='.$key);
$this->info('INDEXNOW_KEY=' . $key);

return self::SUCCESS;
}
Expand Down
10 changes: 5 additions & 5 deletions src/IndexNow.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace LaravelFreelancerNL\LaravelIndexNow;
namespace LaravelFreelancerNL\LaravelIndexNow;

use Exception;
use Illuminate\Foundation\Bus\PendingDispatch;
Expand All @@ -26,13 +26,13 @@ public function generateKey(): string

$key = Str::uuid()->toString();

$filename = $prefix.$key.'.txt';
$filename = $prefix . $key . '.txt';

if (! file_exists(public_path(dirname($filename)))) {
if (!file_exists(public_path(dirname($filename)))) {
throw new KeyFileDirectoryMissing();
}

File::put(public_path().'/'.$filename, $key);
File::put(public_path() . '/' . $filename, $key);

return $key;
}
Expand Down Expand Up @@ -115,7 +115,7 @@ protected function generateTargetUrl(): string
{
$searchEngineDomain = config('index-now.search-engine');

return 'https://'.$searchEngineDomain.'/indexnow';
return 'https://' . $searchEngineDomain . '/indexnow';
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/KeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
it('generates a key file', function () {
$key = IndexNow::generateKey();

$path = public_path($key.'.txt');
$path = public_path($key . '.txt');
$contents = File::get($path);

expect($contents)->toBe($key);
Expand All @@ -21,7 +21,7 @@

$key = IndexNow::generateKey();

$path = public_path($keyLocation.$key.'.txt');
$path = public_path($keyLocation . $key . '.txt');

$contents = File::get($path);

Expand All @@ -31,15 +31,15 @@
it('generates a key file in a subdirectory', function () {
$keyLocation = 'articles/';

if (! file_exists(public_path($keyLocation))) {
if (!file_exists(public_path($keyLocation))) {
mkdir(public_path($keyLocation));
}

config(['index-now.key-location' => $keyLocation]);

$key = IndexNow::generateKey();

$path = public_path($keyLocation.$key.'.txt');
$path = public_path($keyLocation . $key . '.txt');

$contents = File::get($path);

Expand Down
20 changes: 10 additions & 10 deletions tests/SubmitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

Http::assertSent(function (Request $request) {
return $request->url() == 'https://api.indexnow.org/indexnow?key='
.config('index-now.key')
.'&url='.urlencode('https://dejacht.nl');
. config('index-now.key')
. '&url=' . urlencode('https://dejacht.nl');
});
});

Expand All @@ -47,9 +47,9 @@

Http::assertSent(function (Request $request) {
return $request->url() == 'https://api.indexnow.org/indexnow?key='
.config('index-now.key')
.'&keyLocation='.config('index-now.key-location')
.'&url='.urlencode('https://devechtschool.nl');
. config('index-now.key')
. '&keyLocation=' . config('index-now.key-location')
. '&url=' . urlencode('https://devechtschool.nl');
});
});

Expand Down Expand Up @@ -93,7 +93,7 @@
$urls = [];

for ($i = 0; $i <= 10001; $i++) {
$urls[] = $baseUrl.$i;
$urls[] = $baseUrl . $i;
}

IndexNow::submit($urls);
Expand Down Expand Up @@ -129,7 +129,7 @@
expect($response)->toBeFalse();

Log::assertLogged(
fn (LogEntry $log) => $log->level === 'info'
fn(LogEntry $log) => $log->level === 'info'
&& $log->message === 'IndexNow: page submissions are only sent in production environments.'
&& $log->context === ['url' => 'https://dejacht.nl']
);
Expand All @@ -149,7 +149,7 @@
expect($response)->toBeFalse();

Log::assertNotLogged(
fn (LogEntry $log) => $log->level === 'info'
fn(LogEntry $log) => $log->level === 'info'
&& $log->message === 'IndexNow: page submissions are only sent in production environments.'
&& $log->context === ['url' => 'https://dejacht.nl']
);
Expand All @@ -169,7 +169,7 @@

Http::assertSent(function (Request $request) {
return $request->url() == 'https://api.indexnow.org/indexnow?key='
.config('index-now.key')
.'&url='.urlencode('https://dejacht.nl');
. config('index-now.key')
. '&url=' . urlencode('https://dejacht.nl');
});
});
4 changes: 2 additions & 2 deletions tests/SubmitUrlJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

Http::assertSent(function (Request $request) {
return $request->url() == 'https://api.indexnow.org/indexnow?key='
.config('index-now.key')
.'&url='.urlencode('https://laravel-freelancer.nl');
. config('index-now.key')
. '&url=' . urlencode('https://laravel-freelancer.nl');
});
});
4 changes: 1 addition & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@ protected function getPackageProviders($app)
];
}

public function getEnvironmentSetUp($app)
{
}
public function getEnvironmentSetUp($app) {}
}

0 comments on commit b682d88

Please sign in to comment.