Skip to content

Commit

Permalink
[TASK] Use custom composer.json for build
Browse files Browse the repository at this point in the history
Refs #62
  • Loading branch information
derhansen committed Feb 4, 2024
1 parent 416603a commit 3fe21d6
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 170 deletions.
38 changes: 38 additions & 0 deletions .Build/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "derhansen/sf_yubikey_build",
"description": "composer.json for builds",
"repositories": [
{
"type": "path",
"url": "../"
}
],
"require": {
"derhansen/sf_yubikey": "@dev",
"typo3/cms-core": "^12.4",
"php": ">=8.1"
},
"require-dev": {
"typo3/cms-composer-installers": "^5.0",
"typo3/cms-backend": "^12.4",
"typo3/cms-frontend": "^12.4",
"typo3/cms-extbase": "^12.4",
"typo3/cms-felogin": "^12.4",
"typo3/cms-fluid-styled-content": "^12.4",
"typo3/cms-fluid": "^12.4",
"typo3/cms-tstemplate": "^12.4",
"typo3/cms-install": "^12.4",
"typo3/cms-extensionmanager": "^12.4",
"typo3/testing-framework": "^8.0",
"friendsofphp/php-cs-fixer": "^3.12.0",
"saschaegerer/phpstan-typo3": "^1.8.3",
"phpstan/extension-installer": "^1.1"
},
"config": {
"allow-plugins": {
"typo3/class-alias-loader": true,
"typo3/cms-composer-installers": true,
"phpstan/extension-installer": true
}
}
}
70 changes: 70 additions & 0 deletions .Build/php-cs-fixer/.php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

$header = <<<'EOF'
This file is part of the TYPO3 extension sf_yubikey.
(c) Torben Hansen <[email protected]>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

return (new \PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PER' => true,
'array_syntax' => ['syntax' => 'short'],
'cast_spaces' => ['space' => 'none'],
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'dir_constant' => true,
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'list_syntax' => ['syntax' => 'short'],
'type_declaration_spaces' => true,
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
'no_alias_functions' => true,
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_leading_namespace_whitespace' => true,
'no_null_property_initialization' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_superfluous_elseif' => true,
'no_trailing_comma_in_singleline' => true,
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_no_access' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => true,
'single_space_around_construct' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'single_line_empty_body' => false,
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
])
->setFinder(
PhpCsFixer\Finder::create()
->in(dirname(__DIR__ . '/../../../'))
->exclude(['.Build', 'Documentation', 'Resources'])
->notName('ext_emconf.php')
);
Empty file.
7 changes: 5 additions & 2 deletions phpstan.neon → .Build/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
includes:
- phpstan-baseline.neon

parameters:
level: 7
paths:
- Classes/
- Configuration/
- ../../Classes/
- ../../Configuration/

checkMissingIterableValueType: false
reportUnmatchedIgnoredErrors: true
Expand Down
30 changes: 30 additions & 0 deletions .Build/phpunit/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
backupGlobals="true"
bootstrap="../../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
cacheResult="false"
colors="true"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
beStrictAboutTestsThatDoNotTestAnything="false"
failOnWarning="true"
failOnRisky="true"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="false"
>
<coverage/>
<testsuites>
<testsuite name="Unit Tests">
<directory>../../Tests/Unit/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./Classes</directory>
</include>
</source>
</phpunit>
18 changes: 8 additions & 10 deletions .github/workflows/CodeQuality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ jobs:
matrix:
env:
- { php: 8.1, coverage: 0}
- { php: 8.2, coverage: 0}

env: ${{ matrix.env }}

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Set up PHP Version
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.env.php }}
tools: composer:v2

- name: Validate composer.json and composer.lock
run: composer validate
- name: Validate composer.json
run: |
cd .Build
composer validate
- name: Cache dependencies
uses: actions/cache@v3
Expand All @@ -35,16 +36,13 @@ jobs:

- name: Install composer dependencies
run: |
cd .Build
composer install --no-progress
- name: PHP lint
run: |
.Build/bin/phplint
- name: Validate PHP coding guidelines
run: |
.Build/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --dry-run --stop-on-violation --using-cache=no
.Build/vendor/bin/php-cs-fixer fix --config=.Build/php-cs-fixer/.php-cs-fixer.php -v --dry-run --stop-on-violation --using-cache=no
- name: Run phpstan checks
run: |
.Build/bin/phpstan
.Build/vendor/bin/phpstan --configuration=.Build/phpstan/phpstan.neon
37 changes: 24 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
name: CI
name: Unit- and functional tests

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
env:
- { php: 8.1, coverage: 0}
- { php: 8.2, coverage: 0}

env: ${{ matrix.env }}
php: ['8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Set up PHP Version
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.env.php }}
php-version: ${{ matrix.php }}
tools: composer:v2

- name: Validate composer.json and composer.lock
run: composer validate
# Directory permissions for .composer are wrong, so we remove the complete directory
# https://github.com/actions/virtual-environments/issues/824
- name: Delete .composer directory
run: |
sudo rm -rf ~/.composer
- name: Validate composer.json
run: |
cd .Build
composer validate
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.composer/cache
key: dependencies-composer-${{ hashFiles('composer.json') }}

- name: Install composer dependencies
run: |
cd .Build
composer install --no-progress
- name: Unit Tests
- name: Unit tests
run: |
.Build/bin/phpunit
echo "Running unit tests";
.Build/vendor/bin/phpunit -c .Build/phpunit/UnitTests.xml
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# PHP Storm, other java IDE's
.idea
atlassian-ide-plugin.xml
.Build
.Build/public
.Build/vendor
.Build/var/
composer.lock
.phplint.cache
.phpunit.result.cache
.php-cs-fixer.cache
var/
.phpunit.cache
71 changes: 0 additions & 71 deletions .php-cs-fixer.dist.php

This file was deleted.

7 changes: 0 additions & 7 deletions .phplint.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ You can find a detailed documentation in the Documentation folder of the TYPO3 e

| Version | TYPO3 | PHP | Support/Development |
|---------|------------|-----------|--------------------------------------|
| 5.x | 12.4 | >= 8.1 | Features, Bugfixes, Security Updates |
| 4.x | 11.5 | 7.4 - 8.x | Features, Bugfixes, Security Updates |
| 5.x | 12.4 | 8.1 - 8-3 | Features, Bugfixes, Security Updates |
| 4.x | 11.5 | 7.4 - 8.3 | Features, Bugfixes, Security Updates |
| 3.x | 9.5 - 10.4 | 7.2 - 7.4 | Security Updates |
| 2.x | 7.6 - 9.5 | 5.5 - 7.4 | Support dropped |
| 1.x | 6.2 - 7.6 | 5.5 - 7.2 | Support dropped |
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/YubikeyAuthServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class YubikeyAuthServiceTest extends UnitTestCase
/**
* Data provider for authUserReturnsExpectedReturnCode
*/
public function authUserDataProvider(): array
public static function authUserDataProvider(): array
{
return [
'YubiKey not configured' => [
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/YubikeyServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class YubikeyServiceTest extends UnitTestCase
{
public function verifyHmacDataProvider(): array
public static function verifyHmacDataProvider(): array
{
$h = 'lHVE5KrfuhWg36MttJOwxWqa/AY=';
$t = '2021-02-13T05:20:11Z0768';
Expand Down
Loading

0 comments on commit 3fe21d6

Please sign in to comment.