Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parallel PHP syntax check on template files #481

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 14 additions & 2 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 @@ -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
Expand Down