Skip to content

Commit ac27b5a

Browse files
committed
Updated readme for phpcs usage, aligned gh action workflows
1 parent ecbc734 commit ac27b5a

5 files changed

Lines changed: 40 additions & 22 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
name: phpstan
1+
name: analyse-php
22

33
on: [push, pull_request]
44

55
jobs:
66
build:
77
if: ${{ github.ref != 'refs/heads/l10n_development' }}
8-
runs-on: ubuntu-20.04
9-
strategy:
10-
matrix:
11-
php: ['7.4']
8+
runs-on: ubuntu-22.04
129
steps:
1310
- uses: actions/checkout@v1
1411

1512
- name: Setup PHP
1613
uses: shivammathur/setup-php@v2
1714
with:
18-
php-version: ${{ matrix.php }}
15+
php-version: 8.1
1916
extensions: gd, mbstring, json, curl, xml, mysql, ldap
2017

2118
- name: Get Composer Cache Directory
@@ -24,13 +21,14 @@ jobs:
2421
echo "::set-output name=dir::$(composer config cache-files-dir)"
2522
2623
- name: Cache composer packages
27-
uses: actions/cache@v1
24+
uses: actions/cache@v2
2825
with:
2926
path: ${{ steps.composer-cache.outputs.dir }}
30-
key: ${{ runner.os }}-composer-${{ matrix.php }}
27+
key: ${{ runner.os }}-composer-8.1
28+
restore-keys: ${{ runner.os }}-composer-
3129

3230
- name: Install composer dependencies
3331
run: composer install --prefer-dist --no-interaction --ansi
3432

35-
- name: Run PHPStan
36-
run: php${{ matrix.php }} ./vendor/bin/phpstan analyse --memory-limit=2G
33+
- name: Run static analysis check
34+
run: composer check-static

.github/workflows/test-migrations.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on: [push, pull_request]
55
jobs:
66
build:
77
if: ${{ github.ref != 'refs/heads/l10n_development' }}
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
99
strategy:
1010
matrix:
1111
php: ['7.4', '8.0', '8.1']
@@ -24,10 +24,11 @@ jobs:
2424
echo "::set-output name=dir::$(composer config cache-files-dir)"
2525
2626
- name: Cache composer packages
27-
uses: actions/cache@v1
27+
uses: actions/cache@v2
2828
with:
2929
path: ${{ steps.composer-cache.outputs.dir }}
3030
key: ${{ runner.os }}-composer-${{ matrix.php }}
31+
restore-keys: ${{ runner.os }}-composer-
3132

3233
- name: Start MySQL
3334
run: |
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: phpunit
1+
name: test-php
22

33
on: [push, pull_request]
44

55
jobs:
66
build:
77
if: ${{ github.ref != 'refs/heads/l10n_development' }}
8-
runs-on: ubuntu-20.04
8+
runs-on: ubuntu-22.04
99
strategy:
1010
matrix:
1111
php: ['7.4', '8.0', '8.1']
@@ -24,10 +24,11 @@ jobs:
2424
echo "::set-output name=dir::$(composer config cache-files-dir)"
2525
2626
- name: Cache composer packages
27-
uses: actions/cache@v1
27+
uses: actions/cache@v2
2828
with:
2929
path: ${{ steps.composer-cache.outputs.dir }}
3030
key: ${{ runner.os }}-composer-${{ matrix.php }}
31+
restore-keys: ${{ runner.os }}-composer-
3132

