diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 35facdb4..b2d483ed 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -112,7 +112,10 @@ jobs: - name: Install dependencies run: make vendor - - name: PHPCS + - name: Lint templates + run: make lint-templates + + - name: Lint app if: always() run: | echo "::add-matcher::.github/matchers/phpcs.json" diff --git a/Makefile b/Makefile index d0f98f96..c1203701 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,16 @@ entrypoints = $(wildcard src/*.js) # Misc variables. export PATH := vendor/bin:node_modules/.bin:$(PATH) +NPROC := 1 ifneq ($(OS),Windows_NT) # Not for Windows UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) # For Mac SHELL := PATH=$(PATH) /bin/bash +NPROC := $(shell sysctl -n hw.logicalcpu) else SHELL := /bin/bash +NPROC := $(shell nproc) endif endif override GIT_VERSION := $(shell git --no-pager describe --always --tags) @@ -170,9 +173,18 @@ check: lint analyse test .PHONY: lint lint: lint-php lint-js -# Lint php code with phpcs. +# Lint php code. .PHONY: lint-php -lint-php: $(phpcs_dir) vendor +lint-php: lint-templates lint-app + +# Run PHP syntax check on template files in parallel thanks to xargs +.PHONY: lint-templates +lint-templates: + echo app/view/templates/*.php | xargs -P$(NPROC) -n1 php --syntax-check > /dev/null + +# Lint backend php code with phpcs. +.PHONY: lint-app +lint-app: $(phpcs_dir) vendor phpcs --report-full --report-summary --cache=$(phpcs_dir)/result.cache || { printf "run 'make fix'\n\n"; exit 1; } .PHONY: lint-js