Skip to content

Commit 4fc4176

Browse files
committed
Add composer scripts
1 parent 33e23ae commit 4fc4176

File tree

3 files changed

+44
-21
lines changed

3 files changed

+44
-21
lines changed

CONTRIBUTING.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ Composer.
2626

2727
The test suite may be executed with:
2828

29-
```
30-
$ vendor/bin/simple-phpunit
29+
```console
30+
$ composer run test
3131
```
3232

3333
The `phpunit.xml.dist` file is used as the default configuration file for the
@@ -47,7 +47,7 @@ By default, the `simple-phpunit` binary chooses the correct PHPUnit version for
4747
the PHP version you are running. To run tests against a specific PHPUnit
4848
version, use the `SYMFONY_PHPUNIT_VERSION` environment variable:
4949

50-
```
50+
```console
5151
$ SYMFONY_PHPUNIT_VERSION=7.5 vendor/bin/simple-phpunit
5252
```
5353

@@ -108,55 +108,63 @@ The following environment variables are used for [CSFLE testing](https://github.
108108
* `KMS_TLS_CA_FILE`
109109
* `KMS_TLS_CERTIFICATE_KEY_FILE`
110110

111-
## Checking coding standards
111+
## Code quality
112+
113+
Before submitting a pull request, please ensure that your code adheres to the
114+
coding standards and passes static analysis checks.
115+
116+
```console
117+
$ composer run checks
118+
```
119+
120+
### Coding standards
112121

113122
The library's code is checked using [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer),
114123
which is installed as a development dependency by Composer. To check the code
115124
for style errors, run the `phpcs` binary:
116125

117-
118-
```
126+
```console
119127
$ vendor/bin/phpcs
120128
```
121129

122130
To automatically fix all fixable errors, use the `phpcbf` binary:
123131

124-
```
132+
```console
125133
$ vendor/bin/phpcbf
126134
```
127135

128-
## Running static analysis
136+
### Static analysis
129137

130138
The library uses [psalm](https://psalm.dev) to run static analysis on the code
131139
and ensure an additional level of type safety. New code is expected to adhere
132140
to level 1, with a baseline covering existing issues. To run static analysis
133141
checks, run the `psalm` binary:
134142

135-
```
143+
```console
136144
$ vendor/bin/psalm
137145
```
138146

139147
To remove fixed errors from the baseline, you can use the `update-baseline`
140148
command-line argument:
141149

142-
```
150+
```console
143151
$ vendor/bin/psalm --update-baseline
144152
```
145153

146154
Note that this will not add new errors to the baseline. New errors should be
147155
fixed instead of being added to the technical debt, but in case this isn't
148156
possible it can be added to the baseline using `set-baseline`:
149157

150-
```
158+
```console
151159
$ vendor/bin/psalm --set-baseline=psalm-baseline.xml
152160
```
153161

154-
## Automatic code refactoring
162+
### Refactoring
155163

156164
The library uses [rector](https://getrector.com/) to refactor the code for new features.
157165
To run automatic refactoring, use the `rector` command:
158166

159-
```
167+
```console
160168
$ vendor/bin/rector
161169
```
162170

@@ -178,7 +186,7 @@ repository:
178186
repository.
179187
* Create and activate Python 2.7 virtual environment if necessary.
180188

181-
```
189+
```console
182190
$ virtualenv -p python2.7 venv
183191
$ source venv/bin/activate
184192
```

RELEASING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ the Evergreen configuration should be updated:
7676

7777
Commit and push any changes:
7878

79-
```
79+
```console
8080
$ git commit -m "Update composer.json and CI matrices for X.Y.Z" composer.json .evergreen/config.yml
8181
$ git push mongodb
8282
```
@@ -85,7 +85,7 @@ $ git push mongodb
8585

8686
Create a tag for the release and push:
8787

88-
```
88+
```console
8989
$ git tag -a -m "Release X.Y.Z" X.Y.Z
9090
$ git push mongodb --tags
9191
```
@@ -119,7 +119,7 @@ The above would be changed to:
119119

120120
Commit this change:
121121

122-
```
122+
```console
123123
$ git commit -m "Master is now 1.10-dev" composer.json
124124
```
125125

@@ -128,7 +128,7 @@ $ git commit -m "Master is now 1.10-dev" composer.json
128128
After a new minor version is released (i.e. `master` was tagged), a maintenance
129129
branch should be created for future patch releases:
130130

131-
```
131+
```console
132132
$ git checkout -b vX.Y
133133
$ git push mongodb vX.Y
134134
```
@@ -146,7 +146,7 @@ Update the master branch alias in `composer.json`:
146146

147147
Commit and push this change:
148148

149-
```
149+
```console
150150
$ git commit -m "Master is now X.Y-dev" composer.json
151151
$ git push mongodb
152152
```
@@ -155,7 +155,7 @@ $ git push mongodb
155155

156156
If this was a patch release, the maintenance branch must be merged up to master:
157157

158-
```
158+
```console
159159
$ git checkout master
160160
$ git pull mongodb master
161161
$ git merge vX.Y --strategy=ours

composer.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"license": "Apache-2.0",
77
"authors": [
88
{ "name": "Andreas Braun", "email": "andreas.braun@mongodb.com" },
9-
{ "name": "Jeremy Mikola", "email": "jmikola@gmail.com" }
9+
{ "name": "Jeremy Mikola", "email": "jmikola@gmail.com" },
10+
{ "name": "Jérôme Tamarelle", "email": "jerome.tamarelle@mongodb.com" }
1011
],
1112
"require": {
1213
"php": "^7.2 || ^8.0",
@@ -33,6 +34,20 @@
3334
"psr-4": { "MongoDB\\Tests\\": "tests/" },
3435
"files": [ "tests/PHPUnit/Functions.php" ]
3536
},
37+
"scripts": {
38+
"checks": [
39+
"@check:cs",
40+
"@check:psalm",
41+
"@check:rector"
42+
],
43+
"check:cs": "phpcs",
44+
"check:psalm": "psalm",
45+
"check:rector": "rector --ansi --dry-run",
46+
"fix:cs": "phpcbf",
47+
"fix:psalm:baseline": "psalm --set-baseline=psalm-baseline.xml",
48+
"fix:rector": "rector process --ansi",
49+
"test": "simple-phpunit"
50+
},
3651
"extra": {
3752
"branch-alias": {
3853
"dev-master": "1.17.x-dev"

0 commit comments

Comments
 (0)