Skip to content

Commit

Permalink
Fix CI, remove travis, add github workflow for tests (FriendsOfSymfon…
Browse files Browse the repository at this point in the history
  • Loading branch information
igorrebega committed Feb 7, 2022
1 parent 5940472 commit da28677
Show file tree
Hide file tree
Showing 39 changed files with 419 additions and 343 deletions.
4 changes: 1 addition & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
/Tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs.dist export-ignore
/.travis.yml export-ignore
/Makefile export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/.php-cs-fixer.dist.php export-ignore
77 changes: 75 additions & 2 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
php-version: '7.4'
coverage: 'none'
extensions: 'json, mbstring, tokenizer'
tools: 'composer-normalize, php-cs-fixer:2.16.4'
tools: 'composer-normalize, php-cs-fixer:3.0.0'
env:
update: true

Expand All @@ -24,7 +24,80 @@ jobs:
php-cs-fixer --version
- name: 'Check PHP code'
run: 'php-cs-fixer fix --diff --dry-run --using-cache=false'
run: 'php-cs-fixer fix --diff --dry-run --allow-risky=yes --using-cache=no'

- name: 'Check composer.json'
run: 'composer-normalize --diff --dry-run --no-update-lock'
phpunit:
name: "PHPUnit"
runs-on: "ubuntu-20.04"
continue-on-error: ${{ matrix.can-fail }}

strategy:
matrix:
include:
- php-version: 7.4
composer-flags: "--prefer-stable"
symfony-require: "4.4.*"
can-fail: false
- php-version: 7.4
composer-flags: "--prefer-stable"
can-fail: false
symfony-require: "5.4.*"
coverage: yes
- php-version: 8.0
composer-flags: "--prefer-stable"
can-fail: false
symfony-require: "5.4.*"
ignore-propel: true

steps:
- name: "Checkout"
uses: "actions/checkout@v2"

- name: "Install PHP with XDebug"
uses: "shivammathur/setup-php@v2"
if: "${{ matrix.coverage != '' }}"
with:
php-version: "${{ matrix.php-version }}"
coverage: "xdebug"
tools: "composer:v2,flex"

- name: "Install PHP without coverage"
uses: "shivammathur/setup-php@v2"
if: "${{ matrix.coverage == '' }}"
with:
php-version: "${{ matrix.php-version }}"
coverage: "none"
tools: "composer:v2,flex"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Remove propel if needed"
if: "${{ matrix.ignore-propel != '' }}"
run: |
composer remove propel/propel1 --dev --no-update
composer remove willdurand/propel-typehintable-behavior --dev --no-update
- name: "Install dependencies with composer"
env:
SYMFONY_REQUIRE: "${{ matrix.symfony-require }}"
run: |
composer remove friendsofphp/php-cs-fixer --dev --no-update
composer update --no-interaction --no-progress ${{ matrix.composer-flags }}
- name: "Run PHPUnit"
if: "${{ matrix.coverage != '' }}"
run: |
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover=coverage.clover
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
- name: "Run PHPUnit"
if: "${{ matrix.coverage == '' }}"
run: "./vendor/bin/phpunit"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ vendor/
Propel/om/
Propel/map/
composer.lock
.php_cs.cache
.phpunit.result.cache
.php-cs-fixer.cache
42 changes: 28 additions & 14 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
Expand All @@ -18,31 +20,40 @@
file that was distributed with this source code.
EOF;

$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__);

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'psr_autoloading' => true,
'header_comment' => ['header' => $header],
])
->setRiskyAllowed(true)
->setUsingCache(false)
->setRules(
[
'@Symfony' => true,
'@PHPUnit60Migration:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'declare_strict_types' => true,
'dir_constant' => true,
'general_phpdoc_annotation_remove' => ['@author'],
'general_phpdoc_annotation_remove' => ['annotations' => ['@author']],
'header_comment' => ['header' => $header],
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'modernize_types_casting' => true,
// 'native_function_invocation' => true,
'no_extra_consecutive_blank_lines' => ['continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
'no_extra_blank_lines' => [
'tokens' => [
'continue',
'extra',
'return',
'throw',
'use',
'parenthesis_brace_block',
'square_brace_block',
'curly_brace_block',
],
],
'multiline_whitespace_before_semicolons' => ['strategy' => 'new_line_for_chained_calls'],
'no_php4_constructor' => true,
'no_short_echo_tag' => true,
'echo_tag_syntax' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
Expand All @@ -54,17 +65,20 @@
'php_unit_strict' => true,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_annotation_without_dot' => true,
'phpdoc_inline_tag' => false,
'general_phpdoc_tag_rename' => false,
'phpdoc_no_empty_return' => false,
'phpdoc_order' => true,
'phpdoc_to_comment' => false,
'psr4' => true,
'random_api_migration' => true,
'semicolon_after_instruction' => true,
'single_import_per_statement' => true,
'strict_comparison' => true,
'strict_param' => true,
'yoda_style' => false
'yoda_style' => false,
]
)->setUsingCache(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
)
->setFinder($finder);
;
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Document/AuthCodeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace FOS\OAuthServerBundle\Document;

use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\DocumentRepository;
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
use FOS\OAuthServerBundle\Model\AuthCodeInterface;
use FOS\OAuthServerBundle\Model\AuthCodeManager as BaseAuthCodeManager;

Expand Down
2 changes: 1 addition & 1 deletion Document/TokenManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace FOS\OAuthServerBundle\Document;

use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ODM\MongoDB\DocumentRepository;
use Doctrine\ODM\MongoDB\Repository\DocumentRepository;
use FOS\OAuthServerBundle\Model\TokenInterface;
use FOS\OAuthServerBundle\Model\TokenManager as BaseTokenManager;

Expand Down
38 changes: 0 additions & 38 deletions Makefile

This file was deleted.

6 changes: 3 additions & 3 deletions Propel/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
abstract class Token extends BaseToken implements TokenInterface
{
/**
* {@inheritdoc}
* @return mixed
*/
public function getData()
{
return $this->getUser();
}

/**
* {@inheritdoc}
* @return int
*/
public function getExpiresIn()
{
Expand All @@ -39,7 +39,7 @@ public function getExpiresIn()
}

/**
* {@inheritdoc}
* @return bool
*/
public function hasExpired()
{
Expand Down
5 changes: 4 additions & 1 deletion Storage/OAuthStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use OAuth2\IOAuth2GrantImplicit;
use OAuth2\IOAuth2GrantUser;
use OAuth2\IOAuth2RefreshTokens;
use OAuth2\Model\IOAuth2AuthCode;
use OAuth2\Model\IOAuth2Client;
use OAuth2\OAuth2;
use OAuth2\OAuth2ServerException;
Expand Down Expand Up @@ -168,7 +169,9 @@ public function checkUserCredentials(IOAuth2Client $client, $username, $password
}

/**
* {@inheritdoc}
* @param string $code
*
* @return IOAuth2AuthCode
*/
public function getAuthCode($code)
{
Expand Down
25 changes: 25 additions & 0 deletions Tests/BypassFinalHook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

declare(strict_types=1);

/*
* This file is part of the FOSOAuthServerBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\OAuthServerBundle\Tests;

use DG\BypassFinals;
use PHPUnit\Runner\BeforeTestHook;

final class BypassFinalHook implements BeforeTestHook
{
public function executeBeforeTest(string $test): void
{
BypassFinals::enable();
}
}
12 changes: 6 additions & 6 deletions Tests/Command/CleanCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public function testItShouldRemoveExpiredToken(): void

$display = $tester->getDisplay();

$this->assertContains(sprintf('Removed %d items from %s storage.', $expiredAccessTokens, get_class($this->accessTokenManager)), $display);
$this->assertContains(sprintf('Removed %d items from %s storage.', $expiredRefreshTokens, get_class($this->refreshTokenManager)), $display);
$this->assertContains(sprintf('Removed %d items from %s storage.', $expiredAuthCodes, get_class($this->authCodeManager)), $display);
$this->assertStringContainsString(sprintf('Removed %d items from %s storage.', $expiredAccessTokens, get_class($this->accessTokenManager)), $display);
$this->assertStringContainsString(sprintf('Removed %d items from %s storage.', $expiredRefreshTokens, get_class($this->refreshTokenManager)), $display);
$this->assertStringContainsString(sprintf('Removed %d items from %s storage.', $expiredAuthCodes, get_class($this->authCodeManager)), $display);
}

/**
Expand All @@ -109,8 +109,8 @@ public function testItShouldNotRemoveExpiredTokensForOtherClasses(): void

$display = $tester->getDisplay();

$this->assertNotRegExp(sprintf('\'Removed (\d)+ items from %s storage.\'', get_class($this->accessTokenManager)), $display);
$this->assertNotRegExp(sprintf('\'Removed (\d)+ items from %s storage.\'', get_class($this->refreshTokenManager)), $display);
$this->assertNotRegExp(sprintf('\'Removed (\d)+ items from %s storage.\'', get_class($this->authCodeManager)), $display);
$this->assertDoesNotMatchRegularExpression(sprintf('\'Removed (\d)+ items from %s storage.\'', get_class($this->accessTokenManager)), $display);
$this->assertDoesNotMatchRegularExpression(sprintf('\'Removed (\d)+ items from %s storage.\'', get_class($this->refreshTokenManager)), $display);
$this->assertDoesNotMatchRegularExpression(sprintf('\'Removed (\d)+ items from %s storage.\'', get_class($this->authCodeManager)), $display);
}
}
Loading

0 comments on commit da28677

Please sign in to comment.