Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests in CI also with PHP 8.4 #11

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,12 @@ name: CI
on: pull_request

jobs:
cs:
name: PHP CS Fixer
runs-on: ubuntu-latest

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

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run PHP CS Fixer
run: composer cs

tests:
name: PHPUnit tests
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.0', '8.1', '8.2', '8.3']
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']

steps:
- name: Checkout code
Expand All @@ -44,8 +25,8 @@ jobs:
- name: Run tests
run: composer test

stan:
name: PHPStan
stanAndCs:
name: Static Analysis (PHPStan) and Code Style (PHP CS Fixer)
runs-on: ubuntu-latest

steps:
Expand All @@ -62,3 +43,6 @@ jobs:

- name: Run PHPStan
run: composer stan

- name: Run PHP CS Fixer
run: composer cs
12 changes: 8 additions & 4 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?php

use PhpCsFixer\Config;
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;

$finder = PhpCsFixer\Finder::create()
->in([__DIR__ . '/src', __DIR__ . '/tests']);

$config = new PhpCsFixer\Config();

return $config->setFinder($finder)
return (new Config())
->setFinder($finder)
->setParallelConfig(ParallelConfigFactory::detect())
->setRules([
'@PSR12' => true,
'@PER-CS' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
'no_unused_imports' => true,
])
->setRiskyAllowed(true)
->setUsingCache(true);
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2023 Christian Olear
Copyright (c) 2024 Christian Olear

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
8 changes: 7 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@
"source": "https://github.com/crwlrsoft/robots-txt",
"docs": "https://www.crwlr.software/packages/robots-txt"
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/otsch"
}
],
"require": {
"php": "^8.0",
"crwlr/url": "^1.0|^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"friendsofphp/php-cs-fixer": "^3.0",
"friendsofphp/php-cs-fixer": "^3.57",
"sempro/phpunit-pretty-print": "^1.4",
"mockery/mockery": "^1.4",
"phpstan/phpstan": "^1.1"
Expand Down
2 changes: 1 addition & 1 deletion src/Encoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static function decodePercentEncodedAsciiCharactersInPath(string $path):
trigger_error(
"Failed to Decode percent encoded ASCII characters. Preg error: \n" . preg_last_error() . ": " .
preg_last_error_msg(),
E_USER_WARNING
E_USER_WARNING,
);

return $path;
Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidRobotsTxtFileException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

use Exception;

class InvalidRobotsTxtFileException extends Exception
{
}
class InvalidRobotsTxtFileException extends Exception {}
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private function getLine(array $lines, int $lineNumber): string
{
return trim(
$lines[$lineNumber],
" \n\r\t\v\x00 ­  ⁠​           ⠀͏‌"
" \n\r\t\v\x00 ­  ⁠​           ⠀͏‌",
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/RobotsTxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(private array $userAgentGroups, private array $sitem
foreach ($userAgentGroups as $userAgentGroup) {
if (!$userAgentGroup instanceof UserAgentGroup) {
throw new InvalidArgumentException(
'Argument $userAgentGroups must exclusively contain objects of type UserAgentGroup.'
'Argument $userAgentGroups must exclusively contain objects of type UserAgentGroup.',
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/UserAgentGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function test_is_allowed(array $disallowedPatterns, string $allowedPatter
{
array_walk(
$disallowedPatterns,
fn (string $pattern) => $this->userAgentGroup->addDisallowedPattern(new RulePattern($pattern))
fn(string $pattern) => $this->userAgentGroup->addDisallowedPattern(new RulePattern($pattern)),
);
$this->userAgentGroup->addAllowedPattern(new RulePattern($allowedPattern));
$this->assertTrue($this->userAgentGroup->isAllowed($uri));
Expand Down