From 6886fed0f7abac1cb4a42f126cf3d8a56f04021d Mon Sep 17 00:00:00 2001 From: Nicolas Peugnet Date: Fri, 1 Nov 2024 11:08:51 +0100 Subject: [PATCH] Add parallel PHP syntax check on template files Before this, absolutely no automated checks were done on template files now we at least ensure that they are valid PHP files. The parallel run should work correctly on macOS and other Unix-like systems. On Windows, we fallback to sequential execution. This takes around 1 second on my not so fast 2/4 cores Intel laptop. --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index d0f98f96..9a6ba968 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) @@ -173,6 +176,8 @@ lint: lint-php lint-js # Lint php code with phpcs. .PHONY: lint-php lint-php: $(phpcs_dir) vendor +# Run PHP syntax check on template files in parallel thanks to xargs + echo app/view/templates/*.php | xargs -P$(NPROC) -n1 php --syntax-check > /dev/null phpcs --report-full --report-summary --cache=$(phpcs_dir)/result.cache || { printf "run 'make fix'\n\n"; exit 1; } .PHONY: lint-js