3233
- name: Start Database
3334
run: |
@@ -48,5 +49,5 @@ jobs:
4849
php${{ matrix.php }} artisan migrate --force -n --database=mysql_testing
4950
php${{ matrix.php }} artisan db:seed --force -n --class=DummyContentSeeder --database=mysql_testing
5051
51-
- name: phpunit
52+
- name: Run PHP tests
5253
run: php${{ matrix.php }} ./vendor/bin/phpunit

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
}
7070
},
7171
"scripts": {
72+
"check-static": "phpstan --memory-limit=2g",
7273
"format": "phpcbf",
7374
"lint": "phpcs",
7475
"test": "phpunit",

readme.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
[![GitHub release](https://img.shields.io/github/release/BookStackApp/BookStack.svg)](https://github.com/BookStackApp/BookStack/releases/latest)
44
[![license](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/BookStackApp/BookStack/blob/development/LICENSE)
55
[![Crowdin](https://badges.crowdin.net/bookstack/localized.svg)](https://crowdin.com/project/bookstack)
6-
[![Build Status](https://github.com/BookStackApp/BookStack/workflows/phpunit/badge.svg)](https://github.com/BookStackApp/BookStack/actions)
7-
[![StyleCI](https://github.styleci.io/repos/41589337/shield?style=flat)](https://github.styleci.io/repos/41589337)
6+
[![Build Status](https://github.com/BookStackApp/BookStack/workflows/test-php/badge.svg)](https://github.com/BookStackApp/BookStack/actions)
7+
[![Lint Status](https://github.com/BookStackApp/BookStack/workflows/lint-php/badge.svg)](https://github.com/BookStackApp/BookStack/actions)
88
[![Maintainability](https://api.codeclimate.com/v1/badges/5551731994dd22fa1f4f/maintainability)](https://codeclimate.com/github/BookStackApp/BookStack/maintainability)
99

1010
[![Repo Stats](https://img.shields.io/static/v1?label=GitHub+project&message=stats&color=f27e3f)](https://gh-stats.bookstackapp.com/)
@@ -115,12 +115,29 @@ php artisan migrate --database=mysql_testing
115115
php artisan db:seed --class=DummyContentSeeder --database=mysql_testing
116116
```
117117

118-
Once done you can run `php vendor/bin/phpunit` in the application root directory to run all tests.
118+
Once done you can run `composer test` in the application root directory to run all tests.
119119

120120
### 📜 Code Standards
121121

122-
PHP code style is enforced automatically [using StyleCI](https://github.styleci.io/repos/41589337).
123-
If submitting a PR, any formatting changes to be made will be automatically fixed after merging.
122+
PHP code standards are managed by [using PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
123+
Static analysis is in place using [PHPStan](https://phpstan.org/) & [Larastan](https://github.com/nunomaduro/larastan).
124+
The below commands can be used to utilise these tools:
125+
126+
```bash
127+
# Run code linting using PHP_CodeSniffer
128+
composer lint
129+
130+
# As above, but show rule names in output
131+
composer lint -- -s
132+
133+
# Auto-fix formatting & lint issues via PHP_CodeSniffer phpcbf
134+
composer format
135+
136+
# Run static analysis via larastan/phpstan
137+
composer check-static
138+
```
139+
140+
If submitting a PR, formatting as per our project standards would help for clarity but don't worry too much about using/understanding these tools as we can always address issues at a later stage when they're picked up by our automated tools.
124141

125142
### 🐋 Development using Docker
126143

@@ -234,9 +251,9 @@ Note: This is not an exhaustive list of all libraries and projects that would be
234251
* [OneLogin's SAML PHP Toolkit](https://github.com/onelogin/php-saml) - _[MIT](https://github.com/onelogin/php-saml/blob/master/LICENSE)_
235252
* [League/CommonMark](https://commonmark.thephpleague.com/) - _[BSD-3-Clause](https://github.com/thephpleague/commonmark/blob/2.2/LICENSE)_
236253
* [League/Flysystem](https://flysystem.thephpleague.com) - _[MIT](https://github.com/thephpleague/flysystem/blob/3.x/LICENSE)_
237-
* [StyleCI](https://styleci.io/) - _Hosted Service_
238254
* [pragmarx/google2fa](https://github.com/antonioribeiro/google2fa) - _[MIT](https://github.com/antonioribeiro/google2fa/blob/8.x/LICENSE.md)_
239255
* [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode) - _[BSD-2-Clause](https://github.com/Bacon/BaconQrCode/blob/master/LICENSE)_
240256
* [phpseclib](https://github.com/phpseclib/phpseclib) - _[MIT](https://github.com/phpseclib/phpseclib/blob/master/LICENSE)_
241257
* [Clockwork](https://github.com/itsgoingd/clockwork) - _[MIT](https://github.com/itsgoingd/clockwork/blob/master/LICENSE)_
242258
* [PHPStan](https://phpstan.org/) & [Larastan](https://github.com/nunomaduro/larastan) - _[MIT](https://github.com/phpstan/phpstan/blob/master/LICENSE) and [MIT](https://github.com/nunomaduro/larastan/blob/master/LICENSE.md)_
259+
* [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) - _[BSD 3-Clause](https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt)_

0 commit comments

Comments
 (0)