Skip to content

Commit a246bce

Browse files
Tsvetan StoychevTsvetan Stoychev
authored andcommitted
Add automated quality and dependency controls
1 parent e6f631b commit a246bce

13 files changed

Lines changed: 311 additions & 15 deletions

File tree

‎.github/dependabot.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: composer
5+
directory: /plugins/basicrum
6+
schedule:
7+
interval: weekly
8+
day: monday
9+
time: "05:00"
10+
timezone: Europe/Berlin
11+
open-pull-requests-limit: 5
12+
13+
- package-ecosystem: github-actions
14+
directory: /
15+
schedule:
16+
interval: weekly
17+
day: monday
18+
time: "05:30"
19+
timezone: Europe/Berlin
20+
open-pull-requests-limit: 5

‎.github/workflows/ci.yml‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,41 @@ on:
88
pull_request:
99
workflow_dispatch:
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
15+
quality:
16+
name: Static and dependency analysis
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v5
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '8.2'
27+
tools: composer:v2
28+
coverage: none
29+
30+
- name: Validate Composer metadata
31+
working-directory: plugins/basicrum
32+
run: composer validate --strict
33+
34+
- name: Audit locked dependencies
35+
working-directory: plugins/basicrum
36+
run: composer audit --locked
37+
38+
- name: Install dependencies
39+
working-directory: plugins/basicrum
40+
run: composer install --no-interaction --prefer-dist
41+
42+
- name: Static analysis
43+
working-directory: plugins/basicrum
44+
run: composer analyse
45+
1246
translations:
1347
name: Translation catalogs
1448
runs-on: ubuntu-latest
@@ -128,6 +162,7 @@ jobs:
128162
name: Release ZIP smoke test
129163
runs-on: ubuntu-latest
130164
needs:
165+
- quality
131166
- translations
132167
- unit
133168
- integration

‎.github/workflows/prerelease.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
release:
55
types: [prereleased]
66

7+
permissions:
8+
contents: write
9+
710
jobs:
811
build:
912
name: Build Plugin Artifact

‎.github/workflows/release.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
release:
55
types: [released]
66

7+
permissions:
8+
contents: write
9+
710
jobs:
811
build:
912
name: Build Release Artifact

