Skip to content

Commit

Permalink
Refactor tools.php into a Symfony cli application
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzal committed Aug 29, 2018
1 parent 9003806 commit e1d60ae
Show file tree
Hide file tree
Showing 76 changed files with 3,298 additions and 784 deletions.
16 changes: 16 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/.php_cs export-ignore
/.travis.yml export-ignore
/CODE_OF_CONDUCT.md export-ignore
/CONTRIBUTING.md export-ignore
/Makefile export-ignore
/box.json.dist export-ignore
/composer.json export-ignore
/depfile.yml export-ignore
/infection.json.dist export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/tools export-ignore
/scoper.inc.php export-ignore
8 changes: 8 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!--
Please read the CONTRIBUTING.md to learn about contributing to this project.
Please also note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.
The Code of Conduct can be found in CODE_OF_CONDUCT.md.
-->

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/composer.lock
/.php_cs.cache
/build/
/vendor/
35 changes: 35 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(['src', 'tests'])
;

return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'blank_line_before_statement' => true,
'concat_space' => ['spacing' => 'none'],
'declare_strict_types' => true,
'native_function_invocation' => true,
'no_empty_comment' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_blank_lines' => true,
'no_extra_consecutive_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_unused_imports' => true,
'no_useless_else' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_add_missing_param_annotation' => ['only_untyped' => true],
'protected_to_private' => true,
'strict_comparison' => true,
'ternary_operator_spaces' => true,
'ternary_to_null_coalescing' => true,
'yoda_style' => true,
])
->setFinder($finder)
;

48 changes: 48 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
inherit: true

