Skip to content

Commit

Permalink
chore(ci): add coveralls and badges
Browse files Browse the repository at this point in the history
  • Loading branch information
William JEHANNE committed May 24, 2019
1 parent df1c479 commit 98d0b65
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage_clover: build/phpunit/clover.xml
json_path: build/phpunit/coveralls-upload.json
service_name: travis-ci
26 changes: 20 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
language: php

branches:
only:
- master

php:
- '7.1'
- '7.2'
- '7.3'

env:
global:
- TARGET=ci

dist: trusty
sudo: false
Expand All @@ -13,11 +22,16 @@ cache:

before_install: composer self-update

install: make app-install
before_install:
- composer self-update
- if [ -x .travis/before_install_${TARGET}.sh ]; then .travis/before_install_${TARGET}.sh; fi;

install:
- if [ -x .travis/install_${TARGET}.sh ]; then .travis/install_${TARGET}.sh; fi;

script:
- make app-composer-validate
- make app-test-with-code-coverage
- make app-static-analysis
- make app-cs-check
- make app-security-check
- make $TARGET

after_success:
- if [ -x .travis/after_success_${TARGET}.sh ]; then .travis/after_success_${TARGET}.sh; fi;

4 changes: 4 additions & 0 deletions .travis/after_success_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
set -ev

coveralls -v
8 changes: 8 additions & 0 deletions .travis/before_install_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env sh
set -ev

PHP_INI_DIR="$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/"
TRAVIS_INI_FILE="$PHP_INI_DIR/travis.ini"
echo "memory_limit=3072M" >> "$TRAVIS_INI_FILE"

sed --in-place "s/\"dev-master\":/\"dev-${TRAVIS_COMMIT}\":/" composer.json
6 changes: 6 additions & 0 deletions .travis/check_relevant_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -ev

RELEVANT_FILES=$(git diff --name-only HEAD upstream/${TRAVIS_BRANCH} -- '*.php' '*.yml' '*.xml' '*.twig' '*.js' '*.css' '*.json')

if [[ -z ${RELEVANT_FILES} ]]; then echo -n 'KO'; exit 0; fi;
16 changes: 16 additions & 0 deletions .travis/install_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env sh
set -ev

mkdir --parents "${HOME}/bin"

# Coveralls client install
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar --output-document="${HOME}/bin/coveralls"
chmod u+x "${HOME}/bin/coveralls"

# To be removed when these issues are resolved:
# https://github.com/composer/composer/issues/5355
if [ "${COMPOSER_FLAGS}" = '--prefer-lowest' ]; then
composer update --prefer-dist --no-interaction --prefer-stable --quiet
fi

composer update --prefer-dist --no-interaction --prefer-stable ${COMPOSER_FLAGS}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ master
------

* Enable strict typing
* Add coveralls and badges
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: app-composer-validate app-cs-check app-cs-fix app-install app-security-check app-static-analysis app-test \
app-test-with-code-coverage
app-test-with-code-coverage ci

default: help

Expand Down Expand Up @@ -28,4 +28,7 @@ app-test: ## to run unit tests
vendor/bin/phpunit

app-test-with-code-coverage: ## to run unit tests with code-coverage
vendor/bin/phpunit --coverage-text --coverage-clover=build/phpunit/clover.xml --log-junit=build/phpunit/junit.xml --coverage-html=build/phpunit/html --colors=never
vendor/bin/phpunit --coverage-text --colors=never

ci: ## to run checks during ci
make app-composer-validate app-test-with-code-coverage app-static-analysis app-cs-check app-security-check
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# PHPStan Banned Code

[![Latest Stable Version](https://poser.pugx.org/ekino/phpstan-banned-code/v/stable)](https://packagist.org/packages/ekino/phpstan-banned-code)
[![Build Status](https://travis-ci.org/ekino/phpstan-banned-code.svg?branch=master)](https://travis-ci.org/ekino/phpstan-banned-code)
[![Coverage Status](https://coveralls.io/repos/ekino/phpstan-banned-code/badge.svg?branch=master&service=github)](https://coveralls.io/github/ekino/phpstan-banned-code?branch=master)
[![Total Downloads](https://poser.pugx.org/ekino/phpstan-banned-code/downloads)](https://packagist.org/packages/ekino/phpstan-banned-code)

## Basic usage

To use this extension, require it using [Composer](https://getcomposer.org/):
Expand Down
8 changes: 6 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.2/phpunit.xsd"
bootstrap="vendor/autoload.php"
forceCoversAnnotation="true"
beStrictAboutCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true">
Expand All @@ -18,4 +16,10 @@
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="build/phpunit/clover.xml"/>
<log type="junit" target="build/phpunit/junit.xml"/>
<log type="coverage-html" target="build/phpunit/html"/>
</logging>
</phpunit>

0 comments on commit 98d0b65

Please sign in to comment.