Instantly share code, notes, and snippets.

Embed
What would you like to do?
(phpstan + phpcs + reviewdog) on Docker
version: '3'
services:
linter:
build: Docker/linter
volumes:
- .:/app:cached
entrypoint: sh -c "/tmp/run.sh"
FROM phpstan/phpstan:0.9
RUN apk --update --repository http://dl-cdn.alpinelinux.org/alpine/v3.7/community add \
git \
php7-intl
RUN cd /usr/bin && curl -fSL https://github.com/haya14busa/reviewdog/releases/download/0.9.11/reviewdog_linux_arm -o reviewdog && chmod +x ./reviewdog
COPY ./run.sh /tmp/run.sh
RUN chmod +x /tmp/run.sh
phpstan_cache_dir="/tmp/phpstan"
phpstan_level=3
if [ -d "$phpstan_cache_dir" ]; then rm -r "$phpstan_cache_dir"; fi
echo "----phpstan----"
phpstan analyse src tests --memory-limit=500M -c phpstan.neon --errorFormat=raw -l $phpstan_level --no-progress|reviewdog -f=phpstan -diff="git diff master"
echo "----phpcs----"
vendor/bin/phpcs -n --report=emacs --standard=./phpcs.xml | reviewdog -efm="%f:%l:%c: %m" -diff="git diff
1. Dockerfileとrun.shを `Docker/linter` ディレクトリに置く
2. `docker-compose run --rm linter` を叩く
3. `./src` `./tests` に対してphpstanが実行され、 `git diff master` に引っかかった行だけ結果が出力される
4. 同様に、 `./phpcs.xml` の内容に従ってphpcsが実行され、`git diff master` に引っかかった行だけ結果が出力される
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment