Skip to content

Commit fa46767

Browse files
committed
Enhancement: Synchronize with ergebnis/php-package-template
1 parent 0c0dd3a commit fa46767

File tree

17 files changed

+337
-93
lines changed

17 files changed

+337
-93
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
/Makefile export-ignore
1414
/psalm-baseline.xml export-ignore
1515
/psalm.xml export-ignore
16+
/rector.php export-ignore

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-size
2+
13
* @ergebnis-bot @localheinz

.github/CONTRIBUTING.md

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ For details, take a look at the following workflow configuration files:
66

77
- [`workflows/integrate.yaml`](workflows/integrate.yaml)
88
- [`workflows/merge.yaml`](workflows/merge.yaml)
9-
- [`workflows/prune.yaml`](workflows/prune.yaml)
109
- [`workflows/release.yaml`](workflows/release.yaml)
1110
- [`workflows/renew.yaml`](workflows/renew.yaml)
1211
- [`workflows/triage.yaml`](workflows/triage.yaml)
@@ -47,9 +46,45 @@ make dependency-analysis
4746

4847
to run a dependency analysis.
4948

49+
## Mutation Tests
50+
51+
We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.
52+
53+
Enable `Xdebug` and run
54+
55+
```sh
56+
make mutation-tests
57+
```
58+
59+
to run mutation tests.
60+
61+
## Refactoring
62+
63+
We are using [`rector/rector`](https://github.com/rectorphp/rector) to automatically refactor code.
64+
65+
Run
66+
67+
```sh
68+
make refactoring
69+
```
70+
71+
to automatically refactor code.
72+
73+
## Security Analysis
74+
75+
We are using [`composer`](https://github.com/composer/composer) to run a security analysis.
76+
77+
Run
78+
79+
```sh
80+
make security-analysis
81+
```
82+
83+
to run a security analysis.
84+
5085
## Static Code Analysis
5186

52-
We are using [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analyze the code.
87+
We are using [`phpstan/phpstan`](https://github.com/phpstan/phpstan) and [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analyze the code.
5388

5489
Run
5590

@@ -59,17 +94,17 @@ make static-code-analysis
5994

6095
to run a static code analysis.
6196

62-
We are also using the baseline feature of [`vimeo/psalm`](https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file).
97+
We are also using the baseline features of [`phpstan/phpstan`](https://phpstan.org/user-guide/baseline) and [`vimeo/psalm`](https://psalm.dev/docs/running_psalm/dealing_with_code_issues/#using-a-baseline-file).
6398

6499
Run
65100

66101
```sh
67102
make static-code-analysis-baseline
68103
```
69104

70-
to regenerate the baseline in [`../psalm-baseline.xml`](../psalm-baseline.xml).
105+
to regenerate the baselines in [`../phpstan-baseline.neon`](../phpstan-baseline.neon) and [`../psalm-baseline.xml`](../psalm-baseline.xml).
71106

72-
:exclamation: Ideally, the baseline should shrink over time.
107+
:exclamation: Ideally, the baselines should shrink over time.
73108

74109
## Tests
75110

@@ -83,18 +118,6 @@ make tests
83118

84119
to run all the tests.
85120

86-
## Mutation Tests
87-
88-
We are using [`infection/infection`](https://github.com/infection/infection) to ensure a minimum quality of the tests.
89-
90-
Enable `pcov` or `Xdebug` and run
91-
92-
```sh
93-
make mutation-tests
94-
```
95-
96-
to run mutation tests.
97-
98121
## Extra lazy?
99122

100123
Run
@@ -103,7 +126,7 @@ Run
103126
make
104127
```
105128

106-
to enforce coding standards, run a static code analysis, and run tests!
129+
to automatically refactor code, enforce coding standards, run a static code analysis, and run tests!
107130

108131
## Help
109132

.github/settings.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ branches:
1818
- context: "Coding Standards (8.1, locked)"
1919
- context: "Dependency Analysis (8.1, locked)"
2020
- context: "Mutation Tests (8.1, locked)"
21+
- context: "Refactoring (8.1, locked)"
22+
- context: "Security Analysis (8.1, locked)"
2123
- context: "Static Code Analysis (8.1, locked)"
2224
- context: "Tests (8.1, locked)"
2325
- context: "Tests (8.2, locked)"
@@ -58,10 +60,6 @@ labels:
5860
color: "ee0701"
5961
description: ""
6062

61-
- name: "stale"
62-
color: "eeeeee"
63-
description: ""
64-
6563
# https://docs.github.com/en/rest/reference/repos#update-a-repository
6664

6765
repository:

.github/workflows/integrate.yaml

Lines changed: 102 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
uses: "actions/[email protected]"
8484

8585
- name: "Lint YAML files"
86-
uses: "ibiqlik/[email protected]"
86+
uses: "ibiqlik/[email protected].1"
8787
with:
8888
config_file: ".yamllint.yaml"
8989
file_or_dir: "."
@@ -127,8 +127,10 @@ jobs:
127127
uses: "actions/[email protected]"
128128
with:
129129
path: ".build/php-cs-fixer"
130-
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.sha }}"
131-
restore-keys: "php-${{ matrix.php-version }}-php-cs-fixer-"
130+
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }}"
131+
restore-keys: |
132+
php-${{ matrix.php-version }}-php-cs-fixer-main
133+
php-${{ matrix.php-version }}-php-cs-fixer-
132134
133135
- name: "Run friendsofphp/php-cs-fixer"
134136
run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --dry-run --verbose"
@@ -156,6 +158,7 @@ jobs:
156158
coverage: "none"
157159
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
158160
php-version: "${{ matrix.php-version }}"
161+
tools: "phive"
159162

160163
- name: "Set up problem matchers for PHP"
161164
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
@@ -175,6 +178,11 @@ jobs:
175178
with:
176179
dependencies: "${{ matrix.dependencies }}"
177180

181+
- name: "Install dependencies with phive"
182+
uses: "ergebnis/.github/actions/phive/[email protected]"
183+
with:
184+
trust-gpg-keys: "0x033E5F8D801A2F8D"
185+
178186
- name: "Run maglnet/composer-require-checker"
179187
run: ".phive/composer-require-checker check --config-file=$(pwd)/composer-require-checker.json"
180188

@@ -225,6 +233,96 @@ jobs:
225233
XDEBUG_MODE: "coverage"
226234
run: "vendor/bin/infection --ansi --configuration=infection.json --logger-github"
227235

236+
refactoring:
237+
name: "Refactoring"
238+
239+
runs-on: "ubuntu-latest"
240+
241+
strategy:
242+
matrix:
243+
php-version:
244+
- "8.1"
245+
246+
dependencies:
247+
- "locked"
248+
249+
steps:
250+
- name: "Checkout"
251+
uses: "actions/[email protected]"
252+
253+
- name: "Set up PHP"
254+
uses: "shivammathur/[email protected]"
255+
with:
256+
coverage: "none"
257+
extensions: "none, ctype, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
258+
php-version: "${{ matrix.php-version }}"
259+
260+
- name: "Set up problem matchers for PHP"
261+
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
262+
263+
- name: "Determine composer cache directory"
264+
uses: "ergebnis/.github/actions/composer/[email protected]"
265+
266+
- name: "Cache dependencies installed with composer"
267+
uses: "actions/[email protected]"
268+
with:
269+
path: "${{ env.COMPOSER_CACHE_DIR }}"
270+
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
271+
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
272+
273+
- name: "Install ${{ matrix.dependencies }} dependencies with composer"
274+
uses: "ergebnis/.github/actions/composer/[email protected]"
275+
with:
276+
dependencies: "${{ matrix.dependencies }}"
277+
278+
- name: "Create cache directory for rector/rector"
279+
run: "mkdir -p .build/rector"
280+
281+
- name: "Cache cache directory for rector/rector"
282+
uses: "actions/[email protected]"
283+
with:
284+
path: ".build/rector"
285+
key: "php-${{ matrix.php-version }}-rector-${{ github.ref_name }}"
286+
restore-keys: |
287+
php-${{ matrix.php-version }}-rector-main
288+
php-${{ matrix.php-version }}-rector-
289+
290+
- name: "Run automated refactoring with rector/rector"
291+
run: "vendor/bin/rector --ansi --config=rector.php --dry-run"
292+
293+
security-analysis:
294+
name: "Security Analysis"
295+
296+
runs-on: "ubuntu-latest"
297+
298+
strategy:
299+
matrix:
300+
php-version:
301+
- "8.1"
302+
303+
dependencies:
304+
- "locked"
305+
306+
steps:
307+
- name: "Checkout"
308+
uses: "actions/[email protected]"
309+
310+
- name: "Set up PHP"
311+
uses: "shivammathur/[email protected]"
312+
with:
313+
coverage: "none"
314+
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
315+
php-version: "${{ matrix.php-version }}"
316+
317+
- name: "Set up problem matchers for PHP"
318+
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
319+
320+
- name: "Validate composer.json and composer.lock"
321+
run: "composer validate --ansi --strict"
322+
323+
- name: "Check installed packages for security vulnerability advisories"
324+
run: "composer audit --ansi"
325+
228326
static-code-analysis:
229327
name: "Static Code Analysis"
230328

@@ -246,7 +344,7 @@ jobs:
246344
uses: "shivammathur/[email protected]"
247345
with:
248346
coverage: "none"
249-
extensions: "none, ctype, curl, dom, json, mbstring, pcntl, phar, posix, simplexml, tokenizer, xml, xmlwriter"
347+
extensions: "none, ctype, curl, dom, json, mbstring, opcache, pcntl, phar, posix, simplexml, tokenizer, xml, xmlwriter"
250348
php-version: "${{ matrix.php-version }}"
251349

252350
- name: "Set up problem matchers for PHP"

.github/workflows/merge.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
- name: "Assign @ergebnis-bot"
3535
uses: "ergebnis/.github/actions/github/pull-request/[email protected]"
3636
with:
37-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
3837
assignee: "ergebnis-bot"
38+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
3939

4040
- name: "Approve pull request"
4141
uses: "ergebnis/.github/actions/github/pull-request/[email protected]"

.github/workflows/prune.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/renew.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ jobs:
6161
uses: "actions/[email protected]"
6262
with:
6363
path: ".build/php-cs-fixer"
64-
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.sha }}"
65-
restore-keys: "php-${{ matrix.php-version }}-php-cs-fixer-"
64+
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }}"
65+
restore-keys: |
66+
php-${{ matrix.php-version }}-php-cs-fixer-main
67+
php-${{ matrix.php-version }}-php-cs-fixer-
6668
6769
- name: "Run friendsofphp/php-cs-fixer"
6870
run: "vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --verbose"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/.build/
22
/.notes/
3+
/.phive/
34
/demo/obsidian/
4-
!/demo/obsidian/.gitkeep
55
/vendor/
6+
!/.phive/phars.xml
7+
!/demo/obsidian/.gitkeep

.phive/phars.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="composer-require-checker" version="^4.1.0" installed="4.1.0" location="./.phive/composer-require-checker" copy="true"/>
3+
<phar name="composer-require-checker" version="^4.5.0" installed="4.5.0" location="./.phive/composer-require-checker" copy="false"/>
44
</phive>

0 commit comments

Comments
 (0)