Skip to content

Commit

Permalink
Merge pull request #146 from Tofandel/master
Browse files Browse the repository at this point in the history
Allow symfony/console 7 and add tests for php 8.2 and 8.3 with phpunit range
  • Loading branch information
BrainMaestro authored Jun 22, 2024
2 parents 3d197c4 + 2c4196f commit b3fc96a
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1']
php: ['8.0', '8.1', '8.2', '8.3']

steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ cghooks-temp-*
.php_cs.cache
phpunit.xml
cghooks.lock
composer.lock
.phpunit.result.cache
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
}
],
"require": {
"php": "^8.0|^8.1",
"symfony/console": "^5.0|^6.0"
"php": "^8.0",
"symfony/console": "^5.0|^6.0|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9|^10|^11",
"friendsofphp/php-cs-fixer": "^3.0",
"ext-json": "*"
},
Expand Down Expand Up @@ -57,11 +57,11 @@
"pre-commit": "composer check-style",
"pre-push": [
"composer test",
"appver=$(grep -o -E '\\d.\\d.\\d(-alpha.\\d)?' cghooks)",
"appver=$(grep -o -E '[0-9]+\\.[0-9]+\\.[0-9]+(-alpha\\.[0-9]+)?' cghooks)",
"tag=$(git tag | tail -n 1)",
"if [ \"$tag\" != \"v$appver\" ]; then",
"echo \"The most recent tag $tag does not match the application version $appver\\n\"",
"tag=${tag#v}",
"if [ \"$tag\" != \"$appver\" ]; then",
"echo \"The most recent tag $tag does not match the application version $appver\\n\"",
"sed -i -E \"s/$appver/$tag/\" cghooks",
"exit 1",
"fi"
Expand Down
20 changes: 6 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
6 changes: 3 additions & 3 deletions src/Commands/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ abstract protected function init(InputInterface $input);

abstract protected function command();

final protected function execute(InputInterface $input, OutputInterface $output)
final protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->output = $output;
$this->gitDir = $input->getOption('git-dir') ?: git_dir();
Expand All @@ -41,7 +41,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
}
if ($this->gitDir === false) {
$output->writeln('Git is not initialized. Skip setting hooks...');
return 0;
return SymfonyCommand::SUCCESS;
}
$this->lockFile = (null !== $this->lockDir ? ($this->lockDir . '/') : '') . Hook::LOCK_FILE;

Expand All @@ -52,7 +52,7 @@ final protected function execute(InputInterface $input, OutputInterface $output)
$this->init($input);
$this->command();

return 0;
return SymfonyCommand::SUCCESS;
}

protected function global_dir_fallback()
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/HookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$contents = Hook::getHookContents($this->composerDir, $this->contents, $this->hook);
$outputMessage = [];
$returnCode = 0;
$returnCode = SymfonyCommand::SUCCESS;
exec($contents, $outputMessage, $returnCode);

$output->writeln(implode(PHP_EOL, $outputMessage));
Expand Down
Loading

0 comments on commit b3fc96a

Please sign in to comment.