Skip to content
39 changes: 39 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM php:7.1.1-alpine
FROM php:7.1.5-alpine

MAINTAINER herloct <herloct@gmail.com>

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 \
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -19,7 +21,7 @@ Basic usage.
```sh
docker run --rm \
--volume /local/path:/project \
herloct/phpcs [<options>]
herloct/phpcs[:tag] [<options>]
```

For example, to check `src` directory against the PSR1 and PSR2 coding standard.
Expand All @@ -32,4 +34,4 @@ docker run --rm \

## Volumes

* **/project**: Your PHP project directory.
* `/project`: Your PHP project directory.
7 changes: 7 additions & 0 deletions tests/Sample.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

class Sample {
public function doSomething() {
//
}
}