From 01b503d1da194d71562d299a52ab647ad57e1ecc Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Mon, 18 Nov 2024 23:53:09 +0100 Subject: [PATCH 1/4] Remove test command from output like other recipes --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 1af36780b..8e6e6ca9d 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -32,7 +32,7 @@ build: ## Run webpack @yarn build:$(ENV) test: ## Launch wallabag testsuite - XDEBUG_MODE=off php -dmemory_limit=-1 bin/phpunit -v + @XDEBUG_MODE=off php -dmemory_limit=-1 bin/phpunit -v release: ## Create a package. Need a VERSION parameter (eg: `make release VERSION=master`). ifndef VERSION From 6f40edb1c7fa242e845056c241a0e25e36930b48 Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Mon, 18 Nov 2024 23:53:54 +0100 Subject: [PATCH 2/4] Run php and yarn from Docker container if it's running --- .github/CONTRIBUTING.md | 6 +----- GNUmakefile | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 6e2755201..000c72df0 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -50,11 +50,7 @@ Please fork wallabag and work with **the master branch**. All pull requests need to pass the tests and the code needs match the style guide. -To run the tests locally run: - -- when testing using Docker: `docker-compose run --rm php bin/phpunit` (or `docker-compose run --rm php make test` if you - prefer using `make`) -- otherwise: `bin/phpunit` (or `make test`) +To run the tests locally run `make test`. To run the PHP formatter: diff --git a/GNUmakefile b/GNUmakefile index 8e6e6ca9d..6f7319138 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -11,6 +11,18 @@ else override ENV = prod endif +DOCKER_COMPOSE_RUNNING := $(shell docker-compose ps -q | grep -q . && echo 1 || echo 0) + +ifeq ($(DOCKER_COMPOSE_RUNNING), 1) + PHP := docker compose run --rm php php + PHP_NO_XDEBUG := docker compose run -e XDEBUG_MODE=off --rm php php + YARN := docker compose run --rm php yarn +else + PHP := php + PHP_NO_XDEBUG := XDEBUG_MODE=off php + YARN := yarn +endif + help: ## Display this help menu @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' @@ -25,14 +37,14 @@ dev: build ## Install the latest dev version @./scripts/dev.sh run: ## Run the wallabag built-in server - @php bin/console server:run --env=dev + @$(PHP) bin/console server:run --env=dev build: ## Run webpack - @yarn install - @yarn build:$(ENV) + @$(YARN) install + @$(YARN) build:$(ENV) test: ## Launch wallabag testsuite - @XDEBUG_MODE=off php -dmemory_limit=-1 bin/phpunit -v + @$(PHP_NO_XDEBUG) -dmemory_limit=-1 bin/phpunit -v release: ## Create a package. Need a VERSION parameter (eg: `make release VERSION=master`). ifndef VERSION From 5c0266e818126e005d63add3045063637c848def Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Tue, 19 Nov 2024 00:04:06 +0100 Subject: [PATCH 3/4] Add fix-cs recipe --- .github/CONTRIBUTING.md | 5 +---- GNUmakefile | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 000c72df0..b7c67744b 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -52,7 +52,4 @@ All pull requests need to pass the tests and the code needs match the style guid To run the tests locally run `make test`. -To run the PHP formatter: - -- when testing using Docker: `docker-compose run --rm php bin/php-cs-fixer fix` -- otherwise: `php bin/php-cs-fixer fix` +To run the PHP formatter run `make fix-cs`. diff --git a/GNUmakefile b/GNUmakefile index 6f7319138..157c6e75c 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -46,6 +46,9 @@ build: ## Run webpack test: ## Launch wallabag testsuite @$(PHP_NO_XDEBUG) -dmemory_limit=-1 bin/phpunit -v +fix-cs: ## Run PHP-CS-Fixer + @$(PHP_NO_XDEBUG) bin/php-cs-fixer fix + release: ## Create a package. Need a VERSION parameter (eg: `make release VERSION=master`). ifndef VERSION $(error VERSION is not set) @@ -55,6 +58,6 @@ endif deploy: ## Deploy wallabag @bundle exec cap staging deploy -.PHONY: help install update build test release deploy run dev +.PHONY: help install update build test release deploy run dev fix-cs .DEFAULT_GOAL := install From f2d58958016758e9466cea61f6e28b08033483df Mon Sep 17 00:00:00 2001 From: Yassine Guedidi Date: Tue, 19 Nov 2024 00:07:20 +0100 Subject: [PATCH 4/4] Add phpstan recipe --- .github/CONTRIBUTING.md | 2 ++ GNUmakefile | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index b7c67744b..c351f059e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -53,3 +53,5 @@ All pull requests need to pass the tests and the code needs match the style guid To run the tests locally run `make test`. To run the PHP formatter run `make fix-cs`. + +To run the PHPStan static analysis run `make phpstan`. diff --git a/GNUmakefile b/GNUmakefile index 157c6e75c..2037be837 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -49,6 +49,9 @@ test: ## Launch wallabag testsuite fix-cs: ## Run PHP-CS-Fixer @$(PHP_NO_XDEBUG) bin/php-cs-fixer fix +phpstan: ## Run PHPStan + @$(PHP_NO_XDEBUG) bin/phpstan analyse + release: ## Create a package. Need a VERSION parameter (eg: `make release VERSION=master`). ifndef VERSION $(error VERSION is not set) @@ -58,6 +61,6 @@ endif deploy: ## Deploy wallabag @bundle exec cap staging deploy -.PHONY: help install update build test release deploy run dev fix-cs +.PHONY: help install update build test release deploy run dev fix-cs phpstan .DEFAULT_GOAL := install