Skip to content

Commit

Permalink
Merge pull request #109 from shopwareLabs/add-import-of-other-psh-con…
Browse files Browse the repository at this point in the history
…figs

1.6
  • Loading branch information
JanPietrzyk authored Oct 29, 2020
2 parents d234f36 + 782f0f5 commit 0a49266
Show file tree
Hide file tree
Showing 126 changed files with 13,229 additions and 2,894 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ vendor
bin

#externals
humbuglog.txt
.box_dump
.php_cs.cache
.phpunit.result.cache
99 changes: 90 additions & 9 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,96 @@
<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
<?php declare(strict_types=1);
$finder = PhpCsFixer\Finder::create()
->ignoreUnreadableDirs()
->exclude([
__DIR__ . '/tests/Integration/ScriptRuntime/_non_writable'
__DIR__ . '/tests/Integration/ScriptRuntime/_non_writable',
])
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
;
->append([__FILE__]);

return PhpCsFixer\Config::create()
->setRules([
'@Symfony' => true,

// Fix declare style
'blank_line_after_opening_tag' => false,

return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->finder($finder)
;
// override @Symonfy
'phpdoc_align' => false,
'phpdoc_separation' => false,
'yoda_style' => false,
'phpdoc_summary' => false,
'increment_style' => false,
'php_unit_fqcn_annotation' => false,
'single_line_throw' => false,

'array_syntax' => [
'syntax' => 'short',
],
'class_definition' => [
'single_line' => true,
],
'comment_to_phpdoc' => true,
'concat_space' => [
'spacing' => 'one',
],
'declare_strict_types' => true,
'dir_constant' => true,
'is_null' => true,
'no_null_property_initialization' => true,
'no_superfluous_phpdoc_tags' => true,
'no_useless_return' => true,
'no_useless_else' => true,
'multiline_whitespace_before_semicolons' => true,
'mb_str_functions' => true,
'ordered_class_elements' => false,
'ordered_imports' => [
'imports_order' => [
'class',
'function',
'const',
],
],
'native_function_invocation' => [
'exclude' => [
'call_user_func_array',
],
],
'global_namespace_import' => [
'import_classes' => true,
'import_constants' => false,
'import_functions' => true,
],
'php_unit_ordered_covers' => true,
'php_unit_namespaced' => true,
'php_unit_construct' => true,
'phpdoc_add_missing_param_annotation' => [
'only_untyped' => true,
],
'phpdoc_order' => true,
'phpdoc_var_annotation_correct_order' => true,
'strict_comparison' => true,
'strict_param' => true,
'general_phpdoc_annotation_remove' => [
'annotations' => ['inheritdoc'],
],
'class_attributes_separation' => [
'elements' => [
'method',
'property',
],
],
'void_return' => true,
'php_unit_test_case_static_method_calls' => [
'call_type' => 'self',
],
'yoda_style' => [
'equal' => false,
'identical' => false,
'less_and_greater' => false,
],
'nullable_type_declaration_for_default_null_value' => true,
])
->setRiskyAllowed(true)
->setUsingCache(true)
->setFinder($finder);
2 changes: 2 additions & 0 deletions .psh.xml.dist → .psh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
|_|
]]></header>
<import path="tests"/>
<import path="**/*"/>
<path>actions</path>
</psh>
32 changes: 25 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
language: php

php:
- 7.0
- 7.1

sudo: false
jobs:
include:
- php: 7.2
- php: 7.3
- php: 7.4
env:
- FULL_SUITE=true
- php: 8.0
env:
- UPDATE_PHPUNIT=true
allow_failures:
- php: 8.0

cache:
directories:
- $HOME/.composer/cache

before_script:
- if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then openssl aes-256-cbc -K $encrypted_d4931f6d241c_key -iv $encrypted_d4931f6d241c_iv -in .travis/github_deploy_key.enc -out .travis/github_deploy_key -d; fi
- composer self-update
- composer self-update --1
- if [[ "$UPDATE_PHPUNIT" == "true" ]]; then
composer config platform.php 7.4;
composer require "phpunit/phpunit:^9" --with-all-dependencies;
fi
- composer install
- if [[ "$FULL_SUITE" == "true" ]]; then
composer bin all install;
fi

script:
- ./psh unit
- if [[ "$FULL_SUITE" == "true" ]]; then
./psh ci;
else
./psh unit;
fi