build:
environment:
php:
version: 7.2
tests:
override:
- make test
project_setup:
nodes:
coverage:
tests:
override:
- command: make phpunit-coverage
coverage:
file: build/coverage.xml
format: clover
filter:
paths: [src/*]

build_failure_conditions:
- 'elements.rating(<= B).new.exists'
- 'issues.label("coding-style").new.exists'
- 'issues.severity(>= MAJOR).new.exists'

checks:
php: true

tools:
php_code_sniffer: { config: { standard: psr2 } }
php_cs_fixer: { config: { level: psr2 } }
external_code_coverage: false
php_code_coverage: true
php_changetracking: true
php_sim: true
php_mess_detector: true
php_pdepend: true
php_analyzer: true
sensiolabs_security_checker: true

coding_style:
php:
spaces:
within:
brackets: false
before_parentheses:
closure_definition: true
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: php
matrix:
include:
- php: 7.1
env: EXECUTE_DEPLOYMENT=true
- php: 7.2
env: deps=low
fast_finish: true
before_install:
- phpenv config-rm xdebug.ini
install:
- if [[ $deps = low ]]; then make update-min; else make install; fi
script:
- if [[ $deps = low ]]; then make test-min; else make test; fi
- make package
deploy:
provider: releases
api_key:
secure: U0BP6+CaAYKAPC5pNIzgIpITLIL5lc0fPRSRW2SBdCh5u55NuHoHL22LldK+309t0L8mxLybq6yh4pUksBdkKB/gKLEI4Vrc5hZeR1y49kIClDIAllrQeCAn+XgDZlZls/Q/Op8DPkAouJrj0Y2qBTWrhAG1Fhn9SLsIcVG0x4JhbKd4I0IN+G4YgxSpzcdYEc6uszqZrPSGKjK+ygrnZ2IJZ+roUTJIQXCK0KEOGHx7sKS4mtqvd5hEx9P+FUZcs3Pp7nNp/gJBWd80ZNbVj7iiOulc7Fl2BxqLqVKGqyv7ekqyeg2vaDz2GpbBiYGbDXiGQlJ0kGlENCuTyqS0ZQ/j9O0htaO57C1m0HVFu+gX34cnL6vP6dkwqjPRDQA8BQ1YNeKQcCP7LDYY/OXvYwaEhB2iw7/e6PjYhQTv41kStGGyTqrFbGNWpV/JM+7oCjr977C8lfDU9I1A/MHRHQHuMKPLA2jygCIVzibmxElsfDaHkIbrbgKZ4ukRYr9fyDVfjv9L2TNWp19++JdDbwBDutuho9E23AFgqEQJjTGTG4mf9pX3tFlfGv+3VDe7LhNm69Wkat1lMjFnL4qjI+uY2K9JdHqPZPw0SOaUpbh9BSuv7+n3Wp/j59Dva136BOK/KUEleD2PBf2oufO+ETLDEofpKQ8HA0R/8K1HN2w=
file: build/toolbox.phar
skip_cleanup: true
on:
tags: true
repo: jakzal/toolbox
condition: "$EXECUTE_DEPLOYMENT"
74 changes: 74 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Contributing

When contributing to this repository send a new pull request.
If your change is big or complex, or you simply want to suggest an improvement,
please discuss the change you wish to make via an issue.

Please note we have a [code of conduct](CODE_OF_CONDUCT.md). Please follow it in all your interactions with the project.

## Pull Request Process

* Provide good commit messages describing what you've done.
* Provide tests for any code you write.
* Make sure all tests are passing.
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2017 Jakub Zalas <[email protected]>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
97 changes: 97 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
default: build

build: install test
.PHONY: build

install:
composer install
.PHONY: install

update:
composer update
.PHONY: update

update-min:
composer update --prefer-stable --prefer-lowest
.PHONY: update-min

update-no-dev:
composer update --prefer-stable --no-dev
.PHONY: update-no-dev

test: vendor cs deptrac phpunit infection
.PHONY: test

test-min: update-min cs deptrac phpunit infection
.PHONY: test-min

cs: tools/php-cs-fixer
tools/php-cs-fixer --dry-run --allow-risky=yes --no-interaction --ansi fix
.PHONY: cs

cs-fix: tools/php-cs-fixer
tools/php-cs-fixer --allow-risky=yes --no-interaction --ansi fix
.PHONY: cs-fix

deptrac: tools/deptrac
tools/deptrac --no-interaction --ansi --formatter-graphviz-display=0
.PHONY: deptrac

infection: tools/infection tools/infection.pubkey
phpdbg -qrr ./tools/infection --no-interaction --formatter=progress --min-msi=100 --min-covered-msi=100 --only-covered --ansi
.PHONY: infection

phpunit: tools/phpunit
tools/phpunit
.PHONY: phpunit

phpunit-coverage: tools/phpunit
phpdbg -qrr tools/phpunit
.PHONY: phpunit

package: tools/box
$(eval VERSION=$(shell (git describe --abbrev=0 --tags 2>/dev/null || echo "0.1-dev") | sed -e 's/^v//'))
@rm -rf build/phar && mkdir -p build/phar build/phar/bin

cp -r resources src LICENSE composer.json scoper.inc.php build/phar
sed -e 's/Application('"'"'dev/Application('"'"'$(VERSION)/g' bin/toolbox.php > build/phar/bin/toolbox.php

cd build/phar && \
composer config platform.php 7.1.3 && \
composer update --no-dev -o -a

tools/box compile

@rm -rf build/phar
.PHONY: package

tools: tools/php-cs-fixer tools/deptrac tools/infection tools/box
.PHONY: tools

clean:
rm -rf build
rm -rf vendor
find tools -not -path '*/\.*' -type f -delete
.PHONY: clean

vendor: install

vendor/bin/phpunit: install

tools/phpunit: vendor/bin/phpunit
ln -sf ../vendor/bin/phpunit tools/phpunit

tools/php-cs-fixer:
curl -Ls http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -o tools/php-cs-fixer && chmod +x tools/php-cs-fixer

tools/deptrac:
curl -Ls http://get.sensiolabs.de/deptrac.phar -o tools/deptrac && chmod +x tools/deptrac

tools/infection: tools/infection.pubkey
curl -Ls https://github.com/infection/infection/releases/download/0.10.1/infection.phar -o tools/infection && chmod +x tools/infection

tools/infection.pubkey:
curl -Ls https://github.com/infection/infection/releases/download/0.10.1/infection.phar.pubkey -o tools/infection.pubkey

tools/box:
curl -Ls https://github.com/humbug/box/releases/download/3.0.0-RC.0/box.phar -o tools/box && chmod +x tools/box
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# Toolbox

[![Build Status](https://travis-ci.com/jakzal/toolbox.svg?branch=master)](https://travis-ci.com/jakzal/toolbox)
[![Build Status](https://scrutinizer-ci.com/g/jakzal/toolbox/badges/build.png?b=master)](https://scrutinizer-ci.com/g/jakzal/toolbox/build-status/master)

Helps to discover and install tools.
Loading

0 comments on commit e1d60ae

Please sign in to comment.