Skip to content

Commit 04ab8d9

Browse files
committed
Merge remote-tracking branch 'origin/master' into pr-515
2 parents e4f9187 + 3f98fd3 commit 04ab8d9

File tree

402 files changed

+9402
-7480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

402 files changed

+9402
-7480
lines changed

.php_cs.dist renamed to .php_cs.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@
2020
'phpdoc_order' => true,
2121
'psr4' => true,
2222
'strict_param' => true,
23+
'native_function_invocation' => false,
2324
))
25+
->setCacheFile(getenv('TRAVIS') ? getenv('HOME') . '/php-cs-fixer/.php-cs-fixer' : __DIR__.'/var/.php_cs.cache')
2426
->setFinder(
2527
PhpCsFixer\Finder::create()
28+
->name('/\.php$/')
2629
->in(__DIR__)
2730
)
28-
;
31+
;

.travis.yml

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
sudo: required
2-
31
git:
42
depth: 10
53

@@ -8,22 +6,30 @@ language: php
86
matrix:
97
include:
108
- php: 7.1
9+
sudo: false
1110
env: SYMFONY_VERSION=3.4.* PHPSTAN=true
1211
- php: 7.1
12+
sudo: false
1313
env: SYMFONY_VERSION=3.4.* PHP_CS_FIXER=true
1414
- php: 7.1
15+
sudo: false
1516
env: SYMFONY_VERSION=3.4.* UNIT_TESTS=true
1617
- php: 7.1
18+
sudo: false
1719
env: SYMFONY_VERSION=4.0.* UNIT_TESTS=true
1820
- php: 7.2
21+
sudo: false
1922
env: SYMFONY_VERSION=4.0.* UNIT_TESTS=true
2023
- php: 7.1
2124
services: docker
25+
sudo: required
2226
env: SYMFONY_VERSION=3.4.* FUNCTIONAL_TESTS=true PREPARE_CONTAINER=true
2327
- php: 7.1
28+
sudo: required
2429
services: docker
2530
env: SYMFONY_VERSION=4.0.* FUNCTIONAL_TESTS=true PREPARE_CONTAINER=true
2631
- php: 7.1
32+
sudo: required
2733
services: docker
2834
env: SYMFONY_VERSION=3.4.* RDKAFKA_TESTS=true PREPARE_CONTAINER=true
2935
allow_failures:
@@ -32,32 +38,24 @@ matrix:
3238
cache:
3339
directories:
3440
- $HOME/.composer/cache
35-
- $HOME/docker
36-
37-
38-
before_cache:
39-
- >
40-
mkdir -p $HOME/docker && docker images -a --filter='dangling=false' --format '{{.Repository}}:{{.Tag}} {{.ID}}'
41-
| xargs -n 2 -t sh -c 'test -e $HOME/docker/$1.tar.gz || docker save $0 | gzip -2 > $HOME/docker/$1.tar.gz'
41+
- $HOME/php-cs-fixer
4242

