Skip to content

Commit

Permalink
Enhancement: Synchronize with ergebnis/php-cs-fixer-config-template
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Nov 24, 2024
1 parent c7849a9 commit 2fcde1a
Show file tree
Hide file tree
Showing 15 changed files with 407 additions and 1,176 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
/composer-require-checker.json export-ignore
/composer.lock export-ignore
/Makefile export-ignore
/psalm-baseline.xml export-ignore
/psalm.xml export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon export-ignore
/rector.php export-ignore
32 changes: 28 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CONTRIBUTING
# Contributing

We use [GitHub Actions](https://github.com/features/actions) as a continuous integration system.

Expand All @@ -10,6 +10,18 @@ For details, take a look at the following workflow configuration files:
- [`workflows/renew.yaml`](workflows/renew.yaml)
- [`workflows/triage.yaml`](workflows/triage.yaml)

## Backward-Compatibility Analysis

We use [`roave/backward-compatibility-check`](https://github.com/Roave/BackwardCompatibilityCheck) to prevent breaking backwards-compatibility.

Run

```sh
make backward-compatibility-analysis
```

to run a backward-compatibility analysis.

## Coding Standards

We use [`ergebnis/composer-normalize`](https://github.com/ergebnis/composer-normalize) to normalize `composer.json`.
Expand Down Expand Up @@ -46,6 +58,18 @@ make dependency-analysis

to run a dependency analysis.

## Mutation Tests

We use [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.

Enable `Xdebug` and run

```sh
make mutation-tests
```

to run mutation tests.

## Refactoring

We use [`rector/rector`](https://github.com/rectorphp/rector) to automatically refactor code.
Expand All @@ -72,7 +96,7 @@ to run a security analysis.

## Static Code Analysis

We use [`phpstan/phpstan`](https://github.com/phpstan/phpstan) and [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analyze the code.
We use [`phpstan/phpstan`](https://github.com/phpstan/phpstan) to statically analyze the code.

Run

Expand All @@ -82,15 +106,15 @@ make static-code-analysis

to run a static code analysis.

We also use the baseline feature of [`vimeo/psalm`](https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file).
We also use the baseline feature of [`phpstan/phpstan`](https://phpstan.org/user-guide/baseline).

Run

```sh
make static-code-analysis-baseline
```

to regenerate the baseline in [`../psalm-baseline.xml`](../psalm-baseline.xml).
to regenerate the baseline in [`../phpstan-baseline.neon`](../phpstan-baseline.neon).

:exclamation: Ideally, the baseline should shrink over time.

Expand Down
6 changes: 3 additions & 3 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 2

updates:
- allow:
- dependency-type: "direct"
- dependency-type: "development"
commit-message:
include: "scope"
prefix: "composer"
Expand All @@ -14,7 +14,7 @@ updates:
open-pull-requests-limit: 10
package-ecosystem: "composer"
schedule:
interval: "daily"
interval: "weekly"
versioning-strategy: "increase"

- commit-message:
Expand All @@ -26,4 +26,4 @@ updates:
open-pull-requests-limit: 10
package-ecosystem: "github-actions"
schedule:
interval: "daily"
interval: "weekly"
146 changes: 125 additions & 21 deletions .github/workflows/integrate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,58 @@ on: # yamllint disable-line rule:truthy
- "main"

jobs:
backward-compatibility-analysis:
name: "Backward-Compatibility Analysis"

runs-on: "ubuntu-latest"

timeout-minutes: 5

strategy:
matrix:
php-version:
- "8.1"

dependencies:
- "locked"

steps:
- name: "Checkout"
uses: "actions/[email protected]"
with:
fetch-depth: 0

- name: "Set up PHP"
uses: "shivammathur/[email protected]"
with:
coverage: "none"
extensions: "none, bcmath, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""

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

- name: "Determine composer cache directory"
uses: "ergebnis/.github/actions/composer/[email protected]"

- name: "Cache dependencies installed with composer"
uses: "actions/[email protected]"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install ${{ matrix.dependencies }} dependencies with composer"
uses: "ergebnis/.github/actions/composer/[email protected]"
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Run backward-compatibility analysis with roave/backward-compatibility-check"
run: "vendor/bin/roave-backward-compatibility-check --ansi --format=github-actions --from=1902cc2"

code-coverage:
name: "Code Coverage"

Expand All @@ -19,7 +71,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

dependencies:
- "locked"
Expand All @@ -32,7 +84,7 @@ jobs:
uses: "shivammathur/[email protected]"
with:
coverage: "xdebug"
extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, bcmath, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand Down Expand Up @@ -65,7 +117,7 @@ jobs:
run: "vendor/bin/phpunit --colors=always --configuration=test/Unit/phpunit.xml --coverage-clover=.build/phpunit/logs/clover.xml"

- name: "Send code coverage report to codecov.io"
uses: "codecov/[email protected].7"
uses: "codecov/[email protected].2"
with:
files: ".build/phpunit/logs/clover.xml"
token: "${{ secrets.CODECOV_TOKEN }}"
Expand All @@ -80,7 +132,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

dependencies:
- "locked"
Expand All @@ -100,7 +152,7 @@ jobs:
uses: "shivammathur/[email protected]"
with:
coverage: "none"
extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, bcmath, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand Down Expand Up @@ -149,7 +201,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

dependencies:
- "locked"
Expand All @@ -162,7 +214,7 @@ jobs:
uses: "shivammathur/[email protected]"
with:
coverage: "none"
extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, bcmath, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"
tools: "phive"

Expand Down Expand Up @@ -195,6 +247,58 @@ jobs:
- name: "Run maglnet/composer-require-checker"
run: ".phive/composer-require-checker check --ansi --config-file=$(pwd)/composer-require-checker.json --verbose"

mutation-tests:
name: "Mutation Tests"

runs-on: "ubuntu-latest"

timeout-minutes: 5

strategy:
matrix:
php-version:
- "8.1"

dependencies:
- "locked"

steps:
- name: "Checkout"
uses: "actions/[email protected]"

- name: "Set up PHP"
uses: "shivammathur/[email protected]"
with:
coverage: "xdebug"
extensions: "none, bcmath, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""

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

- name: "Determine composer cache directory"
uses: "ergebnis/.github/actions/composer/[email protected]"

- name: "Cache dependencies installed with composer"
uses: "actions/[email protected]"
with:
path: "${{ env.COMPOSER_CACHE_DIR }}"
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Install ${{ matrix.dependencies }} dependencies with composer"
uses: "ergebnis/.github/actions/composer/[email protected]"
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Run mutation tests with Xdebug and infection/infection"
env:
XDEBUG_MODE: "coverage"
run: "vendor/bin/infection --ansi --configuration=infection.json --logger-github"

refactoring:
name: "Refactoring"

Expand All @@ -205,7 +309,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

dependencies:
- "locked"
Expand All @@ -218,7 +322,7 @@ jobs:
uses: "shivammathur/[email protected]"
with:
coverage: "none"
extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, bcmath, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand Down Expand Up @@ -264,7 +368,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

dependencies:
- "locked"
Expand All @@ -277,7 +381,7 @@ jobs:
uses: "shivammathur/[email protected]"
with:
coverage: "none"
extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, bcmath, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand Down Expand Up @@ -314,7 +418,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.4"
- "8.1"

dependencies:
- "locked"
Expand All @@ -327,7 +431,7 @@ jobs:
uses: "shivammathur/[email protected]"
with:
coverage: "none"
extensions: "none, ctype, curl, dom, json, mbstring, opcache, pcntl, phar, posix, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, bcmath, ctype, curl, dom, intl, json, mbstring, opcache, pcntl, phar, posix, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand All @@ -351,8 +455,8 @@ jobs:
with:
dependencies: "${{ matrix.dependencies }}"

- name: "Run vimeo/psalm"
run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4"
- name: "Run phpstan/phpstan"
run: "vendor/bin/phpstan --ansi --configuration=phpstan.neon --memory-limit=-1"

tests:
name: "Tests"
Expand All @@ -365,11 +469,10 @@ jobs:
fail-fast: false
matrix:
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
- "8.4"

dependencies:
- "lowest"
Expand All @@ -384,7 +487,7 @@ jobs:
uses: "shivammathur/[email protected]"
with:
coverage: "none"
extensions: "none, ctype, curl, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
extensions: "none, bcmath, ctype, curl, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
php-version: "${{ matrix.php-version }}"

- name: "Set up problem matchers for PHP"
Expand All @@ -406,6 +509,10 @@ jobs:
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"

- name: "Remove incompatible dependencies with composer"
if: "matrix.dependencies != 'locked'"
run: "composer remove roave/backward-compatibility-check --ansi --dev --no-interaction --no-progress"

- name: "Remove platform configuration with composer"
if: "matrix.dependencies != 'locked'"
run: "composer config platform.php --ansi --unset"
Expand All @@ -417,6 +524,3 @@ jobs:

- name: "Run unit tests with phpunit/phpunit"
run: "vendor/bin/phpunit --colors=always --configuration=test/Unit/phpunit.xml"

- name: "Run end-to-end tests with phpunit/phpunit"
run: "vendor/bin/phpunit --colors=always --configuration=test/EndToEnd/phpunit.xml"
2 changes: 1 addition & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="composer-require-checker" version="~3.8.0" installed="3.8.0" location="./.phive/composer-require-checker" copy="false"/>
<phar name="composer-require-checker" version="^4.7.1" installed="4.7.1" location="./.phive/composer-require-checker" copy="false"/>
</phive>
Loading

0 comments on commit 2fcde1a

Please sign in to comment.