Last active
February 22, 2021 00:46
-
-
Save o0h/98f4edb10b21717e53b30f622f97a511 to your computer and use it in GitHub Desktop.
(phpstan + phpcs + reviewdog) on Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
linter: | |
build: Docker/linter | |
volumes: | |
- .:/app:cached | |
entrypoint: sh -c "/tmp/run.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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