4343
before_install:
4444
- echo "extension = mongodb.so" >> $HOME/.phpenv/versions/$(phpenv version-name)/etc/php.ini
45-
- if [[ -d $HOME/docker ]]; then ls $HOME/docker/*.tar.gz | xargs -I {file} sh -c "zcat {file} | docker load"; fi
4645

4746
install:
4847
- rm $HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini;
4948
- echo "memory_limit=2048M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
50-
- composer require symfony/symfony:${SYMFONY_VERSION} --no-update
49+
- php ./bin/fix-symfony-version.php "$SYMFONY_VERSION"
5150
- composer install
52-
- ./bin/symlink-pkgs-to-vendor.sh
5351
- if [ "$PREPARE_CONTAINER" = true ]; then docker --version; fi
5452
- if [ "$PREPARE_CONTAINER" = true ]; then docker-compose --version; fi
5553
- if [ "$PREPARE_CONTAINER" = true ]; then bin/dev -b; fi
5654

5755
script:
58-
- if [ "$PHPSTAN" = true ]; then composer require "phpstan/phpstan:^0.8" ; php -d memory_limit=512M bin/phpstan analyse -l 1 -c phpstan.neon pkg/gps pkg/amqp-ext pkg/async-event-dispatcher pkg/dbal pkg/enqueue pkg/enqueue-bundle pkg/fs pkg/gearman pkg/job-queue pkg/null pkg/pheanstalk pkg/redis pkg/simple-client pkg/sqs pkg/stomp pkg/test pkg/rdkafka; fi
59-
- if [ "$PHP_CS_FIXER" = true ]; then IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS; fi
60-
- if [ "$PHP_CS_FIXER" = true ]; then ./bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}"; fi
56+
- PKG_PHP_CHANGED_FILES=`./bin/git-find-changed-php-files.sh "${TRAVIS_COMMIT_RANGE}"`
57+
- if [ "$PHP_CS_FIXER" = true ] && [ ! -z "${PKG_PHP_CHANGED_FILES}" ]; then ./bin/php-cs-fixer fix --config=.php_cs.php --no-interaction --dry-run --diff -v --path-mode=intersection -- ${PKG_PHP_CHANGED_FILES[@]} ; fi
58+
- if [ "$PHPSTAN" = true ] && [ ! -z "${PKG_PHP_CHANGED_FILES}" ]; then docker run --workdir="/mqdev" -v "`pwd`:/mqdev" --rm enqueue/dev:latest php -d memory_limit=1024M bin/phpstan analyse -l 1 -c phpstan.neon -- ${PKG_PHP_CHANGED_FILES[@]} ; fi
6159
- if [ "$UNIT_TESTS" = true ]; then bin/phpunit --exclude-group=functional; fi
6260
- if [ "$FUNCTIONAL_TESTS" = true ]; then bin/test.sh --exclude-group=rdkafka; fi
6361
- if [ "RDKAFKA_TESTS" = true ]; then bin/test.sh --group=rdkafka; fi

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Contributing
2+
------------
3+
4+
Enqueue is an open source, community-driven project.
5+
6+
If you'd like to contribute, please read the following documents:
7+
8+
* [Contribution](docs/contribution.md)

bin/build-rabbitmq-image.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
set -e
44
set -x
55

6-
(cd docker && docker build --rm --force-rm --no-cache --pull --squash --tag "enqueue/rabbitmq:latest" -f Dockerfile.rabbitmq .)
6+
(cd docker && docker build --rm --force-rm --no-cache --pull --squash --tag "enqueue/rabbitmq-local-build" -f Dockerfile."$1"-rabbitmq .)
77
(cd docker && docker login --username="$DOCKER_USER" --password="$DOCKER_PASSWORD")
8-
(cd docker && docker push "enqueue/rabbitmq:latest")
8+
(cd docker && docker tag enqueue/rabbitmq-local-build enqueue/rabbitmq:"$1")
9+
(cd docker && docker push "enqueue/rabbitmq:$1")

bin/fix-symfony-version.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
if (empty($argv[1])) {
4+
throw new \LogicException('The new symfony version must be provided');
5+
}
6+
7+
$newVersion = $argv[1];
8+
9+
$composer = file_get_contents(__DIR__.'/../composer.json');
10+
11+
$updatedComposer = preg_replace('/"symfony\/(.*)": ".*"/', '"symfony/$1": "'.$newVersion.'"', $composer).PHP_EOL;
12+
echo $updatedComposer.PHP_EOL;
13+
14+
file_put_contents(__DIR__.'/../composer.json', $updatedComposer);

bin/git-find-changed-php-files.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
if (( "$#" != 1 ))
4+
then
5+
echo "Git range must be provided"
6+
exit 1
7+
fi
8+
9+
10+
IFS='
11+
'
12+
ALL_CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$1");
13+
PKG_PHP_CHANGED_FILES=$(echo "$ALL_CHANGED_FILES" | grep -E "^pkg\/" | grep -E ".*?\.php$");
14+
15+
echo "$PKG_PHP_CHANGED_FILES";

bin/pre-commit

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ function getFilesToFix()
6868
return (bool) preg_match('/\.(php|twig|translations\/*.yml)$/', $file);
6969
});
7070

71-
echo sprintf('Found %s staged files', count($stagedFiles)).PHP_EOL;
71+
$stagedFiles = array_filter($stagedFiles, function ($file) {
72+
return (bool) preg_match('/^pkg\//', $file);
73+
});
7274

7375
return $stagedFiles;
7476
}
@@ -77,18 +79,18 @@ function runPhpLint()
7779
{
7880
global $phpBin, $projectRootDir;
7981

80-
$filesWithErrors = array();
82+
$output = [];
8183
foreach (getFilesToFix() as $file) {
82-
$output = '';
84+
$commandOutput = null;
8385
$returnCode = null;
84-
exec(sprintf('%s -l %s 2>/dev/null', $phpBin, $projectRootDir.'/'.$file), $output, $returnCode);
86+
exec(sprintf('%s -l %s', $phpBin, $projectRootDir.'/'.$file), $commandOutput, $returnCode);
8587

8688
if ($returnCode) {
87-
$filesWithErrors[] = $file;
89+
$output[] = $commandOutput;
8890
}
8991
}
9092

91-
return $filesWithErrors;
93+
return $output;
9294
}
9395

9496
function runPhpCsFixer()
@@ -101,40 +103,41 @@ function runPhpCsFixer()
101103
}
102104

103105
$filesWithErrors = array();
104-
foreach (getFilesToFix() as $file) {
105-
$output = '';
106-
$returnCode = null;
106+
$output = '';
107+
$returnCode = null;
107108

108-
exec(sprintf(
109-
'%s %s fix %s --dry-run',
110-
$phpBin,
111-
$phpCsFixerBin,
112-
$projectRootDir.'/'.$file
113-
), $output, $returnCode);
109+
exec(sprintf(
110+
'%s %s fix --config=.php_cs.php --no-interaction -v --path-mode=intersection -- %s',
111+
$phpBin,
112+
$phpCsFixerBin,
113+
implode(' ', getFilesToFix())
114+
), $output, $returnCode);
114115

115-
if ($returnCode) {
116-
$output = '';
116+
return $returnCode ? $output : false;
117+
}
117118

118-
exec(sprintf(
119-
'%s %s fix %s',
120-
$phpBin,
121-
$phpCsFixerBin,
122-
$projectRootDir.'/'.$file
123-
), $output);
119+
function runPhpstan()
120+
{
121+
$output = '';
122+
$returnCode = null;
124123

125-
$filesWithErrors[] = $file;
126-
}
127-
}
124+
exec(sprintf(
125+
'docker run --workdir="/mqdev" -v "`pwd`:/mqdev" --rm enqueue/dev:latest php -d memory_limit=1024M bin/phpstan analyse -l 1 -c phpstan.neon %s',
126+
implode(' ', getFilesToFix())
127+
), $output, $returnCode);
128128

129-
return $filesWithErrors;
129+
return $returnCode ? $output : false;
130130
}
131131

132+
echo sprintf('Found %s staged files', count(getFilesToFix())).PHP_EOL;
133+
132134
$phpSyntaxErrors = runPhpLint();
133135
if ($phpSyntaxErrors) {
134136
echo "Php syntax errors were found in next files:" . PHP_EOL;
135-
136-
foreach ($phpSyntaxErrors as $error) {
137-
echo $error . PHP_EOL;
137+
foreach ($phpSyntaxErrors as $phpSyntaxErrors) {
138+
echo array_walk_recursive($phpSyntaxErrors, function($item) {
139+
echo $item.PHP_EOL;
140+
}) . PHP_EOL;
138141
}
139142

140143
exit(1);
@@ -144,11 +147,22 @@ $phpCSFixerErrors = runPhpCsFixer();
144147
if ($phpCSFixerErrors) {
145148
echo "Incorrect coding standards were detected and fixed." . PHP_EOL;
146149
echo "Please stash changes and run commit again." . PHP_EOL;
147-
echo "List of changed files:" . PHP_EOL;
150+
echo "Output:" . PHP_EOL . PHP_EOL;
148151

149-
foreach ($phpCSFixerErrors as $error) {
150-
echo $error . PHP_EOL;
151-
}
152+
echo array_walk_recursive($phpStanErrors, function($item) {
153+
echo $item.PHP_EOL;
154+
}) . PHP_EOL;
155+
echo PHP_EOL;
156+
157+
exit(1);
158+
}
159+
160+
$phpStanErrors = runPhpstan();
161+
if ($phpStanErrors) {
162+
echo array_walk_recursive($phpStanErrors, function($item) {
163+
echo $item.PHP_EOL;
164+
}) . PHP_EOL;
165+
echo PHP_EOL;
152166

153167
exit(1);
154168
}

bin/subtree-split

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ remote enqueue-bundle git@github.com:php-enqueue/enqueue-bundle.git
6363
remote job-queue git@github.com:php-enqueue/job-queue.git
6464
remote test git@github.com:php-enqueue/test.git
6565
remote async-event-dispatcher git@github.com:php-enqueue/async-event-dispatcher.git
66+
remote async-command git@github.com:php-enqueue/async-command.git
6667
remote mongodb git@github.com:php-enqueue/mongodb.git
68+
remote dsn git@github.com:php-enqueue/dsn.git
6769

6870
split 'pkg/enqueue' enqueue
6971
split 'pkg/simple-client' simple-client
@@ -85,4 +87,6 @@ split 'pkg/enqueue-bundle' enqueue-bundle
8587
split 'pkg/job-queue' job-queue
8688
split 'pkg/test' test
8789
split 'pkg/async-event-dispatcher' async-event-dispatcher
88-
split 'pkg/mongodb' mongodb
90+
split 'pkg/async-command' async-command
91+
split 'pkg/mongodb' mongodb
92+
split 'pkg/dsn' dsn

bin/symlink-pkgs-to-vendor.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

bin/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
set -x
44
set -e
55

6-
docker-compose run --workdir="/mqdev" --rm dev ./docker/bin/test.sh "$@"
6+
docker-compose run --workdir="/mqdev" --rm dev ./docker/bin/test.sh $@

0 commit comments

Comments
 (0)