Skip to content

Commit 4bd51c0

Browse files
Merge pull request #642 from eliashaeussler/task/scripts
[TASK] Consolidate Composer & npm checks
2 parents a226046 + e1e2abb commit 4bd51c0

4 files changed

Lines changed: 107 additions & 99 deletions

File tree

.github/workflows/cgl.yaml

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -42,45 +42,18 @@ jobs:
4242
node-version: 24
4343
cache: npm
4444

45-
# Validation
46-
- name: Validate composer.json
47-
run: composer validate --no-check-lock
48-
4945
# Install dependencies
5046
- name: Install Composer dependencies
5147
uses: ramsey/composer-install@5c2bcf28d7b060ef3c601d7b476d5430a7b46c27 #v4
5248
- name: Install Frontend dependencies
5349
run: npm ci
5450

55-
# Audit packages
56-
- name: Audit Composer dependencies
57-
run: npm audit
58-
- name: Audit Frontend dependencies
59-
run: composer audit
60-
61-
# Analyze
62-
- name: Analyze Composer dependencies
63-
run: composer analyze:dependencies
64-
- name: Check for unused Frontend dependencies
65-
run: npm run check-dependencies
66-
67-
# Linting
68-
- name: Lint composer.json
69-
run: composer lint:composer
70-
- name: Lint Editorconfig
71-
run: composer lint:editorconfig
72-
- name: Lint PHP
73-
run: composer lint:php
74-
- name: Lint shell files
75-
run: bash -c 'shopt -s globstar nullglob; shellcheck tests/e2e/**/*.sh'
76-
77-
# SCA
78-
- name: SCA PHP
79-
run: composer sca:php -- --error-format github
80-
81-
# Migration
82-
- name: Run Rector migration
83-
run: composer migration:rector -- --dry-run
51+
# Perform checks
52+
- name: Perform Composer checks
53+
run: composer ci
54+
shell: bash
55+
- name: Perform npm checks
56+
run: npm run ci
8457

8558
# Zizmor
8659
- name: Run zizmor

