Skip to content
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

Improve e2e time on appveyor #638

Merged
merged 21 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ bin
vendor
composer.lock
grumphp.yml
.phpunit.result.cache
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 7.0
- 7.1
- 7.2
- 7.3
Expand All @@ -22,6 +21,7 @@ matrix:
- php: nightly

before_install:
- phpenv config-rm xdebug.ini
- alias composer=composer\ --no-interaction && composer selfupdate
- composer global require hirak/prestissimo

Expand All @@ -30,7 +30,6 @@ install:

script:
- bin/grumphp run
- vendor/bin/phpunit --testsuite=E2E

notifications:
irc:
Expand Down
90 changes: 57 additions & 33 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,70 @@
build: false
clone_folder: c:\projects\grumphp
clone_depth: 1
shallow_clone: false
platform:
- x86
- x64
clone_folder: c:\projects\grumphp

environment:
matrix:
- php_ver: 7.1.2
matrix:
- dependencies: highest
php_version: 7.1
- dependencies: highest
php_version: 7.2
- dependencies: highest
php_version: 7.3

project_directory: c:\projects\grumphp
composer_directory: c:\tools\composer
composer_executable: c:\tools\composer\composer.phar
composer_installer: c:\tools\composer\installer.php
php_root_directory: c:\tools\php

cache:
- '%APPDATA%\Composer'
- c:\tools\php -> appveyor.yml
- c:\ProgramData\chocolatey\bin -> appveyor.yml
- c:\ProgramData\chocolatey\lib -> appveyor.yml
- c:\tools\composer -> appveyor.yml
- '%LOCALAPPDATA%\Composer -> appveyor.yml'
- c:\tools\php -> appveyor.yml

init:
- SET PATH=C:\Program Files\OpenSSL;c:\tools\php71;C:\tools;%PATH%
- SET COMPOSER_NO_INTERACTION=1
- SET PHP=1
- SET ANSICON=121x90 (121x90)
- ps: $Env:php_directory = $Env:php_root_directory + '\' + $Env:php_version
- ps: $Env:exact_php_version = (((choco search php --exact --all-versions --limit-output | Select-String -pattern $Env:php_version) -replace '[php|]', '') | %{ New-Object System.Version $_ } | Sort-Object | Select-Object -Last 1).ToString()
- ps: $Env:PATH = $Env:php_directory + ';' + $Env:composer_directory + ';' + $Env:PATH
- ps: $Env:COMPOSER_NO_INTERACTION = 1
- ps: $Env:ANSICON = '121x90 (121x90)'

install:
- ps: Set-Service wuauserv -StartupType Manual
- IF EXIST c:\tools\php71 (SET PHP=0)
- IF %PHP%==1 cinst -y OpenSSL.Light
- IF %PHP%==1 cinst -y php -version %php_ver%
- cd C:\tools\php71
- IF %PHP%==1 copy php.ini-production php.ini
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
- IF %PHP%==1 echo memory_limit=1024M >> php.ini
- IF %PHP%==1 echo extension_dir=ext >> php.ini
- IF %PHP%==1 echo extension=php_curl.dll >> php.ini
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
- cd C:\tools
- appveyor DownloadFile https://getcomposer.org/composer.phar -FileName composer

before_test:
- cd C:\projects\grumphp
- php C:\tools\composer update --no-progress --profile --prefer-dist --no-scripts --no-interaction --no-suggest
- git config --global user.email "doesntmatter@dispostable.com"
- git config --global user.name "GrumPHP"
# Install PHP
- ps: If ((Test-Path $Env:php_directory) -eq $False) { New-Item -Path $Env:php_directory -ItemType 'directory' }
- ps: $php_install_parameters = '"/DontAddToPath /InstallDir:' + $Env:php_directory + '"'
- ps: appveyor-retry choco upgrade php --yes --version=$Env:exact_php_version --params=$php_install_parameters

