From 18a6452ad87b069c159a07febb9443eaea025601 Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 05:31:34 +0700 Subject: [PATCH 01/13] Update phpcs binary to version 2.9.0. --- Dockerfile | 2 +- README.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 332996b..ebdd902 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM php:7.1.1-alpine MAINTAINER herloct -ENV PHPCS_VERSION=2.8.1 +ENV PHPCS_VERSION=2.9.0 RUN curl -L https://github.com/squizlabs/PHP_CodeSniffer/releases/download/$PHPCS_VERSION/phpcs.phar > /usr/local/bin/phpcs \ && chmod +x /usr/local/bin/phpcs \ diff --git a/README.md b/README.md index cc48fc6..21baa19 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,8 @@ ## Supported tags and respective `Dockerfile` links -* [`2.8.1`, `latest`](https://github.com/herloct/docker-phpcs/blob/2.8.1/Dockerfile) +* [`2.9.0`, `latest`](https://github.com/herloct/docker-phpcs/blob/2.9.0/Dockerfile) +* [`2.8.1`](https://github.com/herloct/docker-phpcs/blob/2.8.1/Dockerfile) * [`2.8.0`](https://github.com/herloct/docker-phpcs/blob/2.8.0/Dockerfile) * [`2.7.1`](https://github.com/herloct/docker-phpcs/blob/2.7.1/Dockerfile) From ed2a03e9959c1993c7d53ca72a48dc1163726985 Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 05:35:16 +0700 Subject: [PATCH 02/13] Update PHP base image to version 7.1.5-alpine. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index ebdd902..f3bc7ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.1.1-alpine +FROM php:7.1.5-alpine MAINTAINER herloct From 39e7dba069c9e6045c8532f51c005912bda9a24f Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 05:35:53 +0700 Subject: [PATCH 03/13] Add basic travis script. --- .travis.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5162578 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,36 @@ +sudo: required +dist: trusty + +services: + - docker + +matrix: + fast_finish: true + include: + - env: + - PHPCS_VERSION=2.9.0 + - IS_LATEST=1 + +before_script: + - docker build --rm --tag herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH . + - docker run --rm herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH + - rm -rf tests + +script: + - mkdir tests + - cd tests + - docker run --rm + --volume $(pwd):/project + herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --version + +after_success: + - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; + - docker push herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH; + - if [[ $TRAVIS_TAG ]]; then + docker tag herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH herloct/phpcs:$PHPCS_VERSION; + docker push herloct/phpcs:$PHPCS_VERSION; + fi + - if [[ $TRAVIS_TAG ]] && [[ $IS_LATEST == 1 ]]; then + docker tag herloct/phpcs:$PHPCS_VERSION herloct/phpcs:latest; + docker push herloct/phpcs:latest; + fi From e80871ac00cfb224ace655ad33e0c31cc6b8bd94 Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 05:52:57 +0700 Subject: [PATCH 04/13] A little adjustments. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 21baa19..56d24ef 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -[![](https://images.microbadger.com/badges/image/herloct/phpcs.svg)](http://microbadger.com/images/herloct/phpcs "Get your own image badge on microbadger.com") +[![license](https://img.shields.io/github/license/herloct/docker-phpcs.svg)]() +[![Build Status](https://travis-ci.org/herloct/docker-phpcs.svg?branch=master)](https://travis-ci.org/herloct/docker-phpcs) ## Supported tags and respective `Dockerfile` links @@ -20,7 +21,7 @@ Basic usage. ```sh docker run --rm \ --volume /local/path:/project \ - herloct/phpcs [] + herloct/phpcs[:tag] [] ``` For example, to check `src` directory against the PSR1 and PSR2 coding standard. @@ -33,4 +34,4 @@ docker run --rm \ ## Volumes -* **/project**: Your PHP project directory. +* `/project`: Your PHP project directory. From 2c3d7193aa9318fef270066779dfac694152553b Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 05:56:01 +0700 Subject: [PATCH 05/13] Add simple tests. --- .travis.yml | 3 +++ tests/Sample.php | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 tests/Sample.php diff --git a/.travis.yml b/.travis.yml index 5162578..b5be2a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,9 @@ script: - docker run --rm --volume $(pwd):/project herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --version + - docker run --rm + --volume $(pwd):/project + herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 tests/Sample.php after_success: - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; diff --git a/tests/Sample.php b/tests/Sample.php new file mode 100644 index 0000000..9e85cd1 --- /dev/null +++ b/tests/Sample.php @@ -0,0 +1,7 @@ + Date: Thu, 1 Jun 2017 06:00:49 +0700 Subject: [PATCH 06/13] Fix tests/Sample.php not found. --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b5be2a1..b59aeb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,17 +14,15 @@ matrix: before_script: - docker build --rm --tag herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH . - docker run --rm herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH - - rm -rf tests script: - - mkdir tests - cd tests - docker run --rm --volume $(pwd):/project herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --version - docker run --rm --volume $(pwd):/project - herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 tests/Sample.php + herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 Sample.php after_success: - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; From 6070caf216d8b3118ad303341039c2159b8fee78 Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 06:09:52 +0700 Subject: [PATCH 07/13] Put the report into file. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b59aeb6..29f5d93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ script: herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --version - docker run --rm --volume $(pwd):/project - herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 Sample.php + herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 --reportFile=report Sample.php after_success: - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; From 077d990d4124cb3a4fea1ddd7e7dd561246e63b3 Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 06:17:10 +0700 Subject: [PATCH 08/13] Wrong option name. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 29f5d93..2fbf03a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ script: herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --version - docker run --rm --volume $(pwd):/project - herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 --reportFile=report Sample.php + herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 --report-file=report Sample.php after_success: - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; From d9deedb480ff889a0c5ae41c5f27743c7867ed70 Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 06:22:27 +0700 Subject: [PATCH 09/13] Supress exit code. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2fbf03a..32cc757 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,8 @@ script: herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --version - docker run --rm --volume $(pwd):/project - herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 --report-file=report Sample.php + herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 --report-file=report Sample.php || true + - ls -la after_success: - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; From d15d8553ae2161318d0fad8326507a25de04875b Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 06:26:47 +0700 Subject: [PATCH 10/13] Print generated report. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 32cc757..be18f83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,8 @@ script: - docker run --rm --volume $(pwd):/project herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 --report-file=report Sample.php || true - - ls -la + - if [[ ! -f "report" ]]; then exit 1; fi + - cat report after_success: - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; From cad4595e22a6f41b5e0aea4cc7973da05f56fa10 Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 06:33:36 +0700 Subject: [PATCH 11/13] Compare the generated report. --- .travis.yml | 2 +- tests/report.sample | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/report.sample diff --git a/.travis.yml b/.travis.yml index be18f83..a2168e3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ script: --volume $(pwd):/project herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 --report-file=report Sample.php || true - if [[ ! -f "report" ]]; then exit 1; fi - - cat report + - cmp report.sample report after_success: - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; diff --git a/tests/report.sample b/tests/report.sample new file mode 100644 index 0000000..f80beed --- /dev/null +++ b/tests/report.sample @@ -0,0 +1,12 @@ +FILE: /project/Sample.php +---------------------------------------------------------------------- +FOUND 3 ERRORS AFFECTING 2 LINES +---------------------------------------------------------------------- + 3 | ERROR | [ ] Each class must be in a namespace of at least one + | | level (a top-level vendor name) + 3 | ERROR | [x] Opening brace of a class must be on the line after + | | the definition + 4 | ERROR | [x] Opening brace should be on a new line +---------------------------------------------------------------------- +PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY +---------------------------------------------------------------------- From 01ebf459d26e168ee1653c1621fd78ebfcbc30d8 Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 06:48:26 +0700 Subject: [PATCH 12/13] Add newline at the begining of sample report. --- tests/report.sample | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/report.sample b/tests/report.sample index f80beed..4b9df9a 100644 --- a/tests/report.sample +++ b/tests/report.sample @@ -1,3 +1,4 @@ + FILE: /project/Sample.php ---------------------------------------------------------------------- FOUND 3 ERRORS AFFECTING 2 LINES From 2c8b960a330cb9b2ab284fc72d771053747f646d Mon Sep 17 00:00:00 2001 From: herloct Date: Thu, 1 Jun 2017 06:54:36 +0700 Subject: [PATCH 13/13] No need to verify the report for now. --- .travis.yml | 2 +- tests/report.sample | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 tests/report.sample diff --git a/.travis.yml b/.travis.yml index a2168e3..be18f83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ script: --volume $(pwd):/project herloct/phpcs:$PHPCS_VERSION-$TRAVIS_BRANCH --standard=PSR1,PSR2 --report-file=report Sample.php || true - if [[ ! -f "report" ]]; then exit 1; fi - - cmp report.sample report + - cat report after_success: - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"; diff --git a/tests/report.sample b/tests/report.sample deleted file mode 100644 index 4b9df9a..0000000 --- a/tests/report.sample +++ /dev/null @@ -1,13 +0,0 @@ - -FILE: /project/Sample.php ----------------------------------------------------------------------- -FOUND 3 ERRORS AFFECTING 2 LINES ----------------------------------------------------------------------- - 3 | ERROR | [ ] Each class must be in a namespace of at least one - | | level (a top-level vendor name) - 3 | ERROR | [x] Opening brace of a class must be on the line after - | | the definition - 4 | ERROR | [x] Opening brace should be on a new line ----------------------------------------------------------------------- -PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY -----------------------------------------------------------------------