Skip to content

Commit

Permalink
Merge branch 'TYPO3-12'
Browse files Browse the repository at this point in the history
  • Loading branch information
magicsunday committed Aug 16, 2024
2 parents d81ad53 + 657df57 commit 05b4791
Show file tree
Hide file tree
Showing 73 changed files with 2,686 additions and 1,974 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Adapted from https://github.com/TYPO3GmbH/blog/blob/master/.github/workflows/ci.yml
name: CI

on:
push:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
typo3: [ '^12.0', '^13.0' ]
php: [ '8.1', '8.2', '8.3' ]
exclude:
- typo3: '^13.0'
php: '8.1'

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

- id: setup_php
name: Set up PHP version ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer:v2, php-cs-fixer

- name: Validate composer.json and composer.lock
run: composer validate

- id: composer-cache-vars
name: Composer Cache Vars
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
echo "timestamp=$(date +"%s")" >> $GITHUB_OUTPUT
- id: composer-cache-dependencies
name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache-vars.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.typo3 }}-${{ steps.composer-cache-vars.outputs.timestamp }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.typo3 }}-
${{ runner.os }}-composer-${{ matrix.php }}-
${{ runner.os }}-composer-
- id: install
name: Install dependencies with typo3/cms-core:${{ matrix.typo3 }}
run: |
composer require typo3/cms-core:${{ matrix.typo3 }} --no-progress --no-update
composer require typo3/cms-backend:${{ matrix.typo3 }} --no-progress --no-update
composer require typo3/cms-extbase:${{ matrix.typo3 }} --no-progress --no-update
composer require typo3/cms-extensionmanager:${{ matrix.typo3 }} --no-progress --no-update
composer install
git checkout composer.json
- id: lint
name: Lint
if: ${{ always() && steps.install.conclusion == 'success' }}
run: |
composer ci:test:php:lint
- id: cgl
name: CGL
if: ${{ always() && steps.install.conclusion == 'success' }}
run: |
php-cs-fixer fix --dry-run --verbose --config Build/.php-cs-fixer.dist.php
- id: phpstan
name: PHPStan
if: ${{ always() && steps.install.conclusion == 'success' }}
run: |
composer ci:test:php:phpstan -- --error-format=github
- id: rector
name: Rector
if: ${{ always() && steps.install.conclusion == 'success' }}
run: |
composer ci:test:php:rector
- id: tests_unit
name: Unit Tests
if: ${{ always() && steps.install.conclusion == 'success' }}
run: |
composer ci:test:php:unit
27 changes: 21 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
/vendor/
/public/
/composer.lock
.buildpath
# PHPStorm
.idea
.project
.settings

# OSX
.DS_Store

# Composer
vendor/
bin/
logs/
composer.lock

# Build stuff
.build/

# PHPUnit
phpunit-report.xml
coverage/

# Cache
.php-cs-fixer.cache
.phplint.cache
130 changes: 55 additions & 75 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1,79 @@
stages:
- preparation
- 'PHP 8.1'
- testing

.parallel-hidden-job:
parallel:
matrix:
- TYPO3: [ '^12.0' ]
PHP: [ '82' ]

default:
before_script:
- apt-get update -yqq
- apt-get install -yqq git libxml2-dev libzip-dev zip unzip
.php:
extends: .parallel-hidden-job
image:
name: registry.netresearch.de/support/typo3-12/build:$PHP
entrypoint: [ '/bin/bash', '-c' ]

# Install PHP extensions
- docker-php-ext-install xml zip


# Job template
.composer:
composer:
stage: preparation
extends:
- .php
variables:
COMPOSER_AUTH: |
script:
- php --version
# Install composer
- curl -sS https://getcomposer.org/installer | php
# Install all project dependencies
- php composer.phar install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- echo "Install dependencies with typo3/cms-core:$TYPO3"
- php --version
- composer config -g gitlab-oauth.git.netresearch.de $GITLAB_ACCESS_TOKEN
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
artifacts:
paths:
- vendor/
- public/
- .build/
expire_in: 1 days
when: always
cache:
paths:
- vendor/
- public/

- .build/

