Skip to content

Commit e0ecfcd

Browse files
author
Simon Mönch
authored
Add lint workflow for phpstan and phpcs (#431)
Closes #430
1 parent 52f70c8 commit e0ecfcd

File tree

8 files changed

+193
-50
lines changed

8 files changed

+193
-50
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ jobs:
8282
if: matrix.publish-phar == false
8383
run: make tu
8484

85-
- name: Run phpstan
86-
if: matrix.publish-phar == false
87-
run: make phpstan
88-
8985
- uses: actions/upload-artifact@v1
9086
name: Publish the PHAR
9187
if: matrix.publish-phar == true

.github/workflows/lint.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
8+
jobs:
9+
tests:
10+
runs-on: ubuntu-latest
11+
name: Lint ${{ matrix.check }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
php: [ "7.4" ]
16+
check: [ "cs", "phpstan"]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: "${{ matrix.php }}"
25+
26+
- name: Get composer cache directory
27+
id: composercache
28+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
29+
30+
- name: Cache composer dependencies
31+
uses: actions/cache@v2
32+
with:
33+
path: ${{ steps.composercache.outputs.dir }}
34+
key: ${{ runner.os }}-composer-cache-${{ hashFiles('**/composer.lock') }}
35+
restore-keys: ${{ runner.os }}-composer-cache-
36+
37+
- name: Set composer root version
38+
run: |
39+
source .composer-root-version
40+
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
41+
42+
- name: Install dependencies
43+
run: composer install --no-interaction --no-progress --no-suggest --prefer-dist
44+
45+
- name: Run ${{ matrix.check }}
46+
run: make ${{ matrix.check }}

Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ MAKEFLAGS += --no-builtin-rules
66

77
PHPBIN=php
88
PHPNOGC=php -d zend.enable_gc=0
9-
PHPSTAN_URL=https://github.com/phpstan/phpstan/releases/download/0.12.53/phpstan.phar
109

1110
SRC_FILES=$(shell find bin/ src/ -type f)
1211

@@ -39,6 +38,11 @@ cs: $(CODE_SNIFFER) $(CODE_SNIFFER_FIX)
3938
$(PHPNOGC) $(CODE_SNIFFER_FIX) || true
4039
$(PHPNOGC) $(CODE_SNIFFER)
4140

41+
.PHONY: cs-check
42+
cs-check: ## Checks CS
43+
cs-check: $(CODE_SNIFFER)
44+
$(PHPNOGC) $(CODE_SNIFFER)
45+
4246
.PHONY: phpstan
4347
PHPSTAN=bin/phpstan
4448
phpstan: ## Runs PHPStan
@@ -573,10 +577,8 @@ $(CODE_SNIFFER_FIX): vendor-bin/code-sniffer/vendor
573577
composer bin code-sniffer install
574578
touch $@
575579

576-
$(PHPSTAN):
577-
rm $@ || true
578-
wget $(PHPSTAN_URL) -O $@
579-
chmod +x $@
580+
$(PHPSTAN): vendor/bamarni
581+
composer bin phpstan install
580582
touch $@
581583

582584
.composer-root-version:

phpcs.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@
2323
<rule ref="SlevomatCodingStandard.Namespaces.UseDoesNotStartWithBackslash"/>
2424
<rule ref="SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking"/>
2525
<rule ref="SlevomatCodingStandard.PHP.TypeCast"/>
26-
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint"/>
26+
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint"/>
2727
</ruleset>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"require-dev": {
3-
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
4-
"slevomat/coding-standard": "^5.0",
3+
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
4+
"slevomat/coding-standard": "^6.0",
55
"squizlabs/php_codesniffer": "^3.4"
66
}
77
}

vendor-bin/code-sniffer/composer.lock

Lines changed: 57 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor-bin/phpstan/composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"phpstan/phpstan": "^0.12.53"
4+
}
5+
}

vendor-bin/phpstan/composer.lock

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)