Update GitHub workflows

This commit is contained in:
Sebastian Meyer 2024-03-31 18:36:06 +02:00
parent e473341f46
commit 7128019a09
15 changed files with 292 additions and 20 deletions

121
.gitattributes vendored Normal file
View File

@ -0,0 +1,121 @@
###
# https://github.com/gitattributes/gitattributes/blob/master/Common.gitattributes
###
# Auto detect text files and perform LF normalization
* text=auto
#
# The above will handle all files NOT found below
#
# Documents
*.bibtex text diff=bibtex
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
*.md text diff=markdown
*.mdx text diff=markdown
*.tex text diff=tex
*.adoc text
*.textile text
*.mustache text
*.csv text eol=crlf
*.tab text
*.tsv text
*.txt text
*.sql text
*.epub diff=astextplain
# Graphics
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.tif binary
*.tiff binary
*.ico binary
# SVG treated as text by default.
*.svg text
# If you want to treat it as binary,
# use the following line instead.
# *.svg binary
*.eps binary
# Scripts
*.bash text eol=lf
*.fish text eol=lf
*.ksh text eol=lf
*.sh text eol=lf
*.zsh text eol=lf
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
# Serialisation
*.json text
*.toml text
*.xml text
*.yaml text
*.yml text
# Archives
*.7z binary
*.gz binary
*.tar binary
*.tgz binary
*.zip binary
# Text files where line endings should be preserved
*.patch -text
#
# Exclude files from exporting
#
.gitattributes export-ignore
.gitignore export-ignore
.gitkeep export-ignore
###
# https://github.com/gitattributes/gitattributes/blob/master/PHP.gitattributes
###
# PHP files
*.php text eol=lf diff=php
*.phpt text eol=lf diff=php
*.phtml text eol=lf diff=html
*.twig text eol=lf
*.phar binary
# Configuration
phpcs.xml text eol=lf
phpunit.xml text eol=lf
phpstan.neon text eol=lf
psalm.xml text eol=lf
###
# Open Culture Consulting custom additions
###
# Configuration
.editorconfig text eol=lf
*.dist.xml text eol=lf
*.xml.dist text eol=lf
*.neon text eol=lf
# Generated documentation
doc/* linguist-generated=true
# Exclude files from exporting
.github/* export-ignore
.phpdoc/* export-ignore
phpdoc.dist.xml export-ignore

View File

@ -4,6 +4,7 @@ updates:
directory: "/" directory: "/"
schedule: schedule:
interval: "weekly" interval: "weekly"
versioning-strategy: "increase-if-necessary"
assignees: assignees:
- "sebastian-meyer" - "sebastian-meyer"
labels: [ ] labels: [ ]

35
.github/workflows/phpcs.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: PHP Code Sniffer
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
PHPCS:
name: PHPCS Scanner
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- name: Checkout Source Code
uses: actions/checkout@v4
- name: Setup Environment
uses: php-actions/composer@v6
with:
command: update
php_version: "8.1"
- name: Run PHPCS
uses: php-actions/phpcs@v1
with:
php_version: "8.1"
path: src/
standard: phpcs.xml.dist

View File

@ -25,7 +25,7 @@ jobs:
- name: Setup Environment - name: Setup Environment
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: "8.0" php-version: "8.1"
coverage: none coverage: none
tools: phpmd tools: phpmd

View File

@ -26,7 +26,7 @@ jobs:
uses: php-actions/composer@v6 uses: php-actions/composer@v6
with: with:
command: update command: update
php_version: "8.0" php_version: "8.1"
- name: Run PHPStan - name: Run PHPStan
uses: php-actions/phpstan@v3 uses: php-actions/phpstan@v3

35
.github/workflows/psalm.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Psalm Static Analyzer
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
Psalm:
name: Psalm Scanner
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
actions: read
steps:
- name: Checkout Source Code
uses: actions/checkout@v4
- name: Run Psalm
uses: docker://ghcr.io/psalm/psalm-github-actions
with:
security_analysis: true
report_file: psalm-results.sarif
- name: Upload Analysis Results
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: psalm-results.sarif
wait-for-processing: true

5
.gitignore vendored
View File

@ -1,5 +1,10 @@
/.phpdoc/cache/
/.vscode/ /.vscode/
/vendor/ /vendor/
.php-cs-fixer.php .php-cs-fixer.php
composer.lock composer.lock
phpcs.xml
phpdoc.xml
phpstan.neon phpstan.neon
psalm.xml
TODO

View File

@ -1,8 +1,8 @@
<?php <?php
/** /**
* Queue-based PSR-15 HTTP Server Request Handler * PHP Basics
* Copyright (C) 2023 Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * Copyright (C) 2024 Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -11,11 +11,11 @@
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); declare(strict_types=1);
@ -24,15 +24,15 @@ namespace PhpCsFixer;
/** /**
* Configuration for PHP-CS-Fixer. * Configuration for PHP-CS-Fixer.
*
* @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst * @see https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/master/doc/config.rst
* *
* @return ConfigInterface * @return ConfigInterface
*/ */
return (new Config()) $config = new Config();
$finder = new Finder();
return $config
->setRiskyAllowed(true) ->setRiskyAllowed(true)
->setRules([ ->setRules(['@PSR12' => true])
'@PSR12' => true, ->setFinder($finder->in([__DIR__ . '/src']));
])
->setFinder(
(new Finder())->in(__DIR__)
);