# Job template: Run code sniffer
.phpcs:
phplint:
stage: testing
extends:
- .php
needs:
- composer
script:
- php --version
- vendor/bin/phpcs Classes/ --standard=PSR12 --extensions=php --report=junit > phpcs-report.xml
artifacts:
reports:
junit:
- phpcs-report.xml
- composer ci:test:php:lint


# Job template: Run static analysis
.phpstan:
phpstan:
stage: testing
extends:
- .php
needs:
- composer
script:
- php --version
- vendor/bin/phpstan analyse --error-format=junit --no-progress -c ./phpstan.neon > phpstan-report.xml
- composer ci:test:php:phpstan -- --memory-limit=-1 --error-format=gitlab > phpstan-report.json
artifacts:
paths:
- "phpstan-report.json"
expire_in: 1 days
when: always
reports:
junit:
- phpstan-report.xml
codequality: "./phpstan-report.json"


# Job template: Rector PHP 8.1 and TYPO3 v11
.rector:
script:
- php --version
- vendor/bin/rector process --dry-run


# PHP 8.1
.php8.1:
image: php:8.1
stage: 'PHP 8.1'
before_script:
- !reference [ default, before_script ]
# Install & enable Xdebug for code coverage reports
- pecl install xdebug-3.2.1
- docker-php-ext-enable xdebug

composer:8.1:
extends:
- .php8.1
- .composer

.php8.1-test:
rector:
stage: testing
extends:
- .php8.1
needs: [ 'composer:8.1' ]

phpcs:8.1:
extends:
- .php8.1-test
- .phpcs

phpstan:8.1:
extends:
- .php8.1-test
- .phpstan
- .php
needs:
- composer
script:
- composer ci:test:php:rector

rector:8.1:
coding-style:
stage: testing
extends:
- .php8.1-test
- .rector

- .php
needs:
- composer
script:
- composer ci:cgl -- --dry-run
95 changes: 95 additions & 0 deletions Build/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

/**
* This file represents the configuration for Code Sniffing PSR-2-related
* automatic checks of coding guidelines
* Install @fabpot's great php-cs-fixer tool via
*
* $ composer global require friendsofphp/php-cs-fixer
*
* And then simply run
*
* $ php-cs-fixer fix
*
* For more information read:
* http://www.php-fig.org/psr/psr-2/
* http://cs.sensiolabs.org
*/

if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
}

$header = <<<EOF
This file is part of the package netresearch/nr-textdb.
For the full copyright and license information, please read the
LICENSE file that was distributed with this source code.
EOF;

return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PSR12' => true,
'@PER-CS2.0' => true,
'@Symfony' => true,

// Additional custom rules
'declare_strict_types' => true,
'concat_space' => [
'spacing' => 'one',
],
'header_comment' => [
'header' => $header,
'comment_type' => 'PHPDoc',
'location' => 'after_open',
'separate' => 'both',
],
'phpdoc_to_comment' => false,
'phpdoc_no_alias_tag' => false,
'no_superfluous_phpdoc_tags' => false,
'phpdoc_separation' => [
'groups' => [
[
'author',
'license',
'link',
],
],
],
'no_alias_functions' => true,
'whitespace_after_comma_in_array' => [
'ensure_single_space' => true,
],
'single_line_throw' => false,
'self_accessor' => false,
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => true,
'import_functions' => true,
],
'function_declaration' => [
'closure_function_spacing' => 'one',
'closure_fn_spacing' => 'one',
],
'binary_operator_spaces' => [
'operators' => [
'=' => 'align_single_space_minimal',
'=>' => 'align_single_space_minimal',
],
],
'yoda_style' => [
'equal' => false,
'identical' => false,
'less_and_greater' => false,
'always_move_variable' => false,
],
])
->setFinder(
PhpCsFixer\Finder::create()
->exclude('.build')
->exclude('config')
->exclude('node_modules')
->exclude('var')
->in(__DIR__ . '/../')
);
7 changes: 7 additions & 0 deletions Build/.phplint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
path: ./
jobs: 10
cache: .build/.phplint.cache
extensions:
- php
exclude:
- .build
Loading

0 comments on commit 05b4791

Please sign in to comment.