2017 © Pedro Peláez
 

library code-review

OpenEuropa code review component.

image

openeuropa/code-review

OpenEuropa code review component.

  • Friday, July 13, 2018
  • by ademarco
  • Repository
  • 21 Watchers
  • 0 Stars
  • 3,549 Installations
  • PHP
  • 20 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 13 Versions
  • 86 % Grown

The README.md

Code review

Build Status Packagist, (*1)

Make automatic conventions checking on each commit via GrumPHP., (*2)

Installation

Install the code review component via Composer:, (*3)

composer require --dev openeuropa/code-review

As this project uses some patches, you will have to enable patching in your project's composer.json file., (*4)

"extra": {
    "enable-patching": true,
    "composer-exit-on-patch-failure": true
}

See the cweagans/composer-patches package for more information on how to apply patches in a project., (*5)

See also the #Patches section for further information., (*6)

In your project root create the following grumphp.yml.dist:, (*7)

imports:
  - { resource: vendor/openeuropa/code-review/dist/library-conventions.yml }

Using Docker Compose

Alternatively, you can build a development setup using Docker and Docker Compose with the provided configuration., (*8)

Docker provides the necessary services and tools such as a web server and a database server to get the site running, regardless of your local host configuration., (*9)

Requirements:

Configuration

By default, Docker Compose reads two files, a docker-compose.yml and an optional docker-compose.override.yml file. By convention, the docker-compose.yml contains your base configuration and it's provided by default. The override file, as its name implies, can contain configuration overrides for existing services or entirely new services. If a service is defined in both files, Docker Compose merges the configurations., (*10)

Find more information on Docker Compose extension mechanism on the official Docker Compose documentation., (*11)

Usage

To start, run:, (*12)

docker-compose up

It's advised to not daemonize docker-compose so you can turn it off (CTRL+C) quickly when you're done working. However, if you'd like to daemonize it, you have to add the flag -d:, (*13)

docker-compose up -d

Then:, (*14)

docker-compose exec web composer install

Running the tests

To run the grumphp checks:, (*15)

docker-compose exec web ./vendor/bin/grumphp run

To run the phpunit tests:, (*16)

docker-compose exec web ./vendor/bin/phpunit

Customization

This component offers a variety of ready conventions that all projects need to follow. This list of default conventions can be found in CONVENTIONS.md., (*17)

Since GrumPHP uses the Symfony Dependency Injection component you can override specific parameters in your project's grumphp.yml.dist file as follows:, (*18)

imports:
  - { resource: vendor/openeuropa/code-review/dist/library-conventions.yml }

parameters:
  tasks.git_commit_message.matchers: ['/^JIRA-\d+: [A-Z].+\./']

Below the list of task parameters can that be overridden on a per-project basis:, (*19)

  • tasks.phpcs.ignore_patterns
  • tasks.phpcs.triggered_by
  • tasks.phpcs.whitelist_patterns
  • tasks.phpmd.exclude
  • tasks.phpmd.ruleset
  • tasks.phpmd.triggered_by
  • tasks.git_commit_message.matchers
  • tasks.phpcsfixer2.config
  • tasks.phpcsfixer2.allow_risky
  • tasks.jsonlint.ignore_patterns

More on how to import and override configuration files here., (*20)

It is also possible to extend the list of tasks to be run by loading the extra tasks extension and adding tasks under the extra_tasks: parameter as shown below:, (*21)

imports:
  - { resource: vendor/openeuropa/code-review/dist/library-conventions.yml }

parameters:
  extra_tasks:
    phpparser: ~
  extensions:
    - OpenEuropa\CodeReview\ExtraTasksExtension

GrumPHP already has a series of tasks that can be used out of the box, you can find the complete list in the GrumPHP tasks page., (*22)

It is also possible to create your own tasks as explained in the GrumPHP extensions page., (*23)

The Code Review component also provides a task to run the PHP CS Fixer. This task is configured using overridable Configuration objects. You can learn more about them and how to customize then on the documentation page of the project, (*24)

Usage

GrumPHP tasks will be ran at every commit, if you with to run them without performing a commit use the following command:, (*25)

./vendor/bin/grumphp run

If you want to simulate the tasks that will be run when creating a new commit:, (*26)

./vendor/bin/grumphp git:pre-commit

Check GrumPHP documentation for more., (*27)

Changelog

The changelog is generated using a local docker installation which installs muccg/docker-github-changelog-generator, (*28)

This reads the Github API for the required repository and writes the CHANGELOG.md to the root of the repository., (*29)

Prerequisites, (*30)

  • Local Docker machine running.
  • A Github Access Token should be generated and exported (or written to ~/.gitconfig) as CHANGELOG_GITHUB_TOKEN=<YOUR TOKEN HERE>

Before tagging a new release export the following:, (*31)

export CHANGELOG_GITHUB_TOKEN=<YOUR TOKEN HERE>
export CHANGELOG_FUTURE_RELEASE=0.1.0

The changelog can then be generated by running:, (*32)

composer run-script changelog

Troubleshooting

GrumPHP not fired on new commits, (*33)

With Git 2.9+ (June 2016) you have a new option for centralizing hooks: core.hooksPath. In case GrumPHP is not fired on new commits check for core.hooksPath global option by running:, (*34)

git config --global --list

To unset that option run:, (*35)

git config --global --unset core.hooksPath 

Generate Changelog on Mac, (*36)

  • Best results were gained using the Docker app
  • The local repo folder should be shared under Docker -> Preferences -> File sharing to enable the file to be written locally.

Patches

The component uses the PSR-2 standard based on version 3.4 of package squizlabs/PHP_CodeSniffer. As the PSR-2 standard does not enforce indentation, we decided to add custom rules in a custom ruleset in order to make sure that our code is properly indented., (*37)

Unfortunately, there are some issues in versions 3.4 of squizlabs/PHP_CodeSniffer regarding code indentation and we fixed them by including custom patches., (*38)

Those issues are partially solved in version 3.5 which is not stable yet., (*39)

As soon as 3.5 reaches a stable version, we will remove those patches., (*40)

The Versions

13/07 2018

dev-master

9999999-dev

OpenEuropa code review component.

  Sources   Download

EUPL-1.1 EUPL-1.2

The Requires

 

The Development Requires

13/07 2018

dev-release-0.3.0

dev-release-0.3.0

OpenEuropa code review component.

  Sources   Download

EUPL-1.2

The Requires

 

The Development Requires

13/07 2018

0.3.0

0.3.0.0

OpenEuropa code review component.

  Sources   Download

EUPL-1.2

The Requires

 

The Development Requires

12/07 2018

dev-pfrenssen-patch-1

dev-pfrenssen-patch-1

OpenEuropa code review component.

  Sources   Download

EUPL-1.2

The Requires

 

The Development Requires

11/07 2018

dev-OPENEUROPA-550

dev-OPENEUROPA-550

OpenEuropa code review component.

  Sources   Download

EUPL-1.2

The Requires

 

The Development Requires

10/07 2018

dev-OPENEUROPA-550-2

dev-OPENEUROPA-550-2

OpenEuropa code review component.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

03/07 2018

dev-OPENEUROPA-582

dev-OPENEUROPA-582

OpenEuropa code review component.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

02/07 2018

dev-OPENEUROPA-369

dev-OPENEUROPA-369

OpenEuropa code review component.

  Sources   Download

EUPL-1.2

The Requires

 

The Development Requires

21/02 2018

0.2.0

0.2.0.0

OpenEuropa code review component.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

09/02 2018

0.1.1

0.1.1.0

OpenEuropa code review component.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

14/12 2017

0.1.0

0.1.0.0

OpenEuropa code review component.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

23/08 2017

0.0.2

0.0.2.0

OpenEuropa code review component.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires

09/06 2017

0.0.1

0.0.1.0

OpenEuropa code review component.

  Sources   Download

EUPL-1.1

The Requires

 

The Development Requires