Skip to content

➕ add github pipeline for tests #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on: [push, pull_request, release]
name: Test
jobs:
test:
runs-on: ubuntu-latest
container:
image: pluswerk/php-dev:nginx-${{ matrix.php }}
options: -t
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
name: 'PHP ${{ matrix.php }}'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependenciess
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- run: composer install
- run: vendor/bin/grumphp run
- run: git config --global --add safe.directory /__w/phpsu/ShellCommandBuilder
- run: script -q -e -c "composer test"
- run: script -q -e -c "composer infection"
- run: composer psalm -- --output-format=github --shepherd
- uses: codecov/codecov-action@v1
with:
file: ./tests/test-results/coverage.xml
16 changes: 0 additions & 16 deletions .github/workflows/shepherd.yml

This file was deleted.

17 changes: 11 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
"type": "library",
"config": {
"optimize-autoloader": true,
"process-timeout": 0
"process-timeout": 0,
"allow-plugins": {
"infection/extension-installer": true,
"phpro/grumphp": true,
"pluswerk/grumphp-config": true
}
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^9.4",
"vimeo/psalm": "^4.1",
"infection/infection": "^0.15.3 || ^0.18.2 || ^0.20.1",
"infection/infection": "^0.26.0",
"spatie/phpunit-watcher": "^1.24 || dev-master#071fbbf",
"phpunit/php-invoker": "^2.0 || ^3.1",
"pluswerk/grumphp-config": "^4.0.1"
"pluswerk/grumphp-config": "^5.0.2"
},
"license": "MIT",
"authors": [
Expand All @@ -39,8 +43,9 @@
},
"minimum-stability": "stable",
"require": {
"php": ">=7.2",
"ext-json": "*"
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
"ext-json": "*",
"composer-runtime-api": "^2.0.0"
},
"extra": {
"pluswerk/grumphp-config": {
Expand Down
1 change: 0 additions & 1 deletion src/Exception/ShellBuilderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

final class ShellBuilderException extends \Exception
{

}
4 changes: 1 addition & 3 deletions src/ShellConditional.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ public function if(bool $condition, callable $callback, callable $alternativeCal
return $result;
}
if ($alternativeCallback) {
$alternativeResult = $alternativeCallback($this);
assert($alternativeResult instanceof self);
return $alternativeResult;
return $alternativeCallback($this);
}
return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ShellBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ static function (ShellBuilder $builder) {

public function testComplexCondiditionalArgumentsWithWrongArguments(): void
{
self::expectException(\AssertionError::class);
self::expectException(\TypeError::class);
ShellBuilder::new()
->ifThis(static function (ShellBuilder $builder) {
return 'world';
Expand All @@ -769,7 +769,7 @@ public function testComplexCondiditionalArgumentsWithWrongArguments(): void

public function testCondiditionalArgumentsWithWrongArguments(): void
{
self::expectException(\AssertionError::class);
self::expectException(\TypeError::class);
ShellBuilder::new()
->if(
true,
Expand Down
4 changes: 2 additions & 2 deletions tests/ShellCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class ShellCommandTest extends TestCase
{
public function testShellCommand(): void
{
$command = new ShellCommand('mysql');
$command = new ShellCommand('mariadb-dump');
$command->addShortOption('u', 'username')
->addShortOption('p', 'password')
->addShortOption('h', '127.0.0.1')
->addArgument('database')
->addOption('skip-comments')
;
$this->assertEquals("mysql -u 'username' -p 'password' -h '127.0.0.1' 'database' --skip-comments", (string)$command);
$this->assertEquals("mariadb-dump -u 'username' -p 'password' -h '127.0.0.1' 'database' --skip-comments", (string)$command);
}

public function testShellCommandWithEnvironmentVariables(): void
Expand Down