-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: only load available commands in maintenance mode
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
- Loading branch information
Showing
102 changed files
with
2,722 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
lib/composer/bamarni/composer-bin-plugin/.github/workflows/phpstan.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: "Static analysis" | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
- "master" | ||
pull_request: null | ||
|
||
jobs: | ||
static-analysis: | ||
runs-on: "ubuntu-latest" | ||
name: "PHPStan on PHP ${{ matrix.php }}" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: | ||
- "8.1" | ||
steps: | ||
- name: "Check out repository code" | ||
uses: "actions/checkout@v2" | ||
|
||
- name: "Setup PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "${{ matrix.php }}" | ||
tools: "composer" | ||
|
||
- name: "Install Composer dependencies" | ||
uses: "ramsey/composer-install@v2" | ||
with: | ||
dependency-versions: "highest" | ||
|
||
- name: "Perform static analysis" | ||
run: "make phpstan" |
80 changes: 80 additions & 0 deletions
80
lib/composer/bamarni/composer-bin-plugin/.github/workflows/tests.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: "Tests" | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
- "master" | ||
pull_request: null | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: "ubuntu-latest" | ||
name: "Unit Tests on PHP ${{ matrix.php }} and ${{ matrix.tools }}" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: | ||
- "7.2" | ||
- "7.3" | ||
- "7.4" | ||
- "8.0" | ||
- "8.1" | ||
tools: [ "composer" ] | ||
dependency-versions: [ "highest" ] | ||
include: | ||
- php: "7.2" | ||
tools: "composer:v2.0" | ||
dependency-versions: "lowest" | ||
|
||
steps: | ||
- name: "Check out repository code" | ||
uses: "actions/checkout@v2" | ||
|
||
- name: "Setup PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "${{ matrix.php }}" | ||
tools: "${{ matrix.tools }}" | ||
|
||
- name: "Install Composer dependencies" | ||
uses: "ramsey/composer-install@v2" | ||
with: | ||
dependency-versions: "${{ matrix.dependency-versions }}" | ||
|
||
- name: "Validate composer.json" | ||
run: "composer validate --strict --no-check-lock" | ||
|
||
- name: "Run tests" | ||
run: "vendor/bin/phpunit --group default" | ||
|
||
e2e-tests: | ||
runs-on: "ubuntu-latest" | ||
name: "E2E Tests on PHP ${{ matrix.php }}" | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
php: | ||
- "8.1" | ||
|
||
steps: | ||
- name: "Check out repository code" | ||
uses: "actions/checkout@v2" | ||
|
||
- name: "Setup PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "${{ matrix.php }}" | ||
tools: "composer" | ||
|
||
- name: "Correct bin plugin version for e2e scenarios (PR-only)" | ||
if: github.event_name == 'pull_request' | ||
run: find e2e -maxdepth 1 -mindepth 1 -type d -exec bash -c "cd {} && composer require --dev bamarni/composer-bin-plugin:dev-${GITHUB_SHA} --no-update" \; | ||
|
||
- name: "Install Composer dependencies" | ||
uses: "ramsey/composer-install@v2" | ||
with: | ||
dependency-versions: "highest" | ||
|
||
- name: "Run tests" | ||
run: "vendor/bin/phpunit --group e2e" |
61 changes: 61 additions & 0 deletions
61
lib/composer/bamarni/composer-bin-plugin/.makefile/touch.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Takes a given string, e.g. 'bin/console' or 'docker-compose exec php bin/console' | ||
# and split it by words. For each words, if the target is a file, it is touched. | ||
# | ||
# This allows to implement a similar rule to: | ||
# | ||
# ```Makefile | ||
# bin/php-cs-fixer: vendor | ||
# touch $@ | ||
# ``` | ||
# | ||
# Indeed when the rule `bin/php-cs-fixer` is replaced with a docker-compose | ||
# equivalent, it will not play out as nicely. | ||
# | ||
# Arguments: | ||
# $1 - {string} Command potentially containing a file | ||
# | ||
|
||
set -Eeuo pipefail; | ||
|
||
|
||
readonly ERROR_COLOR="\e[41m"; | ||
readonly NO_COLOR="\e[0m"; | ||
|
||
|
||
if [ $# -ne 1 ]; then | ||
printf "${ERROR_COLOR}Illegal number of parameters.${NO_COLOR}\n"; | ||
|
||
exit 1; | ||
fi | ||
|
||
|
||
readonly FILES="$1"; | ||
|
||
|
||
####################################### | ||
# Touch the given file path if the target is a file and do not create the file | ||
# if does not exist. | ||
# | ||
# Globals: | ||
# None | ||
# | ||
# Arguments: | ||
# $1 - {string} File path | ||
# | ||
# Returns: | ||
# None | ||
####################################### | ||
touch_file() { | ||
local file="$1"; | ||
|
||
if [ -e ${file} ]; then | ||
touch -c ${file}; | ||
fi | ||
} | ||
|
||
for file in ${FILES} | ||
do | ||
touch_file ${file}; | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phive xmlns="https://phar.io/phive"> | ||
<phar name="composer-normalize" version="^2.28.3" installed="2.28.3" location="./tools/composer-normalize" copy="false"/> | ||
<phar name="infection" version="^0.26.13" installed="0.26.13" location="./tools/infection" copy="false"/> | ||
<phar name="php-cs-fixer" version="^3.8.0" installed="3.8.0" location="./tools/php-cs-fixer" copy="false"/> | ||
</phive> |
17 changes: 17 additions & 0 deletions
17
lib/composer/bamarni/composer-bin-plugin/.php-cs-fixer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php declare(strict_types=1); | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->files() | ||
->in(['src', 'tests']); | ||
|
||
$config = new PhpCsFixer\Config(); | ||
|
||
return $config | ||
->setRules([ | ||
'@PSR12' => true, | ||
'strict_param' => true, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'no_unused_imports' => true, | ||
]) | ||
->setRiskyAllowed(true) | ||
->setFinder($finder); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2016 Bilal Amarni | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# See https://tech.davis-hansson.com/p/make/ | ||
MAKEFLAGS += --warn-undefined-variables | ||
MAKEFLAGS += --no-builtin-rules | ||
|
||
# General variables | ||
TOUCH = bash .makefile/touch.sh | ||
|
||
# PHP variables | ||
COMPOSER=composer | ||
COVERAGE_DIR = dist/coverage | ||
INFECTION_BIN = tools/infection | ||
INFECTION = php -d zend.enable_gc=0 $(INFECTION_BIN) --skip-initial-tests --coverage=$(COVERAGE_DIR) --only-covered --threads=4 --min-msi=100 --min-covered-msi=100 --ansi | ||
PHPUNIT_BIN = vendor/bin/phpunit | ||
PHPUNIT = php -d zend.enable_gc=0 $(PHPUNIT_BIN) | ||
PHPUNIT_COVERAGE = XDEBUG_MODE=coverage $(PHPUNIT) --group default --coverage-xml=$(COVERAGE_DIR)/coverage-xml --log-junit=$(COVERAGE_DIR)/phpunit.junit.xml | ||
PHPSTAN_BIN = vendor/bin/phpstan | ||
PHPSTAN = $(PHPSTAN_BIN) analyse --level=5 src tests | ||
PHP_CS_FIXER_BIN = tools/php-cs-fixer | ||
PHP_CS_FIXER = $(PHP_CS_FIXER_BIN) fix --ansi --verbose --config=.php-cs-fixer.php | ||
COMPOSER_NORMALIZE_BIN=tools/composer-normalize | ||
COMPOSER_NORMALIZE = ./$(COMPOSER_NORMALIZE_BIN) | ||
|
||
|
||
.DEFAULT_GOAL := default | ||
|
||
|
||
# | ||
# Command | ||
#--------------------------------------------------------------------------- | ||
|
||
.PHONY: help | ||
help: ## Shows the help | ||
help: | ||
@printf "\033[33mUsage:\033[0m\n make TARGET\n\n\033[32m#\n# Commands\n#---------------------------------------------------------------------------\033[0m\n" | ||
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | awk 'BEGIN {FS = ":"}; {printf "\033[33m%s:\033[0m%s\n", $$1, $$2}' | ||
|
||
|
||
.PHONY: default | ||
default: ## Runs the default task: CS fix and all the tests | ||
default: cs test | ||
|
||
|
||
.PHONY: cs | ||
cs: ## Runs PHP-CS-Fixer | ||
cs: $(PHP_CS_FIXER_BIN) $(COMPOSER_NORMALIZE_BIN) | ||
$(PHP_CS_FIXER) | ||
$(COMPOSER_NORMALIZE) | ||
|
||
|
||
.PHONY: phpstan | ||
phpstan: ## Runs PHPStan | ||
phpstan: | ||
$(PHPSTAN) | ||
|
||
|
||
.PHONY: infection | ||
infection: ## Runs infection | ||
infection: $(INFECTION_BIN) $(COVERAGE_DIR) vendor | ||
if [ -d $(COVERAGE_DIR)/coverage-xml ]; then $(INFECTION); fi | ||
|
||
|
||
.PHONY: test | ||
test: ## Runs all the tests | ||
test: validate-package phpstan $(COVERAGE_DIR) e2e #infection include infection later | ||
|
||
|
||
.PHONY: validate-package | ||
validate-package: ## Validates the Composer package | ||
validate-package: vendor | ||
$(COMPOSER) validate --strict | ||
|
||
|
||
.PHONY: coverage | ||
coverage: ## Runs PHPUnit with code coverage | ||
coverage: $(PHPUNIT_BIN) vendor | ||
$(PHPUNIT_COVERAGE) | ||
|
||
|
||
.PHONY: unit-test | ||
unit-test: ## Runs PHPUnit (default group) | ||
unit-test: $(PHPUNIT_BIN) vendor | ||
$(PHPUNIT) --group default | ||
|
||
|
||
.PHONY: e2e | ||
e2e: ## Runs PHPUnit end-to-end tests | ||
e2e: $(PHPUNIT_BIN) vendor | ||
$(PHPUNIT) --group e2e | ||
|
||
|
||
# | ||
# Rules | ||
#--------------------------------------------------------------------------- | ||
|
||
# Vendor does not depend on the composer.lock since the later is not tracked | ||
# or committed. | ||
vendor: composer.json | ||
$(COMPOSER) update | ||
$(TOUCH) "$@" | ||
|
||
$(PHPUNIT_BIN): vendor | ||
$(TOUCH) "$@" | ||
|
||
$(INFECTION_BIN): ./.phive/phars.xml | ||
phive install infection | ||
$(TOUCH) "$@" | ||
|
||
$(COMPOSER_NORMALIZE_BIN): ./.phive/phars.xml | ||
phive install composer-normalize | ||
$(TOUCH) "$@" | ||
|
||
$(COVERAGE_DIR): $(PHPUNIT_BIN) src tests phpunit.xml.dist | ||
$(PHPUNIT_COVERAGE) | ||
$(TOUCH) "$@" | ||
|
||
$(PHP_CS_FIXER_BIN): vendor | ||
phive install php-cs-fixer | ||
$(TOUCH) "$@" | ||
|
||
$(PHPSTAN_BIN): vendor | ||
$(TOUCH) "$@" |
Oops, something went wrong.