after_success:
- bash <(curl -s https://codecov.io/bash)
Expand Down
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ Table of contents
* [Placeholders](#placeholders)
* [Constants](#constants)
* [Variables](#variables)
* [Dotenv](#dotenv)
* [Require](#require)
* [Templates](#templates)
* [Environments](#environments)
* [Headers](#headers)
* [Overriding configuration file](#overriding-configuration-file)
* [Importing configuration files](#importing-configuration-files)
* [PSH-Scripts](#sh-scripts)
* [Defining placeholders](#defining-placeholders)
* [Including other actions](#including-other-actions)
Expand Down Expand Up @@ -84,7 +87,6 @@ Download `psh.phar` to your local environment.

```sh
wget https://shopwarelabs.github.io/psh/psh.phar # PHP7 Version
# OR wget https://shopwarelabs.github.io/psh/psh56.phar for the PHP5.6 Version
chmod +x psh.phar
```

Expand All @@ -109,8 +111,7 @@ composer install # assuming you have composer installed globally
./psh build
```

This will create a release phar in the `build/psh.phar` directory. Although the project itself requires PHP7 a PHP 5.6
compatible version is currently created with it `build/psh56.phar`.
This will create a release phar in the `build/psh.phar` directory. The project itself requires PHP 7.2+.

Usage
------------
Expand Down Expand Up @@ -233,6 +234,18 @@ dev-ops/common/actions/test.sh
echo __TEST__
```

#### Require

It may be necessary to require a placeholder to be set, but can't set right away. One such example might be a system dependent path. PSH allows you to communicate this to the user by adding this:

```xml
<placeholder>
<require name="FOO" description="Foo needs to be a reference to bar"/>
</placeholder>
```

Now unless foo is set, it is not possible to execute any psh script. The description is optional and can be omitted.

#### Templates

If your application depends on files that are not part of your repository because they differ for different systems (Typically `*.dist` files),
Expand Down Expand Up @@ -310,6 +323,18 @@ You can place a `.psh.xml.override` inside your directory where the `.psh.xml` i

> Notice: You can overwrite a XML config file with a YAML file to ease the migration from one format to the other.
#### Importing configuration files

You can import environments, actions and placeholders by using the import statement and telling psh to look in another place.

```xml
<import path="another/config/file/location" />
```

These directories should contain a `psh.xml` or `psh.xml.dist`. If no file is found a warning is issued but no braking error, since it may very well be that psh is currently installing or downloading the files. You can also use a glob pattern like "tools/**/config"

> Notice: This happens through merging the different configurations into one. Be aware that you might overwrite base configuration.
## PSH-Scripts

Although most of your existing sh scripts should work just fine, you may find some of the following additions useful or necessary.
Expand Down
20 changes: 3 additions & 17 deletions actions/build.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
#!/usr/bin/env bash
# DESCRIPTION: Builds phar packages

I: rm -R build/php56
mkdir build/php56

cp psh build/php56
cp composer.json build/php56
cp box.json build/php56
cp box.phar build/php56
cp -R vendor build/php56
cp -R resource build/php56
bin/php-version-transpiler src/ build/php56/src

cd build/php56 && php box.phar build
mv build/php56/psh.phar build/psh56.phar
chmod +x build/psh56.phar

php box.phar build
I: rm build/*.phar
php bin/box compile --debug
mv psh.phar build/psh.phar
chmod +x build/psh.phar
rm -R build/php56
rm -R .box_dump
8 changes: 8 additions & 0 deletions actions/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# DESCRIPTION: Execute full ci suite

bin/psalm
bin/php-cs-fixer fix
INCLUDE: unit.sh

phpdbg -qrr bin/infection --min-msi=80
7 changes: 6 additions & 1 deletion actions/clear.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/env bash
# DESCRIPTION: Remove build artifacts
# <PSH_EXECUTE_THROUGH_CMD>
set -euo pipefail

I: rm -R build/*
rm -Rf build/*
rm -Rf vendor-bin/*/vendor
rm -Rf bin
rm -Rf vendor
5 changes: 0 additions & 5 deletions actions/unit.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
#!/usr/bin/env bash
# DESCRIPTION: Execute unit tests

D: bin/php-cs-fixer fix
phpdbg -qrr bin/phpunit --coverage-clover=./build/coverage.xml --coverage-html=./build/html-coverage

WAIT:

./humbug.phar --no-interaction
3 changes: 0 additions & 3 deletions box.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"alias": "psh.phar",
"chmod": "0755",
"directories": [
"src",
"resource",
Expand All @@ -9,7 +8,5 @@
"files": [
"psh"
],
"main": "psh",
"output": "psh.phar",
"stub": true
}
Binary file removed box.phar
Binary file not shown.
31 changes: 16 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@
}
},
"require": {
"php": ">=7",
"php": "^7.2",
"ext-dom": "*",
"symfony/finder": "^3.1",
"symfony/process": "^3.1",
"symfony/filesystem": "^3.1",
"symfony/yaml": "^3.1",
"league/climate": "^3.2",
"symfony/finder": "^4.4",
"symfony/process": "^4.4",
"symfony/filesystem": "^4.4",
"symfony/yaml": "^4.4",
"league/climate": "^3.6",
"khill/php-duration": "^1.0",
"vlucas/phpdotenv": "^3.3",
"symfony/config": "^3.3"
"vlucas/phpdotenv": "^5.2",
"symfony/config": "^4.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^1.11",
"phpunit/phpunit": "^5.4",
"janpiet/php-version-transpiler": "dev-master"
"roave/security-advisories": "dev-master",
"friendsofphp/php-cs-fixer": "^2",
"phpunit/phpunit": "^8",
"bamarni/composer-bin-plugin": "^1.4"
},
"license": "MIT",
"authors": [
Expand All @@ -40,10 +41,10 @@
"config": {
"bin-dir": "bin",
"platform": {
"php": "7.0"
"php": "7.2.0"
}

},
"minimum-stability": "dev",
"prefer-stable": true
"scripts": {
},
"minimum-stability": "stable"
}
Loading

0 comments on commit 0a49266

Please sign in to comment.