View File

@ -8,6 +8,7 @@
"request", "request",
"handler", "handler",
"middleware", "middleware",
"queue",
"http-server-handler", "http-server-handler",
"http-server-middleware" "http-server-middleware"
], ],
@ -25,19 +26,21 @@
"support": { "support": {
"issues": "https://github.com/opencultureconsulting/psr-15/issues", "issues": "https://github.com/opencultureconsulting/psr-15/issues",
"source": "https://github.com/opencultureconsulting/psr-15", "source": "https://github.com/opencultureconsulting/psr-15",
"docs": "https://github.com/opencultureconsulting/psr-15/blob/main/README.md" "docs": "https://opencultureconsulting.github.io/psr-15/"
}, },
"require": { "require": {
"php": "^8.0", "php": "^8.1",
"guzzlehttp/psr7": "^2.6", "guzzlehttp/psr7": "^2.6",
"opencultureconsulting/basics": "^1.1", "opencultureconsulting/basics": "^2.0",
"psr/http-server-handler": "^1.0", "psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0" "psr/http-server-middleware": "^1.0"
}, },
"require-dev": { "require-dev": {
"phpstan/phpstan": "^1.10", "phpstan/phpstan": "^1.10",
"phpstan/phpstan-strict-rules": "^1.5", "phpstan/phpstan-strict-rules": "^1.5",
"friendsofphp/php-cs-fixer": "^3.48" "friendsofphp/php-cs-fixer": "^3.52",
"squizlabs/php_codesniffer": "^3.9",
"vimeo/psalm": "^5.23"
}, },
"provide": { "provide": {
"psr/http-server-handler-implementation": "1.0", "psr/http-server-handler-implementation": "1.0",

10
phpcs.xml.dist Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<ruleset name="OCC Standard Ruleset">
<description>Open Culture Consulting strictly follows PSR standards.</description>
<file>./src</file>
<arg name="extensions" value="php"/>
<rule ref="PSR12">
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
</rule>
</ruleset>

39
phpdoc.dist.xml Normal file
View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8" ?>
<phpdocumentor
configVersion="3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://www.phpdoc.org"
xsi:schemaLocation="https://www.phpdoc.org https://raw.githubusercontent.com/phpDocumentor/phpDocumentor/master/data/xsd/phpdoc.xsd">
<title>PSR-15 Queue</title>
<paths>
<output>doc</output>
<cache>.phpdoc/cache</cache>
</paths>
<version number="latest">
<api format="php">
<source dsn=".">
<path>/src</path>
</source>
<extensions>
<extension>php</extension>
</extensions>
<default-package-name>PSR15</default-package-name>
<include-source>true</include-source>
<ignore-tags>
<ignore-tag>extends</ignore-tag>
<ignore-tag>implements</ignore-tag>
<ignore-tag>phpstan-require-implements</ignore-tag>
<ignore-tag>psalm-suppress</ignore-tag>
</ignore-tags>
</api>
<guide format="rst">
<source dsn=".">
<path>/.phpdoc/guide</path>
</source>
<output>guides</output>
</guide>
</version>
<setting name="graphs.enabled" value="false"/>
<setting name="guides.enabled" value="true"/>
<setting name="template.color" value="orange"/>
</phpdocumentor>

23
psalm.xml.dist Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0"?>
<psalm
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="1"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="true"
findUnusedVariablesAndParams="true"
>
<issueHandlers>
<RedundantCastGivenDocblockType errorLevel="suppress"/>
<RedundantConditionGivenDocblockType errorLevel="suppress"/>
<RedundantFunctionCallGivenDocblockType errorLevel="suppress"/>
</issueHandlers>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
</psalm>

View File

@ -31,7 +31,7 @@ use Psr\Http\Server\RequestHandlerInterface;
* Abstract class implementing Psr\Http\Server\MiddlewareInterface. * Abstract class implementing Psr\Http\Server\MiddlewareInterface.
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/psr15 * @package PSR15
*/ */
abstract class AbstractMiddleware implements MiddlewareInterface abstract class AbstractMiddleware implements MiddlewareInterface
{ {

View File

@ -30,7 +30,7 @@ use Psr\Http\Server\MiddlewareInterface;
* Queue of PSR-15 Middlewares to process HTTP Server Requests. * Queue of PSR-15 Middlewares to process HTTP Server Requests.
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/psr15 * @package PSR15
* *
* @extends StrictQueue<MiddlewareInterface> * @extends StrictQueue<MiddlewareInterface>
*/ */

View File

@ -36,7 +36,7 @@ use Psr\Http\Server\RequestHandlerInterface;
* A queue-based PSR-15 HTTP Server Request Handler. * A queue-based PSR-15 HTTP Server Request Handler.
* *
* @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com> * @author Sebastian Meyer <sebastian.meyer@opencultureconsulting.com>
* @package opencultureconsulting/psr15 * @package PSR15
* *
* @property-read MiddlewareQueue $queue * @property-read MiddlewareQueue $queue
* @property-read ServerRequestInterface $request * @property-read ServerRequestInterface $request