diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..be18f83 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,39 @@ +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 + +script: + - 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 --report-file=report Sample.php || true + - if [[ ! -f "report" ]]; then exit 1; fi + - cat report + +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 diff --git a/Dockerfile b/Dockerfile index 332996b..f3bc7ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM php:7.1.1-alpine +FROM php:7.1.5-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..56d24ef 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ -[![](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 -* [`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) @@ -19,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. @@ -32,4 +34,4 @@ docker run --rm \ ## Volumes -* **/project**: Your PHP project directory. +* `/project`: Your PHP project directory. 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 @@ +