‎AGENTS.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ Run from the repository root:
3535
```bash
3636
make composer-install
3737
make lint-php
38+
make lint
39+
make analyse
40+
make composer-validate
41+
make composer-audit
3842
make unit
3943
make integration-setup
4044
make integration

‎Makefile‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TEST_DB_PASS = root
1212
TEST_DB_HOST = db
1313
WP_TEST_VERSION ?= latest
1414

15-
.PHONY: help build up down restart logs shell composer-install wp-install lint lint-fix lint-php translations integration-setup integration test package package-verify package-smoke clean
15+
.PHONY: help build up down restart logs shell composer-install wp-install lint lint-fix lint-php analyse composer-validate composer-audit translations integration-setup integration test package package-verify package-smoke clean
1616

1717
help:
1818
@echo "Targets:"
@@ -27,6 +27,9 @@ help:
2727
@echo " lint-php Run PHP syntax lint"
2828
@echo " lint Run PHPCS"
2929
@echo " lint-fix Run PHPCBF"
30+
@echo " analyse Run PHPStan static analysis"
31+
@echo " composer-validate Validate Composer metadata and lock file"
32+
@echo " composer-audit Audit locked Composer dependencies"
3033
@echo " translations Update POT, PO, and MO translation catalogs"
3134
@echo " unit Run unit tests"
3235
@echo " integration-setup Install WordPress test suite inside containers"
@@ -70,6 +73,15 @@ lint:
7073
lint-fix:
7174
$(COMPOSE) run --rm -w $(PLUGIN_WORKDIR) $(PHP_SERVICE) composer lint:fix
7275

76+
analyse:
77+
$(COMPOSE) run --rm -w $(PLUGIN_WORKDIR) $(PHP_SERVICE) composer analyse
78+
79+
composer-validate:
80+
$(COMPOSE) run --rm -w $(PLUGIN_WORKDIR) $(PHP_SERVICE) composer validate --strict
81+
82+
composer-audit:
83+
$(COMPOSE) run --rm -w $(PLUGIN_WORKDIR) $(PHP_SERVICE) composer audit --locked
84+
7385
translations:
7486
$(COMPOSE) run --rm --no-deps --user "$$(id -u):$$(id -g)" -e HOME=/tmp -w $(WPCLI_PLUGIN_WORKDIR) $(WPCLI_SERVICE) sh /tools/update-translations.sh .
7587

‎README.md‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ make unit
2222
make integration-setup
2323
make integration
2424
make lint
25+
make analyse
26+
make composer-validate
27+
make composer-audit
2528
make translations
2629
make package
2730
make package-smoke
@@ -66,3 +69,16 @@ WordPress logs contain PHP warnings or fatal errors.
6669
CI runs this same build and smoke-test path and retains both the ZIP and its
6770
SHA-256 checksum as workflow artifacts. Release and pre-release workflows attach
6871
both files to the GitHub release.
72+
73+
## Automated Quality Controls
74+
75+
`make analyse` runs PHPStan level 5 with WordPress-aware stubs. The enforced
76+
configuration is stored in `plugins/basicrum/phpstan.neon.dist`.
77+
78+
`make composer-validate` checks Composer metadata and lock-file consistency in
79+
strict mode. `make composer-audit` checks the complete lock file against current
80+
security advisories. CI runs all three checks on every push and pull request.
81+
82+
Dependabot checks Composer dependencies and GitHub Actions weekly. CI workflows
83+
use a read-only `GITHUB_TOKEN`; release and pre-release workflows receive only
84+
the `contents: write` permission required to attach release assets.

‎checklist.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ Acceptance criteria:
101101

102102
## 6. Add stronger automated analysis and dependency controls
103103

104-
- [ ] Add PHPStan with WordPress stubs and select an initial enforced level.
105-
- [ ] Add `composer validate --strict` to CI.
106-
- [ ] Add `composer audit --locked` to CI.
107-
- [ ] Configure dependency update automation for Composer and GitHub Actions.
108-
- [ ] Set explicit minimal `GITHUB_TOKEN` permissions in every workflow.
109-
- [ ] Give release workflows only the additional permissions required to upload
104+
- [x] Add PHPStan with WordPress stubs and select an initial enforced level.
105+
- [x] Add `composer validate --strict` to CI.
106+
- [x] Add `composer audit --locked` to CI.
107+
- [x] Configure dependency update automation for Composer and GitHub Actions.
108+
- [x] Set explicit minimal `GITHUB_TOKEN` permissions in every workflow.
109+
- [x] Give release workflows only the additional permissions required to upload
110110
assets.
111111
- [ ] Pin third-party GitHub Actions to immutable commit SHAs.
112112
- [ ] Document how pinned actions are reviewed and updated.
113113

114114
Acceptance criteria:
115115

116-
- [ ] Type issues, invalid package metadata, known dependency advisories, and
116+
- [x] Type issues, invalid package metadata, known dependency advisories, and
117117
excessive workflow permissions are checked automatically.
118118

119119
## 7. Make JavaScript and translation artifacts reproducible
@@ -153,8 +153,8 @@ Acceptance criteria:
153153
- [ ] PHP unit tests pass across the supported PHP matrix.
154154
- [ ] WordPress integration tests pass across the supported WordPress matrix.
155155
- [ ] JavaScript tests pass.
156-
- [ ] Static analysis passes.
157-
- [ ] Composer validation and audit pass.
156+
- [x] Static analysis passes.
157+
- [x] Composer validation and audit pass.
158158
- [ ] Generated asset checks pass.
159159
- [x] The packaged ZIP smoke test passes.
160160
- [ ] Version and repository convention checks pass.

‎plugins/basicrum/composer.json‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
"composer/installers": "^1.0 || ^2.0"
1515
},
1616
"require-dev": {
17+
"php-parallel-lint/php-parallel-lint": "^1.3",
18+
"phpcompatibility/phpcompatibility-wp": "^2.1",
19+
"phpstan/phpstan": "^2.1",
1720
"squizlabs/php_codesniffer": "^3.7",
21+
"szepeviktor/phpstan-wordpress": "^2.0",
1822
"wp-coding-standards/wpcs": "^3.0",
19-
"phpcompatibility/phpcompatibility-wp": "^2.1",
20-
"yoast/wp-test-utils": "^1.2",
21-
"php-parallel-lint/php-parallel-lint": "^1.3"
23+
"yoast/wp-test-utils": "^1.2"
2224
},
2325
"autoload": {
2426
"psr-4": {
@@ -31,6 +33,7 @@
3133
}
3234
},
3335
"scripts": {
36+
"analyse": "phpstan analyse --configuration=phpstan.neon.dist --no-progress --memory-limit=512M",
3437
"lint": "phpcs --standard=phpcs.ruleset.xml",
3538
"lint:fix": "phpcbf --standard=phpcs.ruleset.xml",
3639
"lint:php": "parallel-lint --exclude vendor --exclude node_modules .",

0 commit comments

Comments
 (0)