Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task #424: add github actions to lint the code and release to TER #466

Merged
merged 3 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ indent_size = 2

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

# ReST-Files
[*.rst]
Expand All @@ -34,10 +34,6 @@ indent_size = 2
indent_size = 2
indent_style = tab

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

# TypoScript
[*.{typoscript,tsconfig}]
indent_size = 2
Expand Down
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
# This GitHub Actions workflow uses the same development tools that are also installed locally
# via Composer or PHIVE and calls them using the Composer scripts.
name: CI with Composer scripts
on:
push:
branches:
- main
pull_request:
schedule:
- cron: '15 3 * * 1'
permissions:
contents: read
jobs:
php-lint:
name: "PHP linter"
runs-on: ubuntu-22.04
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2
- name: "Show the Composer configuration"
run: "composer config --global --list"
- name: "Run PHP lint"
run: "composer ci:php:lint"
strategy:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
code-quality:
name: "Code quality checks"
runs-on: ubuntu-22.04
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
php-version: "${{ matrix.php-version }}"
coverage: none
tools: composer:v2
- name: "Show Composer version"
run: "composer --version"
- name: "Show the Composer configuration"
run: "composer config --global --list"
- name: "Cache dependencies installed with composer"
uses: actions/cache@v3
with:
key: "php${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}"
path: ~/.cache/composer
restore-keys: "php${{ matrix.php-version }}-composer-\n"
- name: "Install Composer dependencies"
run: "composer install --no-progress"
- name: "Run command"
run: "composer ci:${{ matrix.command }}"
strategy:
fail-fast: false
matrix:
command:
- "composer:normalize"
- "composer:psr-verify"
- "json:lint"
# - "php:sniff"
# - "php:stan"
# - "xliff:lint"
php-version:
- "8.1"
20 changes: 20 additions & 0 deletions .github/workflows/publish-ter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: read
jobs:
publish:
permissions:
actions: write
runs-on: ubuntu-22.04
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Publish new version to TER"
uses: tomasnorre/typo3-upload-ter@v2
with:
api-token: ${{ secrets.TYPO3_API_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
#
# Ignore by common IDEs used directories/files
*.idea
.idea
.idea
/composer.lock
/.Build
5 changes: 5 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

$config = \TYPO3\CodingStandards\CsFixerConfig::create();
$config->getFinder()->in('Classes')->in('Configuration')->in('Tests');
return $config;
18 changes: 18 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Documentation: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset -->
<ruleset name="direct_mail">
<!-- Configuration -->
<config name="encoding" value="utf-8"/>
<config name="testVersion" value="7.4-8.3"/>
<arg name="extensions" value="php/php"/>

<!-- Exclude git directory -->
<exclude-pattern>.git/</exclude-pattern>
<!-- Exclude third party code -->
<exclude-pattern>vendor/</exclude-pattern>
<exclude-pattern>.Build/</exclude-pattern>
<!-- PSR2 ruleset -->
<rule ref="PSR12" />
<!-- PHPCompatibility ruleset -->
<rule ref="PHPCompatibility"/>
</ruleset>
14 changes: 14 additions & 0 deletions Build/bin/console
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env php
<?php

include_once __DIR__ . '/../../.Build/vendor/autoload.php';

use Symfony\Component\Console\Application;
use Symfony\Component\Translation\Command\XliffLintCommand;
use Symfony\Component\Yaml\Command\LintCommand;

$application = new Application();
$application->add(new XliffLintCommand(null, null, null, false));
$application->add(new LintCommand());

exit($application->run());
116 changes: 103 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,138 @@
{
"name": "directmailteam/direct-mail",
"type": "typo3-cms-extension",
"description": "Advanced Direct Mail/Newsletter mailer system with sophisticated options for personalization of emails including response statistics.",
"license": [
"GPL-2.0-or-later"
],
"type": "typo3-cms-extension",
"keywords": [
"TYPO3",
"extension",
"directmail",
"newsletter"
],
"homepage": "https://github.com/kartolo/direct_mail",
"authors": [
{
"name": "Ivan Kartolo",
"role": "Developer"
}
],
"license": [
"GPL-2.0-or-later"
],
"homepage": "https://github.com/kartolo/direct_mail",
"support": {
"issues": "https://github.com/kartolo/direct_mail/issues"
},
"require": {
"typo3/cms-core": "^11.5",
"typo3/cms-dashboard": "^11.5",
"php": "^7.4 || ^8.0 || ^8.1",
"php": "^7.4 || ^8.0",
"friendsoftypo3/tt-address": "^6.0 || ^7.0 || ^8.0",
"tedivm/fetch": "0.7.*"
"tedivm/fetch": "~0.7.0",
"typo3/cms-core": "^11.5",
"typo3/cms-dashboard": "^11.5"
},
"require-dev": {
"roave/security-advisories": "dev-master"
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"ergebnis/composer-normalize": "^2.28.3",
"friendsofphp/php-cs-fixer": "^3.41.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpstan/extension-installer": "^1.3.1",
"phpstan/phpstan": "^1.2.0",
"roave/security-advisories": "dev-master",
"saschaegerer/phpstan-typo3": "^1.0.0",
"seld/jsonlint": "^1.10.1",
"squizlabs/php_codesniffer": "^3.8.0",
"symfony/console": "^5.4 || ^6.4",
"symfony/translation": "^5.4 || ^6.4",
"symfony/yaml": "^5.3.6 || ^6.2.0",
"tomasvotruba/type-coverage": "^0.2.1",
"typo3/coding-standards": "^0.6.1"
},
"replace": {
"typo3-ter/direct-mail": "self.version"
},
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"DirectMailTeam\\DirectMail\\": "Classes"
}
},
"replace": {
"typo3-ter/direct-mail": "self.version"
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true,
"phpstan/extension-installer": true,
"sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": true,
"typo3/class-alias-loader": true,
"typo3/cms-composer-installers": true
},
"bin-dir": ".Build/bin",
"preferred-install": {
"*": "dist"
},
"sort-packages": true,
"vendor-dir": ".Build/vendor"
},
"extra": {
"typo3/cms": {
"extension-key": "direct_mail"
"extension-key": "direct_mail",
"web-dir": ".Build/Web"
}
},
"scripts": {
"ci:composer:normalize": "@composer normalize --no-check-lock --dry-run",
"ci:composer:psr-verify": "@composer dumpautoload --optimize --strict-psr --no-plugins",
"ci:json:lint": "find . ! -path '*/.cache/*' ! -path '*/.Build/*' ! -path '*/node_modules/*' -name '*.json' | xargs -r php .Build/bin/jsonlint -q",
"ci:php": [
"@ci:php:cs-fixer",
"@ci:php:lint",
"@ci:php:sniff",
"@ci:php:stan"
],
"ci:php:cs-fixer": "php-cs-fixer fix --config .php-cs-fixer.php -v --dry-run --diff",
"ci:php:lint": "find .*.php *.php Classes Configuration Tests -name '*.php' -print0 | xargs -r -0 -n 1 -P 4 php -l",
"ci:php:sniff": "phpcs --standard=.phpcs.xml -n -p -s --extensions=php .",
"ci:php:stan": "phpstan --no-progress",
"ci:static": [
"@ci:composer:normalize",
"@ci:json:lint",
"@ci:php:cs-fixer",
"@ci:php:lint",
"@ci:php:sniff",
"@ci:php:stan",
"@ci:yaml:lint"
],
"ci:xliff:lint": "php Build/bin/console lint:xliff Resources/Private/Language",
"ci:yaml:lint": "find . ! -path '*.Build/*' ! -path '*node_modules/*' -regextype egrep -regex '.*.ya?ml$' | xargs -r php ./.Build/bin/yaml-lint",
"fix:composer:normalize": "@composer normalize --no-check-lock",
"fix:php": [
"@fix:php:cs",
"@fix:php:sniff"
],
"fix:php:cs": "php-cs-fixer fix --config .phpcs-fixer.php",
"fix:php:sniff": "phpcbf --standard=.phpcs.xml -n -p -s --extensions=php .",
"prepare-release": [
"rm -rf .github",
"rm -rf Build",
"rm .gitignore",
"rm .editorconfig",
"rm .php-cs-fixer.php",
"rm .phpcs.xml",
"rm phpstan.neon"
]
},
"scripts-descriptions": {
"ci:composer:normalize": "Checks the composer.json.",
"ci:composer:psr-verify": "Verifies PSR-4 namespace correctness.",
"ci:json:lint": "Lints the JSON files.",
"ci:php": "Runs all static checks for the PHP files.",
"ci:php:cs-fixer": "Checks the code style with the PHP Coding Standards Fixer (PHP-CS-Fixer).",
"ci:php:lint": "Lints the PHP files for syntax errors.",
"ci:php:sniff": "Checks the code style with PHP_CodeSniffer (PHPCS).",
"ci:php:stan": "Checks the PHP types using PHPStan.",
"ci:xliff:lint": "Lints the XLIFF files.",
"ci:yaml:lint": "Lints the YAML files.",
"fix:composer:normalize": "Normalizes composer.json file content.",
"fix:php": "Runs all fixers for the PHP code.",
"fix:php:cs": "Fixes the code style with PHP-CS-Fixer.",
"fix:php:sniff": "Fixes the code style with PHP_CodeSniffer.",
"prepare-release": "Removes development-only files in preparation of a TER release."
}
}
24 changes: 24 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
parameters:
parallel:
# Don't be overly greedy on machines with more CPU's to be a good neighbor especially on CI
maximumNumberOfProcesses: 5

level: 3

bootstrapFiles:
- .Build/vendor/autoload.php

paths:
- Classes
- Configuration
- Tests

scanDirectories:
- Classes
- Configuration
- Tests

type_coverage:
return_type: 100
param_type: 100
property_type: 95