Skip to content

Commit

Permalink
Add parallel PHP syntax check on template files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
n-peugnet committed Nov 1, 2024
1 parent 941f18d commit 6886fed
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6886fed

Please sign in to comment.