Skip to content

Commit

Permalink
Use PHPStan and coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
harmim committed Jul 5, 2023
1 parent 8b50674 commit eeb234f
Show file tree
Hide file tree
Showing 26 changed files with 1,387 additions and 550 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build.yml
@@ -1,5 +1,3 @@
# Author: Dominik Harmim <harmim6@gmail.com>

name: Build

on: [push, pull_request]
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/coding-style.yml
@@ -1,13 +1,18 @@
# Author: Dominik Harmim <harmim6@gmail.com>

name: Coding Style

on: [push, pull_request]

jobs:
nette-cc:
name: Nette Code Checker
code-checker:
name: Code Checker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: make code-checker CI=1

coding-standard:
name: Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: make coding-standard CI=1
11 changes: 11 additions & 0 deletions .github/workflows/static-analysis.yml
@@ -0,0 +1,11 @@
name: Static Analysis

on: [push, pull_request]

jobs:
phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: make phpstan CI=1
5 changes: 2 additions & 3 deletions .github/workflows/tests.yml
@@ -1,5 +1,3 @@
# Author: Dominik Harmim <harmim6@gmail.com>

name: Tests

on: [push, pull_request]
Expand All @@ -23,5 +21,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: |
echo "repo_token: ${{ secrets.GITHUB_TOKEN }}" >> tests/.coveralls.github-actions.yml
echo "repo_token: ${{ secrets.GITHUB_TOKEN }}" >> \
tests/.coveralls.github-actions.yml
make tests-coverage CI=1
2 changes: 0 additions & 2 deletions .gitignore
@@ -1,5 +1,3 @@
# Author: Dominik Harmim <harmim6@gmail.com>

/.idea
/temp/*
/vendor/*
Expand Down
69 changes: 47 additions & 22 deletions Makefile
@@ -1,5 +1,3 @@
# Author: Dominik Harmim <harmim6@gmail.com>

FIX := 0
CI := 0

Expand All @@ -14,6 +12,10 @@ CODE_CHECKER := nette/code-checker
CODE_CHECKER_VERSION := ~3.3.0
CODE_CHECKER_DIR := $(TEMP_DIR)/code-checker

CODING_STANDARD := nette/coding-standard
CODING_STANDARD_VERSION := ~3.3.2
CODING_STANDARD_DIR := $(TEMP_DIR)/coding-standard

COVERALLS := php-coveralls/php-coveralls
COVERALLS_VERSION := ^2.5
COVERALLS_DIR := $(TEMP_DIR)/coveralls
Expand All @@ -33,55 +35,78 @@ composer: docker-compose-php
$(DOCKER_PHP) composer install --no-interaction --no-progress


.PHONY: code-checker
code-checker: code-checker-install code-checker-run

.PHONY: code-checker-install
code-checker-install: docker-compose-php
ifeq ($(wildcard $(CODE_CHECKER_DIR)/.), )
$(DOCKER_PHP) composer create-project $(CODE_CHECKER) $(CODE_CHECKER_DIR) $(CODE_CHECKER_VERSION) --no-interaction \
$(DOCKER_PHP) composer create-project $(CODE_CHECKER) $(CODE_CHECKER_DIR) \
$(CODE_CHECKER_VERSION) --no-interaction --no-progress --no-dev
endif

.PHONY: code-checker
code-checker: code-checker-install docker-compose-php
ifeq ($(FIX), 0)
$(DOCKER_PHP) ./$(CODE_CHECKER_DIR)/code-checker --no-progress \
--strict-types --eol
else
$(DOCKER_PHP) ./$(CODE_CHECKER_DIR)/code-checker --no-progress \
--strict-types --eol --fix
endif


.PHONY: coding-standard-install
coding-standard-install: docker-compose-php
ifeq ($(wildcard $(CODING_STANDARD_DIR)/.), )
$(DOCKER_PHP) composer create-project $(CODING_STANDARD) \
$(CODING_STANDARD_DIR) $(CODING_STANDARD_VERSION) --no-interaction \
--no-progress --no-dev
endif

.PHONY: code-checker-run
code-checker-run: docker-compose-php
.PHONY: coding-standard
coding-standard: coding-standard-install docker-compose-php
ifeq ($(FIX), 0)
$(DOCKER_PHP) ./$(CODE_CHECKER_DIR)/code-checker --no-progress --strict-types --eol
$(DOCKER_PHP) ./$(CODING_STANDARD_DIR)/ecs check $(SRC_DIR) $(TESTS_DIR)
else
$(DOCKER_PHP) ./$(CODE_CHECKER_DIR)/code-checker --no-progress --strict-types --eol --fix
$(DOCKER_PHP) ./$(CODING_STANDARD_DIR)/ecs check $(SRC_DIR) $(TESTS_DIR) \
--fix
endif


.PHONY: phpstan
phpstan: install docker-compose-php
$(DOCKER_PHP) ./$(VENDOR_BIN_DIR)/phpstan analyse -c phpstan.neon \
--no-progress


.PHONY: tests
tests: install docker-compose-php
$(DOCKER_PHP) ./$(VENDOR_BIN_DIR)/tester $(TESTS_DIR) -s -C


.PHONY: tests-coverage
tests-coverage: tests-coverage-install tests-coverage-run

.PHONY: tests-coverage-install
tests-coverage-install: docker-compose-php
ifeq ($(wildcard $(COVERALLS_DIR)/.), )
$(DOCKER_PHP) composer create-project $(COVERALLS) $(COVERALLS_DIR) $(COVERALLS_VERSION) --no-interaction \
--no-progress --no-dev
$(DOCKER_PHP) composer create-project $(COVERALLS) $(COVERALLS_DIR) \
$(COVERALLS_VERSION) --no-interaction --no-progress --no-dev
endif

.PHONY: tests-coverage-run
tests-coverage-run: install docker-compose-php
$(DOCKER_PHP) ./$(VENDOR_BIN_DIR)/tester -p phpdbg $(TESTS_DIR) -s -C --coverage coverage.xml \
--coverage-src $(SRC_DIR)
.PHONY: tests-coverage
tests-coverage: install tests-coverage-install docker-compose-php
$(DOCKER_PHP) ./$(VENDOR_BIN_DIR)/tester -p phpdbg $(TESTS_DIR) -s -C \
--coverage coverage.xml --coverage-src $(SRC_DIR)
ifeq ($(CI), 1)
$(DOCKER_PHP) git config --global --add safe.directory /app
$(DOCKER_PHP) ./$(COVERALLS_DIR)/bin/php-coveralls --verbose --config $(TESTS_DIR)/.coveralls.github-actions.yml
$(DOCKER_PHP) ./$(COVERALLS_DIR)/bin/php-coveralls --verbose \
--config $(TESTS_DIR)/.coveralls.github-actions.yml
else
$(DOCKER_PHP) ./$(COVERALLS_DIR)/bin/php-coveralls --verbose --config $(TESTS_DIR)/.coveralls.local.yml
$(DOCKER_PHP) ./$(COVERALLS_DIR)/bin/php-coveralls --verbose \
--config $(TESTS_DIR)/.coveralls.local.yml
endif


.PHONY: clean
clean:
git clean -xdff $(TEMP_DIR) $(TESTS_TEMP_DIR) $(shell find $(TESTS_DIR) -type d -name output) $(VENDOR_DIR) \
git clean -xdff $(TEMP_DIR) $(TESTS_TEMP_DIR) \
$(shell find $(TESTS_DIR) -type d -name output) $(VENDOR_DIR) \
$(shell ls -Ap | grep -v '/\|composer.lock')


Expand Down

0 comments on commit eeb234f

Please sign in to comment.