# Prepare PHP
- ps: cd $Env:php_directory
- ps: Copy-Item php.ini-production -Destination php.ini
- ps: Add-Content -Path php.ini -Value 'memory_limit=1G'
- ps: Add-Content -Path php.ini -Value 'date.timezone="UTC"'
- ps: Add-Content -Path php.ini -Value 'extension_dir=ext'
- ps: Add-Content -Path php.ini -Value 'extension=php_curl.dll'
- ps: Add-Content -Path php.ini -Value 'extension=php_mbstring.dll'
- ps: Add-Content -Path php.ini -Value 'extension=php_openssl.dll'
- ps: php --version

# Prepare composer
- ps: If ((Test-Path $Env:composer_directory) -eq $False) { New-Item -Path $Env:composer_directory -ItemType 'directory' }
- ps: If ((Test-Path $Env:composer_installer) -eq $False) { appveyor-retry appveyor DownloadFile https://getcomposer.org/installer -FileName $Env:composer_installer }
- ps: If ((Test-Path $Env:composer_executable) -eq $False) { php $Env:composer_installer --install-dir=$Env:composer_directory }
- ps: Set-Content -Path ($Env:composer_directory + '\composer.bat') -Value ('@php ' + $Env:composer_executable + ' %*')
- ps: Copy-Item "$Env:composer_executable" "$Env:composer_directory\composer"

# Install dependencies
- ps: cd $Env:project_directory
- IF %dependencies%==lowest composer update --prefer-dist --prefer-lowest --prefer-stable --no-progress --no-scripts --no-suggest --profile
- IF %dependencies%==highest composer update --prefer-dist --no-progress --no-scripts --no-suggest --profile
- git config --global user.email "doesntmatter@dispostable.com"
- git config --global user.name "GrumPHP"

test_script:
- cd c:\projects\grumphp
- php ./bin/grumphp run
- php ./vendor/phpunit/phpunit/phpunit --testsuite=E2E
- ps: cd $Env:project_directory
- php ./bin/grumphp run
13 changes: 5 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"type": "composer-plugin",
"license": "MIT",
"require": {
"php": ">=7.0",
"php": ">=7.1",
"composer-plugin-api": "~1.0",
"composer/composer": "^1.0",
"composer/composer": "^1.8.5",
"doctrine/collections": "~1.2",
"gitonomy/gitlib": "^1.0.3",
"monolog/monolog": "~1.16",
Expand All @@ -22,15 +22,12 @@
"symfony/yaml": "~3.4|~4.0"
},
"require-dev": {
"brianium/paratest": "^2.2.0",
"friendsofphp/php-cs-fixer": "~2",
"jakub-onderka/php-parallel-lint": "^0.9.2",
"nikic/php-parser": "~2.1",
"phpspec/phpspec": "^3.2.2",
"phpspec/prophecy": "^1.6.2",
"phpunit/phpunit": "^6.5|^7.0",
"sebastian/comparator": "^2.1",
"sebastian/diff": "^2.0",
"sebastian/exporter": "^3.1",
"phpspec/phpspec": "^5.1",
"phpunit/phpunit": "^7.5.12",
"sensiolabs/security-checker": "^5.0",
"squizlabs/php_codesniffer": "~2.9"
},
Expand Down
8 changes: 8 additions & 0 deletions doc/tasks/paratest.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ parameters:
coverage-html: null
log-junit: null
testsuite: null
verbose: false
```

**processes**
Expand Down Expand Up @@ -105,3 +106,10 @@ Log test execution in JUnit XML format to file.
Filter which testsuite to run. Run multiple suits by separating them with ",". Example: --testsuite suite1,suite2


**verbose**

*Default: false*

Adds additional debugging information to the screen when running paratest.


9 changes: 9 additions & 0 deletions grumphp.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,12 @@ parameters:
blacklist: [var_dump]
metadata:
priority: 100000
paratest:
testsuite: E2E
verbose: true
functional: true
metadata:
priority: 50
testsuites:
git_pre_commit:
tasks: [phpcs, phpspec, phpunit, composer, yamllint, phplint, phpparser]
2 changes: 1 addition & 1 deletion spec/Process/ProcessBuilderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function it_outputs_the_command_when_run_very_very_verbose(IOInterface $io)
$this->buildProcess($arguments);
}

function getMatchers()
public function getMatchers(): array
{
return [
'beQuoted' => function ($subject, $string) {
Expand Down
2 changes: 1 addition & 1 deletion spec/Process/ProcessFactorySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function it_should_create_a_process_from_an_arguments_collection()
$process->getCommandLine()->shouldBeQuoted('/usr/bin/grumphp');
}

public function getMatchers()
public function getMatchers(): array
{
return [
'beQuoted' => function ($subject, $string) {
Expand Down
2 changes: 1 addition & 1 deletion spec/Runner/TaskRunnerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ function it_triggers_events_during_error_flow(
$this->run($runnerContext);
}

public function getMatchers()
public function getMatchers(): array
{
return [
'containFailedTaskResult' => function (TaskResultCollection $taskResultCollection) {
Expand Down
1 change: 1 addition & 0 deletions spec/Task/ParatestSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function it_should_have_configurable_options()
$options->getDefinedOptions()->shouldContain('coverage-html');
$options->getDefinedOptions()->shouldContain('log-junit');
$options->getDefinedOptions()->shouldContain('testsuite');
$options->getDefinedOptions()->shouldContain('verbose');
}

function it_should_run_in_git_pre_commit_context(GitPreCommitContext $context)
Expand Down
19 changes: 11 additions & 8 deletions src/Task/Paratest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function getConfigurableOptions(): OptionsResolver
'log-junit' => null,
'testsuite' => null,
'config' => null,
'verbose' => false,
]
);

Expand All @@ -48,6 +49,7 @@ public function getConfigurableOptions(): OptionsResolver
$resolver->addAllowedTypes('coverage-html', ['null', 'string']);
$resolver->addAllowedTypes('log-junit', ['null', 'string']);
$resolver->addAllowedTypes('testsuite', ['null', 'string']);
$resolver->addAllowedTypes('verbose', ['bool']);

return $resolver;
}
Expand All @@ -67,15 +69,16 @@ public function run(ContextInterface $context): TaskResultInterface
}

$arguments = $this->processBuilder->createArgumentsForCommand('paratest');
$arguments->addOptionalArgument('-p %s', $config['processes']);
$arguments->addOptionalArgument('-p=%s', $config['processes']);
$arguments->addOptionalArgument('-f', $config['functional']);
$arguments->addOptionalArgument('-c %s', $config['configuration']);
$arguments->addOptionalArgument('--phpunit %s', $config['phpunit']);
$arguments->addOptionalArgument('--runner %s', $config['runner']);
$arguments->addOptionalArgument('--coverage-xml %s', $config['coverage-xml']);
$arguments->addOptionalArgument('--coverage-html %s', $config['coverage-html']);
$arguments->addOptionalArgument('--log-junit %s', $config['log-junit']);
$arguments->addOptionalArgument('--testsuite %s', $config['testsuite']);
$arguments->addOptionalArgument('-c=%s', $config['configuration']);
$arguments->addOptionalArgument('--phpunit=%s', $config['phpunit']);
$arguments->addOptionalArgument('--runner=%s', $config['runner']);
$arguments->addOptionalArgument('--coverage-xml=%s', $config['coverage-xml']);
$arguments->addOptionalArgument('--coverage-html=%s', $config['coverage-html']);
$arguments->addOptionalArgument('--log-junit=%s', $config['log-junit']);
$arguments->addOptionalArgument('--testsuite=%s', $config['testsuite']);
$arguments->addOptionalArgument('--verbose=1', $config['verbose']);
$arguments->addOptionalCommaSeparatedArgument('--group=%s', $config['group']);

$process = $this->processBuilder->buildProcess($arguments);
Expand Down
3 changes: 1 addition & 2 deletions test/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

namespace GrumPHPTest;

require_once(__DIR__.'/../vendor/autoload.php');
umask(0);

define('PROJECT_BASE_PATH', __DIR__ . '/..');
define('TEST_BASE_PATH', __DIR__);