Skip to content

Commit cc11c76

Browse files
authored
Merge pull request #41 from WyriHaximus/correctly-detect-if-in-docker-Makefile
Makefile: correctly detect if in docker
2 parents a293305 + aade93f commit cc11c76

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

Makefile

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@ SHELL=bash
33

44
.PHONY: *
55

6+
DOCKER_CGROUP:=$(shell cat /proc/1/cgroup | grep docker | wc -l)
7+
68
ifneq ("$(wildcard /.dockerenv)","")
7-
DOCKER_RUN=
9+
IN_DOCKER=TRUE
10+
else ifneq ("$(DOCKER_CGROUP)","0")
11+
IN_DOCKER=TRUE
12+
else
13+
IN_DOCKER=FALSe
14+
endif
15+
16+
ifeq ("$(IN_DOCKER)","TRUE")
17+
DOCKER_RUN=
818
else
919
DOCKER_RUN=docker run --rm -it \
10-
-v `pwd`:`pwd` \
11-
-w `pwd` \
12-
"wyrihaximusnet/php:7.4-zts-alpine3.11-dev"
20+
-v "`pwd`:`pwd`" \
21+
-w "`pwd`" \
22+
"wyrihaximusnet/php:7.4-zts-alpine3.12-dev"
1323
endif
1424

1525
all: lint cs-fix cs stan psalm unit infection composer-require-checker composer-unused
@@ -18,16 +28,16 @@ lint:
1828
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
1929

2030
cs:
21-
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(nproc)
31+
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc)
2232

2333
cs-fix:
24-
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(nproc)
34+
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc)
2535

2636
stan:
2737
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
2838

2939
psalm:
30-
$(DOCKER_RUN) vendor/bin/psalm --threads=$(nproc) --shepherd --stats
40+
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
3141

3242
unit:
3343
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml
@@ -36,7 +46,7 @@ unit-ci: unit
3646
if [ -f ./build/logs/clover.xml ]; then wget https://scrutinizer-ci.com/ocular.phar && sleep 3 && php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml; fi
3747

3848
infection:
39-
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(nproc)
49+
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
4050

4151
composer-require-checker:
4252
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json

0 commit comments

Comments
 (0)