Skip to content

Commit 31590e5

Browse files
authored
Merge pull request #204 from ergebnis/feature/synchronize
Enhancement: Synchronize with `ergebnis/php-package-template`
2 parents 37dd01c + 9826233 commit 31590e5

18 files changed

+2559
-406
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ trim_trailing_whitespace = true
1010
[*.json]
1111
indent_size = 2
1212

13+
[*.md]
14+
indent_size = 2
15+
1316
[*.neon]
1417
indent_style = tab
1518

.gitattributes

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
/.editorconfig export-ignore
55
/.gitattributes export-ignore
66
/.gitignore export-ignore
7-
/.php_cs export-ignore
7+
/.php-cs-fixer.php export-ignore
8+
/.yamllint.yaml export-ignore
89
/composer-require-checker.json export-ignore
10+
/composer.lock export-ignore
911
/Makefile export-ignore
1012
/psalm-baseline.xml export-ignore
1113
/psalm.xml export-ignore
14+
/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: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ We are using [`yamllint`](https://github.com/adrienverge/yamllint) to enforce co
2020
If you do not have `yamllint` installed yet, run
2121

2222
```sh
23-
$ brew install yamllint
23+
brew install yamllint
2424
```
2525

2626
to install `yamllint`.
@@ -30,7 +30,7 @@ We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-C
3030
Run
3131

3232
```sh
33-
$ make coding-standards
33+
make coding-standards
3434
```
3535

3636
to automatically fix coding standard violations.
@@ -42,19 +42,43 @@ We are using [`maglnet/composer-require-checker`](https://github.com/maglnet/Com
4242
Run
4343

4444
```sh
45-
$ make dependency-analysis
45+
make dependency-analysis
4646
```
4747

4848
to run a dependency analysis.
4949

50+
## Refactoring
51+
52+
We are using [`rector/rector`](https://github.com/rectorphp/rector) to automatically refactor code.
53+
54+
Run
55+
56+
```sh
57+
make refactoring
58+
```
59+
60+
to automatically refactor code.
61+
62+
## Security Analysis
63+
64+
We are using [`composer`](https://github.com/composer/composer) to run a security analysis.
65+
66+
Run
67+
68+
```sh
69+
make security-analysis
70+
```
71+
72+
to run a security analysis.
73+
5074
## Static Code Analysis
5175

5276
We are using [`vimeo/psalm`](https://github.com/vimeo/psalm) to statically analyze the code.
5377

5478
Run
5579

5680
```sh
57-
$ make static-code-analysis
81+
make static-code-analysis
5882
```
5983

6084
to run a static code analysis.
@@ -64,7 +88,7 @@ We are also using the baseline feature of [`vimeo/psalm`](https://psalm.dev/docs
6488
Run
6589

6690
```sh
67-
$ make static-code-analysis-baseline
91+
make static-code-analysis-baseline
6892
```
6993

7094
to regenerate the baseline in [`../psalm-baseline.xml`](../psalm-baseline.xml).
@@ -78,7 +102,7 @@ We are using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) t
78102
Run
79103

80104
```sh
81-
$ make tests
105+
make tests
82106
```
83107

84108
to run all the tests.
@@ -88,7 +112,7 @@ to run all the tests.
88112
Run
89113

90114
```sh
91-
$ make
115+
make
92116
```
93117

94118
to enforce coding standards, run a static code analysis, and run tests!
@@ -98,7 +122,7 @@ to enforce coding standards, run a static code analysis, and run tests!
98122
:bulb: Run
99123

100124
```sh
101-
$ make help
125+
make help
102126
```
103127

104128
to display a list of available targets with corresponding descriptions.

.github/settings.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,19 @@ branches:
1313
require_code_owner_reviews: true
1414
required_approving_review_count: 1
1515
required_status_checks:
16-
contexts:
17-
- "Code Coverage (8.1, locked)"
18-
- "Coding Standards (8.1, locked)"
19-
- "Dependency Analysis (8.1, locked)"
20-
- "Security Analysis (8.1, locked)"
21-
- "Static Code Analysis (8.1, locked)"
22-
- "Tests (8.1, locked)"
23-
- "Tests (8.2, locked)"
16+
checks:
17+
- context: "Code Coverage (8.1, locked)"
18+
- context: "Coding Standards (8.1, locked)"
19+
- context: "Dependency Analysis (8.1, locked)"
20+
- context: "Refactoring (8.1, locked)"
21+
- context: "Security Analysis (8.1, locked)"
22+
- context: "Static Code Analysis (8.1, locked)"
23+
- context: "Tests (8.1, highest)"
24+
- context: "Tests (8.1, locked)"
25+
- context: "Tests (8.1, lowest)"
26+
- context: "Tests (8.2, highest)"
27+
- context: "Tests (8.2, locked)"
28+
- context: "Tests (8.2, lowest)"
2429
strict: false
2530
restrictions:
2631

@@ -72,6 +77,8 @@ repository:
7277
default_branch: "main"
7378
delete_branch_on_merge: true
7479
description: ":eyeglasses: Provides an extension for detecting slow tests in phpunit/phpunit."
80+
enable_automated_security_fixes: true
81+
enable_vulnerability_alerts: true
7582
has_downloads: true
7683
has_issues: true
7784
has_pages: false

.github/workflows/integrate.yaml

Lines changed: 80 additions & 6 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: "."
@@ -95,12 +95,13 @@ jobs:
9595
coverage: "none"
9696
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
9797
php-version: "${{ matrix.php-version }}"
98+
tools: "phive"
9899

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

102103
- name: "Validate composer.json and composer.lock"
103-
run: "composer validate --ansi"
104+
run: "composer validate --ansi --strict"
104105

105106
- name: "Determine composer cache directory"
106107
uses: "ergebnis/.github/actions/composer/[email protected]"
@@ -127,8 +128,15 @@ jobs:
127128
uses: "actions/[email protected]"
128129
with:
129130
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-"
131+
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }}"
132+
restore-keys: |
133+
php-${{ matrix.php-version }}-php-cs-fixer-main
134+
php-${{ matrix.php-version }}-php-cs-fixer-
135+
136+
- name: "Install dependencies with phive"
137+
uses: "ergebnis/.github/actions/phive/[email protected]"
138+
with:
139+
trust-gpg-keys: "0x033E5F8D801A2F8D,0xE82B2FB314E9906E"
132140

133141
- name: "Run friendsofphp/php-cs-fixer"
134142
run: ".phive/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --dry-run --verbose"
@@ -156,6 +164,7 @@ jobs:
156164
coverage: "none"
157165
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
158166
php-version: "${{ matrix.php-version }}"
167+
tools: "phive"
159168

160169
- name: "Set up problem matchers for PHP"
161170
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
@@ -175,9 +184,71 @@ jobs:
175184
with:
176185
dependencies: "${{ matrix.dependencies }}"
177186

187+
- name: "Install dependencies with phive"
188+
uses: "ergebnis/.github/actions/phive/[email protected]"
189+
with:
190+
trust-gpg-keys: "0x033E5F8D801A2F8D,0xE82B2FB314E9906E"
191+
178192
- name: "Run maglnet/composer-require-checker"
179193
run: ".phive/composer-require-checker check --config-file=$(pwd)/composer-require-checker.json"
180194

195+
refactoring:
196+
name: "Refactoring"
197+
198+
runs-on: "ubuntu-latest"
199+
200+
strategy:
201+
matrix:
202+
php-version:
203+
- "8.1"
204+
205+
dependencies:
206+
- "locked"
207+
208+
steps:
209+
- name: "Checkout"
210+
uses: "actions/[email protected]"
211+
212+
- name: "Set up PHP"
213+
uses: "shivammathur/[email protected]"
214+
with:
215+
coverage: "none"
216+
extensions: "none, ctype, dom, intl, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
217+
php-version: "${{ matrix.php-version }}"
218+
219+
- name: "Set up problem matchers for PHP"
220+
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
221+
222+
- name: "Determine composer cache directory"
223+
uses: "ergebnis/.github/actions/composer/[email protected]"
224+
225+
- name: "Cache dependencies installed with composer"
226+
uses: "actions/[email protected]"
227+
with:
228+
path: "${{ env.COMPOSER_CACHE_DIR }}"
229+
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
230+
restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-"
231+
232+
- name: "Install ${{ matrix.dependencies }} dependencies with composer"
233+
uses: "ergebnis/.github/actions/composer/[email protected]"
234+
with:
235+
dependencies: "${{ matrix.dependencies }}"
236+
237+
- name: "Create cache directory for rector/rector"
238+
run: "mkdir -p .build/rector"
239+
240+
- name: "Cache cache directory for rector/rector"
241+
uses: "actions/[email protected]"
242+
with:
243+
path: ".build/rector"
244+
key: "php-${{ matrix.php-version }}-rector-${{ github.ref_name }}"
245+
restore-keys: |
246+
php-${{ matrix.php-version }}-rector-main
247+
php-${{ matrix.php-version }}-rector-
248+
249+
- name: "Run automated refactoring with rector/rector"
250+
run: "vendor/bin/rector --ansi --config=rector.php --dry-run"
251+
181252
security-analysis:
182253
name: "Security Analysis"
183254

@@ -206,7 +277,7 @@ jobs:
206277
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
207278

208279
- name: "Validate composer.json and composer.lock"
209-
run: "composer validate --ansi"
280+
run: "composer validate --ansi --strict"
210281

211282
- name: "Check installed packages for security vulnerability advisories"
212283
run: "composer audit --ansi"
@@ -234,6 +305,7 @@ jobs:
234305
coverage: "none"
235306
extensions: "none, ctype, curl, dom, json, mbstring, pcntl, phar, posix, simplexml, tokenizer, xml, xmlwriter"
236307
php-version: "${{ matrix.php-version }}"
308+
tools: "phive"
237309

238310
- name: "Set up problem matchers for PHP"
239311
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
@@ -257,7 +329,7 @@ jobs:
257329
run: "mkdir -p .build/psalm"
258330

259331
- name: "Run vimeo/psalm"
260-
run: ".phive/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4"
332+
run: "vendor/bin/psalm --config=psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4"
261333

262334
tests:
263335
name: "Tests"
@@ -271,7 +343,9 @@ jobs:
271343
- "8.2"
272344

273345
dependencies:
346+
- "lowest"
274347
- "locked"
348+
- "highest"
275349

276350
steps:
277351
- name: "Checkout"

.github/workflows/renew.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ jobs:
3232
coverage: "none"
3333
extensions: "none, ctype, dom, json, mbstring, phar, simplexml, tokenizer, xml, xmlwriter"
3434
php-version: "${{ matrix.php-version }}"
35+
tools: "phive"
3536

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

3940
- name: "Validate composer.json and composer.lock"
40-
run: "composer validate --ansi"
41+
run: "composer validate --ansi --strict"
4142

4243
- name: "Determine composer cache directory"
4344
uses: "ergebnis/.github/actions/composer/[email protected]"
@@ -61,8 +62,15 @@ jobs:
6162
uses: "actions/[email protected]"
6263
with:
6364
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-"
65+
key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.ref_name }}"
66+
restore-keys: |
67+
php-${{ matrix.php-version }}-php-cs-fixer-main
68+
php-${{ matrix.php-version }}-php-cs-fixer-
69+
70+
- name: "Install dependencies with phive"
71+
uses: "ergebnis/.github/actions/phive/[email protected]"
72+
with:
73+
trust-gpg-keys: "0x033E5F8D801A2F8D,0xE82B2FB314E9906E"
6674

6775
- name: "Run friendsofphp/php-cs-fixer"
6876
run: ".phive/php-cs-fixer fix --ansi --config=.php-cs-fixer.php --diff --verbose"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/.build/
22
/.notes/
3+
/.phive/
34
/vendor/
5+
!/.phive/phars.xml

.phive/composer-require-checker

-633 KB
Binary file not shown.

.phive/phars.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="composer-require-checker" version="^4.5.0" installed="4.5.0" location="./.phive/composer-require-checker" copy="true"/>
4-
<phar name="php-cs-fixer" version="^3.14.3" installed="3.14.3" location="./.phive/php-cs-fixer" copy="true"/>
5-
<phar name="psalm" version="^5.6.0" installed="5.6.0" location="./.phive/psalm" copy="true"/>
3+
<phar name="composer-require-checker" version="^4.5.0" installed="4.5.0" location="./.phive/composer-require-checker" copy="false"/>
4+
<phar name="php-cs-fixer" version="^3.14.3" installed="3.14.3" location="./.phive/php-cs-fixer" copy="false"/>
65
</phive>

0 commit comments

Comments
 (0)