composer.json

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,38 +77,55 @@
7777
}
7878
},
7979
"scripts": {
80-
"analyze": [
81-
"@analyze:dependencies"
80+
"check": [
81+
"@check:deps",
82+
"@check:refactor",
83+
"@check:static",
84+
"@check:style"
85+
],
86+
"check:deps": "composer-dependency-analyser --config build/composer-dependency-analyser.php",
87+
"check:refactor": [
88+
"@check:refactor:php"
89+
],
90+
"check:refactor:php": "@refactor:php --dry-run",
91+
"check:static": "phpstan analyse -c build/phpstan.php",
92+
"check:style": [
93+
"@check:style:composer",
94+
"@check:style:editorconfig",
95+
"@check:style:php",
96+
"@check:style:shell"
97+
],
98+
"check:style:composer": "@fix:composer --dry-run",
99+
"check:style:editorconfig": "ec",
100+
"check:style:php": "@fix:php --dry-run",
101+
"check:style:shell": "find tests/e2e -name '*.sh' -print0 | xargs -0 -I{} shellcheck {}",
102+
"ci": [
103+
"@composer validate",
104+
"@composer audit",
105+
"@check:deps",
106+
"@check:refactor",
107+
"@check:static --error-format github",
108+
"@check:style"
82109
],
83-
"analyze:dependencies": "composer-dependency-analyser --config build/composer-dependency-analyser.php",
84110
"fix": [
85111
"@fix:composer",
86112
"@fix:editorconfig",
87113
"@fix:php"
88114
],
89115
"fix:composer": "@composer normalize",
90-
"fix:editorconfig": "@lint:editorconfig --fix",
116+
"fix:editorconfig": "@check:style:editorconfig --fix",
91117
"fix:php": "php-cs-fixer fix --config build/.php-cs-fixer.php",
92-
"lint": [
93-
"@lint:composer",
94-
"@lint:editorconfig",
95-
"@lint:php"
118+
"refactor": [
119+
"@refactor:php"
96120
],
97-
"lint:composer": "@fix:composer --dry-run",
98-
"lint:editorconfig": "ec",
99-
"lint:php": "@fix:php --dry-run",
100-
"migration": [
101-
"@migration:rector"
102-
],
103-
"migration:rector": "rector process -c build/rector.php",
104-
"sca": [
105-
"@sca:php"
106-
],
107-
"sca:php": "phpstan analyse -c build/phpstan.php",
121+
"refactor:php": "rector process -c build/rector.php",
108122
"test": [
109123
"@test:e2e",
110124
"@test:unit"
111125
],
126+
"test:coverage": [
127+
"@test:unit:coverage"
128+
],
112129
"test:e2e": "tests/e2e/run.sh",
113130
"test:e2e:docker": "@test:e2e docker",
114131
"test:e2e:phar": "@test:e2e phar",

docs/contribution-guide.md

Lines changed: 63 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Contribution guide
22

3-
Thanks for considering contributing to this project! Each contribution is
4-
highly appreciated. In order to maintain a high code quality, please follow
5-
all steps below.
3+
Thanks for considering contributing to this project. Contributions of any size are highly appreciated.
4+
5+
To keep the code base consistent and maintainable, please follow the workflow described below before
6+
submitting a pull request.
67

78
## Requirements
89

910
- PHP >= 8.2
10-
- Docker (when running E2E tests)
11-
- GPG (when running E2E tests)
12-
- [`jq`](https://github.com/jqlang/jq) (when running E2E tests)
11+
- Composer
12+
- Docker (for E2E tests)
13+
- GPG (for E2E tests)
14+
- [`jq`](https://github.com/jqlang/jq) (for E2E tests)
1315

1416
## Preparation
1517

@@ -22,81 +24,96 @@ cd cache-warmup
2224
composer install
2325
```
2426

25-
## Run code analyzers
27+
## Development workflow
2628

27-
```bash
28-
# All analyzers
29-
composer analyze
29+
A typical contribution workflow looks like this:
3030

31-
# Specific analyzers
32-
composer analyze:dependencies
33-
```
31+
1. Apply automatic fixes.
32+
2. Run all checks.
33+
3. Run the test suite.
34+
4. Submit a pull request.
3435

35-
## Run linters
36+
### Apply automatic fixes
3637

37-
```bash
38-
# All linters
39-
composer lint
38+
Use the following commands to normalize and format the code base:
4039

41-
# Specific linters
42-
composer lint:composer
43-
composer lint:editorconfig
44-
composer lint:php
45-
46-
# Fix all CGL issues
40+
```bash
41+
# Apply all automatic fixes
4742
composer fix
4843

49-
# Fix specific CGL issues
44+
# Apply specific fixes
5045
composer fix:composer
5146
composer fix:editorconfig
5247
composer fix:php
5348
```
5449

55-
## Run static code analysis
50+
### Run checks
51+
52+
Use `composer check` to run the full code quality pipeline locally. This command bundles dependency analysis,
53+
static analysis, coding style checks, and Rector in dry-run mode so that potential refactorings can be reviewed
54+
without changing files.
5655

5756
```bash
58-
# All static code analyzers
59-
composer sca
57+
# Run all checks
58+
composer check
59+
60+
# Run specific checks
61+
composer check:deps
62+
composer check:refactor
63+
composer check:static
64+
composer check:style
65+
66+
# Run specific style checks
67+
composer check:style:composer
68+
composer check:style:editorconfig
69+
composer check:style:php
70+
```
71+
72+
### Run refactorings
73+
74+
Refactorings are intentionally separated from regular checks because they may change the code base.
6075

61-
# Specific static code analyzers
62-
composer sca:php
76+
```bash
77+
# Run all configured refactorings
78+
composer refactor
79+
80+
# Run specific refactorings
81+
composer refactor:php
6382
```
6483

65-
## Run tests
84+
### Run tests
85+
86+
Run the full test suite before opening a pull request:
6687

6788
```bash
68-
# All tests
89+
# Run all tests
6990
composer test
7091

71-
# E2E tests
92+
# Run E2E tests
7293
composer test:e2e
7394
composer test:e2e:docker
7495
composer test:e2e:phar
7596

76-
# Unit tests
97+
# Run unit tests
7798
composer test:unit
7899

79-
# Unit tests with code coverage
100+
# Run unit tests with code coverage
80101
composer test:unit:coverage
81102
```
82103

83-
### Test reports
104+
## Coverage reports
84105

85-
Code coverage reports are written to `.build/coverage`. You can open the
86-
last HTML report like follows:
106+
Code coverage reports are written to `.build/coverage`. Open the latest HTML report with:
87107

88108
```bash
89109
open .build/coverage/html/index.html
90110
```
91111

92-
## Submit a pull request
112+
## Pull requests
93113

94-
Once you have finished your work, please
95-
[**submit a pull request**](https://github.com/eliashaeussler/cache-warmup/compare)
96-
and describe what you've done. Ideally, your PR references an issue describing
97-
the problem you're trying to solve.
114+
Once the changes are ready, please [submit a pull request](https://github.com/eliashaeussler/cache-warmup/compare)
115+
and describe what was changed and why. Ideally, the pull request references an issue that describes the
116+
problem being solved.
98117

99-
All described code quality tools are automatically executed on each pull request
100-
for all currently supported PHP versions. Take a look at the appropriate
101-
[workflows](../.github/workflows)
102-
to get a detailed overview.
118+
All documented code quality tools are executed automatically for pull requests across the currently
119+
supported PHP versions. For details, refer to the [GitHub Actions workflows](../.github/workflows).

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"typescript": "^6.0.0"
2525
},
2626
"scripts": {
27-
"check-dependencies": "knip -c build/knip.json",
27+
"ci": "npm audit && npm run check:deps",
28+
"check:deps": "knip -c build/knip.json",
2829
"docs:dev": "vitepress dev docs --open",
2930
"docs:build": "vitepress build docs",
3031
"docs:preview": "vitepress preview docs --open"

0 commit comments

Comments
 (0)