Skip to content

Commit

Permalink
Merge pull request #1 from netlogix/feature/typo3-v12
Browse files Browse the repository at this point in the history
FEATURE: Add TYPO3 v12 support
  • Loading branch information
tweis authored Jan 29, 2024
2 parents 3ff1a58 + b43af24 commit 9ed7f2b
Show file tree
Hide file tree
Showing 21 changed files with 677 additions and 289 deletions.
60 changes: 60 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

# TS/JS-Files
[*.{ts,js}]
indent_size = 2

# JSON-Files
[*.json]
indent_style = tab

# ReST-Files
[*.{rst,rst.txt}]
indent_size = 4
max_line_length = 80

# Markdown-Files
[*.md]
max_line_length = 80

# YAML-Files
[*.{yaml,yml}]
indent_size = 2

# NEON-Files
[*.neon]
indent_size = 2
indent_style = tab

# package.json
[package.json]
indent_size = 2

# TypoScript
[*.{typoscript,tsconfig}]
indent_size = 2

# XLF-Files
[*.xlf]
indent_style = tab

# SQL-Files
[*.sql]
indent_style = tab
indent_size = 2

# .htaccess
[{_.htaccess,.htaccess}]
indent_style = tab
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily

- package-ecosystem: composer
directory: /
schedule:
interval: daily
70 changes: 70 additions & 0 deletions .github/workflows/apply-coding-standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Apply Coding Standard

on:
push:
branches:
- main

jobs:
php-coding-standard:
name: 'Apply PHP Coding Standard'
runs-on: ubuntu-latest
steps:
- name: 'Checkout Code'
uses: actions/checkout@v4

- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer

- name: 'Get Composer Cache Directory'
id: composer-cache
shell: bash
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: 'Cache Composer Dependencies'
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer

- name: 'Install Composer Dependencies'
shell: bash
run: composer install --no-interaction

- name: 'Rector PHP Code'
shell: bash
run: composer rector-fix

- name: 'Lint PHP Code'
shell: bash
run: composer lint-fix

- name: 'Run PHPUnit unit tests'
shell: bash
run: composer test-unit

- name: 'Run PHPUnit functional tests'
shell: bash
run: composer test-functional

- name: 'Create pull-request'
id: cpr
uses: peter-evans/create-pull-request@v5.0.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "[automated] Apply Coding Standard"
base: 'main'
branch: 'automated-apply-coding-standards'
title: '[automated] Apply Coding Standard'
labels: 'automated'
delete-branch: true

- name: 'Enable Pull Request Merge when ready'
if: steps.cpr.outputs.pull-request-operation == 'created'
run: gh pr merge --auto "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
142 changes: 54 additions & 88 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,127 +1,93 @@
name: Test TYPO3 Extension

on: [ push, pull_request ]
# Make sure only one build is running per branch at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read
pull-requests: write

jobs:
test:

runs-on: ubuntu-22.04

name: TYPO3 ${{ matrix.typo3}} on PHP ${{ matrix.php }}
runs-on: ubuntu-latest
name: TYPO3 v12.4 tests on PHP ${{ matrix.php }}

strategy:
fail-fast: false
matrix:
php: [ 7.4, 8.0, 8.1 ]
typo3: [ 10.4, 11.5 ]

exclude:
# do not run TYPO3 10.4 on PHP 8
- php: 8.0
typo3: 10.4
# do not run TYPO3 10.4 on PHP 8.1
- php: 8.1
typo3: 10.4
php: [ 8.1, 8.2, 8.3 ]

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

- name: Setup PHP
- name: 'Setup PHP'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer
coverage: 'xdebug3'
extensions: pdo, sqlite3

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

- name: Get Composer Cache Directory
- name: 'Get Composer Cache Directory'
id: composer-cache
shell: bash
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-php${{ matrix.php }}-typo3${{ matrix.typo3 }}

- name: Install TYPO3 core
run: composer require typo3/cms-core="^${{ matrix.typo3 }}" -W

- name: Unit Tests
run: .Build/bin/phpunit -c phpunit.xml
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Functional Tests
run: .Build/bin/phpunit -c phpunit_functional.xml

# upload results for later use
- uses: actions/upload-artifact@master
if: github.event_name == 'pull_request'
- name: 'Cache Composer Dependencies'
uses: actions/cache@v3
with:
name: coverage-results
path: .Build/logs/coverage/


report:
# only run on pull request
if: github.event_name == 'pull_request'
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-php${{ matrix.php }}

runs-on: ubuntu-22.04
- name: 'Validate composer.json and composer.lock'
shell: bash
run: composer validate --strict

name: Create Test Result Report
- name: 'Install Composer Dependencies'
shell: bash
run: composer install --no-interaction

needs: [ test ]
- name: 'PHPUnit unit tests'
shell: bash
run: composer test-unit

steps:
- name: Checkout
uses: actions/checkout@v3
- name: 'PHPUnit functional tests'
shell: bash
run: composer test-functional

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
# soyhuce/phpunit-to-cobertura is not compatible with with PHP > 7.4 yet
php-version: 7.4
tools: composer
extensions: pdo, sqlite3
- name: 'Merge Coverage Reports'
shell: bash
run: .Build/bin/phpcov merge --html .Build/artifacts/coverage/merged --clover .Build/artifacts/coverage/clover.xml .Build/artifacts/coverage/

- uses: actions/download-artifact@master
- name: 'Generate code coverage summary report'
uses: saschanowak/CloverCodeCoverageSummary@0.4.0
with:
name: coverage-results
path: .Build/logs/coverage/

- name: Install Dependencies
run: composer install --no-interaction
filename: .Build/artifacts/coverage/clover.xml

# merge result files from unit tests and functional tests
- name: Merge Coverage Reports
run: .Build/bin/phpcov merge --php .Build/logs/coverage.php .Build/logs/coverage/
- name: 'Add code coverage summary as action run comment'
run: |
cat code-coverage-summary.md >> $GITHUB_STEP_SUMMARY
cat code-coverage-details.md >> $GITHUB_STEP_SUMMARY
# convert result file to cobertura
- name: Generate Cobertura Report
run: composer require soyhuce/phpunit-to-cobertura && .Build/bin/phpunit-to-cobertura .Build/logs/coverage.php .Build/logs/cobertura.xml
- name: 'Add title to code coverage summary'
shell: bash
run: sed -i '1 i\## TYPO3 v12.4 tests on PHP ${{ matrix.php }}' code-coverage-summary.md

# finally use the cobertura report and generate coverage summary
- name: Code Coverage Summary Report
uses: irongut/CodeCoverageSummary@v1.2.0
with:
filename: .Build/logs/cobertura.xml
badge: true
# there are not enough tests yet
fail_below_min: false
format: markdown
hide_branch_rate: true
hide_complexity: false
indicators: true
output: both
thresholds: '60 80'

- name: Add Coverage PR Comment
- name: 'Add code coverage summary as pr comment'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: coverage-${{ matrix.php }}
recreate: true
path: code-coverage-results.md
path: code-coverage-summary.md
Loading

0 comments on commit 9ed7f2b

Please sign in to comment.