Skip to content

Merge 2.2 into master #1917

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

Merged
merged 19 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a4825cc
Move coverage jobs to CircleCI
teohhanhui Apr 23, 2018
f6bd5fc
add some local caches where they are missing
bendavies Apr 25, 2018
3ac4c89
Merge pull request #1888 from teohhanhui/ci/parallel-jobs
soyuka Apr 26, 2018
985f0c1
Allow subresource items in the iri converter
Apr 20, 2018
ca162c1
Merge pull request #1892 from bendavies/missing-local-caches
soyuka Apr 26, 2018
f9706ea
fix normalizer cache key generation
bendavies Apr 26, 2018
309e0ff
Merge pull request #1877 from soyuka/allow-subresource-iri
soyuka Apr 26, 2018
0b35725
Merge pull request #1894 from bendavies/normalizer-cache-keys
dunglas Apr 26, 2018
0b55fdc
respect forceEager=false on an association
bendavies Apr 26, 2018
1b650ee
Merge pull request #1897 from bendavies/respect-property-force-eager
dunglas Apr 27, 2018
1ea6f68
Restore identifiers casting to integer when necessary
antograssiot Apr 29, 2018
5335963
Merge pull request #1899 from antograssiot/fix-identifier-casting
soyuka Apr 29, 2018
bfe7c0d
simplify boolean filter
bendavies Apr 30, 2018
7fb6254
Merge pull request #1905 from bendavies/simplify-boolean-filter
dunglas Apr 30, 2018
03ce36e
Revert "Simplify boolean filter"
teohhanhui Apr 30, 2018
592af01
Merge pull request #1907 from api-platform/revert-1905-simplify-boole…
dunglas Apr 30, 2018
6361a21
introduce cache trait to reuse common pattern
bendavies Apr 30, 2018
dcdea86
Merge pull request #1908 from bendavies/cache-trait
teohhanhui Apr 30, 2018
6df01b4
Merge branch '2.2' into merge-2.2
teohhanhui May 2, 2018
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
191 changes: 191 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
version: 2

reusable-steps:
- &clear-test-app-cache
run:
name: Clear test app cache
command: tests/Fixtures/app/console cache:clear
- &disable-php-memory-limit
run:
name: Disable PHP memory limit
command: echo 'memory_limit=-1' | sudo tee -a /usr/local/etc/php/php.ini
- &disable-xdebug-php-extension
run:
name: Disable Xdebug PHP extension
command: sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
- &restore-composer-cache
restore_cache:
keys:
- composer-cache-{{ .Revision }}
- composer-cache-{{ .Branch }}
- composer-cache
- &restore-npm-cache
restore_cache:
keys:
- npm-cache-{{ .Revision }}
- npm-cache-{{ .Branch }}
- npm-cache
- &save-composer-cache-by-branch
save_cache:
paths:
- ~/.composer/cache
key: composer-cache-{{ .Branch }}-{{ .BuildNum }}
- &save-composer-cache-by-revision
save_cache:
paths:
- ~/.composer/cache
key: composer-cache-{{ .Revision }}-{{ .BuildNum }}
- &save-npm-cache-by-branch
save_cache:
paths:
- ~/.npm
key: npm-cache-{{ .Branch }}-{{ .BuildNum }}
- &save-npm-cache-by-revision
save_cache:
paths:
- ~/.npm
key: npm-cache-{{ .Revision }}-{{ .BuildNum }}
- &update-composer
run:
name: Update Composer
command: composer self-update
- &update-project-dependencies
run:
name: Update project dependencies
command: composer update --prefer-dist --no-progress --no-suggest --ansi

jobs:
phpunit-php-7.2-coverage:
docker:
- image: circleci/php:7.2-node-browsers
environment:
SYMFONY_DEPRECATIONS_HELPER: weak_vendors
APP_ENV: test
parallelism: 2
working_directory: ~/api-platform/core
steps:
- checkout
- *restore-composer-cache
- *restore-npm-cache
- *disable-xdebug-php-extension
- *disable-php-memory-limit
- *update-composer
- *update-project-dependencies
- *save-composer-cache-by-revision
- *save-composer-cache-by-branch
- *clear-test-app-cache
- run:
name: Run PHPUnit tests
command: |-
mkdir -p build/logs/tmp build/cov
find tests -name '*Test.php' | circleci tests split --split-by=timings | parallel -j10% --rpl '{_} s/\//_/g;' \
phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-{_}.cov --log-junit build/logs/tmp/{_}.xml --colors=always {}
- run:
name: Merge PHPUnit test reports
command: |-
mkdir -p build/logs/phpunit
npx junit-merge --out build/logs/phpunit/junit.xml --dir build/logs/tmp
rm -r build/logs/tmp
- store_test_results:
path: build/logs
- store_artifacts:
path: build/logs/phpunit/junit.xml
destination: build/logs/phpunit/junit.xml
- persist_to_workspace:
root: build
paths:
- cov
- *save-npm-cache-by-revision
- *save-npm-cache-by-branch

behat-php-7.2-coverage:
docker:
- image: circleci/php:7.2-node-browsers
environment:
SYMFONY_DEPRECATIONS_HELPER: weak_vendors
APP_ENV: test
parallelism: 2
working_directory: ~/api-platform/core
steps:
- checkout
- *restore-composer-cache
- *restore-npm-cache
- *disable-xdebug-php-extension
- *disable-php-memory-limit
- *update-composer
- *update-project-dependencies
- *save-composer-cache-by-revision
- *save-composer-cache-by-branch
- *clear-test-app-cache
- run:
name: Run Behat tests
command: |-
mkdir -p build/logs/tmp build/cov
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature' | circleci tests split --split-by=timings); do
_f=${f//\//_}
FEATURE="${_f}" phpdbg -qrr vendor/bin/behat --profile=coverage --suite=default --tags=~@postgres --format=progress --out=std --format=junit --out=build/logs/tmp/"${_f}" "$f"
done
- run:
name: Merge Behat test reports
command: |-
mkdir -p build/logs/behat
npx junit-merge --out build/logs/behat/junit.xml --dir build/logs/tmp --recursive
rm -r build/logs/tmp
- store_test_results:
path: build/logs
- store_artifacts:
path: build/logs/behat/junit.xml
destination: build/logs/behat/junit.xml
- persist_to_workspace:
root: build
paths:
- cov
- *save-npm-cache-by-revision
- *save-npm-cache-by-branch

merge-and-upload-coverage:
docker:
- image: circleci/php:7.2-node-browsers
working_directory: ~/api-platform/core
steps:
- checkout
- *restore-npm-cache
- *disable-xdebug-php-extension
- *disable-php-memory-limit
- run:
name: Download phpcov
command: wget https://phar.phpunit.de/phpcov.phar
- attach_workspace:
at: build
- run:
name: Merge code coverage reports
command: |-
mkdir -p build/logs
phpdbg -qrr phpcov.phar merge --clover build/logs/clover.xml build/cov
- store_artifacts:
path: build/logs/clover.xml
destination: build/logs/clover.xml
- run:
name: Upload code coverage report to Coveralls
command: |-
if [ ! -z "$COVERALLS_REPO_TOKEN" ]; then
npx @cedx/coveralls build/logs/clover.xml
else
echo 'Skipped'
fi
- run:
name: Upload code coverage report to Codecov
command: npx codecov --file=build/logs/clover.xml --disable=gcov
- *save-npm-cache-by-revision
- *save-npm-cache-by-branch

workflows:
version: 2
test-with-coverage:
jobs:
- phpunit-php-7.2-coverage
- behat-php-7.2-coverage
- merge-and-upload-coverage:
requires:
- phpunit-php-7.2-coverage
- behat-php-7.2-coverage
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ indent_style = space
indent_size = 4
trim_trailing_whitespace = false

[.circleci/config.yml]
indent_style = space
indent_size = 2

[.gitmodules]
indent_style = tab

Expand Down
52 changes: 13 additions & 39 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: php

sudo: false

cache:
Expand All @@ -17,8 +16,6 @@ matrix:
- php: '7.0'
- php: '7.1'
- php: '7.2'
- php: '7.2'
env: coverage=1
- php: '7.2'
env: lint=1
- php: '7.2'
Expand All @@ -43,18 +40,6 @@ matrix:
before_install:
- phpenv config-rm xdebug.ini || echo "xdebug not available"
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- if [[ $coverage != 1 && $lint != 1 ]]; then
npm install -g swagger-cli;
fi
- if [[ $coverage = 1 ]]; then
mkdir -p build/logs build/cov;
fi
- if [[ $coverage = 1 ]]; then
wget https://phar.phpunit.de/phpcov.phar;
fi
- if [[ $coverage = 1 ]]; then
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar;
fi
- if [[ $lint = 1 ]]; then
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.8.4/php-cs-fixer.phar;
fi
Expand All @@ -64,47 +49,36 @@ before_install:
- export PATH="$PATH:$HOME/.composer/vendor/bin"

install:
- if [[ $coverage = 1 ]]; then
composer require --dev --no-update 'phpunit/php-code-coverage:^5.2.2';
fi
- if [[ $deps = 'low' ]]; then
composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi;
else
composer update --prefer-dist --no-progress --no-suggest --ansi;
fi

script:
- if [[ $coverage = 1 ]]; then
APP_ENV=test_phpunit phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-phpunit.cov;
elif [[ $lint != 1 ]]; then
APP_ENV=test_phpunit vendor/bin/phpunit;
- if [[ $lint != 1 ]]; then
tests/Fixtures/app/console cache:clear;
fi
- if [[ $lint != 1 ]]; then
vendor/bin/phpunit;
fi
- if [[ $lint != 1 ]]; then
tests/Fixtures/app/console cache:clear;
fi
- if [[ $coverage = 1 ]]; then
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature'); do
FEATURE=${f//\//_} phpdbg -qrr vendor/bin/behat --profile=coverage --suite=default --tags=~@postgress --format=progress $f || exit $?;
done;
elif [[ $APP_ENV = 'postgres' ]]; then
- if [[ $APP_ENV = 'postgres' ]]; then
vendor/bin/behat --suite=postgres --format=progress;
elif [[ $lint != 1 ]]; then
vendor/bin/behat --suite=default --format=progress;
fi
- if [[ $coverage = 1 ]]; then
phpdbg -qrr phpcov.phar merge --clover build/logs/clover.xml build/cov;
- if [[ $lint != 1 ]]; then
tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json;
fi
- if [[ $coverage != 1 && $lint != 1 ]]; then
tests/Fixtures/app/console api:swagger:export > swagger.json && swagger-cli validate swagger.json && rm swagger.json;
fi
- if [[ $coverage != 1 && $lint != 1 ]]; then
tests/Fixtures/app/console api:swagger:export --yaml > swagger.yaml && swagger-cli validate --no-schema swagger.yaml && rm swagger.yaml;
- if [[ $lint != 1 ]]; then
tests/Fixtures/app/console api:swagger:export --yaml > swagger.yaml && npx swagger-cli validate --no-schema swagger.yaml && rm swagger.yaml;
fi
- if [[ $lint = 1 ]]; then
php php-cs-fixer.phar fix --dry-run --diff --no-ansi;
fi
- if [[ $lint = 1 ]]; then
phpstan analyse -c phpstan.neon -l5 --ansi src tests;
fi

after_success:
- if [[ $coverage = 1 ]]; then
travis_retry php coveralls.phar;
fi
36 changes: 36 additions & 0 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Foo;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FooDummy;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FourthLevel;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Node;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Person;
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\PersonToPet;
Expand Down Expand Up @@ -732,6 +733,7 @@ public function thereIsARelatedDummyWithFriends(int $nb)
$relatedDummy2->setName('RelatedDummy without friends');
$this->manager->persist($relatedDummy2);
$this->manager->flush();
$this->manager->clear();
}

/**
Expand Down Expand Up @@ -883,4 +885,38 @@ public function thereIsARamseyIdentifiedResource(string $uuid)
$this->manager->persist($dummy);
$this->manager->flush();
}

/**
* @Given there is a dummy object with a fourth level relation
*/
public function thereIsADummyObjectWithAFourthLevelRelation()
{
$fourthLevel = new FourthLevel();
$fourthLevel->setLevel(4);
$this->manager->persist($fourthLevel);

$thirdLevel = new ThirdLevel();
$thirdLevel->setLevel(3);
$thirdLevel->setFourthLevel($fourthLevel);
$this->manager->persist($thirdLevel);

$namedRelatedDummy = new RelatedDummy();
$namedRelatedDummy->setName('Hello');
$namedRelatedDummy->setThirdLevel($thirdLevel);
$this->manager->persist($namedRelatedDummy);

$relatedDummy = new RelatedDummy();
$relatedDummy = new RelatedDummy();
$relatedDummy->setThirdLevel($thirdLevel);
$this->manager->persist($relatedDummy);

$dummy = new Dummy();
$dummy->setName('Dummy with relations');
$dummy->setRelatedDummy($namedRelatedDummy);
$dummy->addRelatedDummy($namedRelatedDummy);
$dummy->addRelatedDummy($relatedDummy);
$this->manager->persist($dummy);

$this->manager->flush();
}
}
1 change: 1 addition & 0 deletions features/doctrine/search_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Feature: Search filter on collections
And I send a "GET" request to "/related_dummies?relatedToDummyFriend.dummyFriend=/dummy_friends/4"
Then the response status code should be 200
And the JSON node "_embedded.item" should have 1 element
And the JSON node "_embedded.item[0].id" should be equal to the number 1
And the JSON node "_embedded.item[0]._links.relatedToDummyFriend" should have 4 elements
And the JSON node "_embedded.item[0]._embedded.relatedToDummyFriend" should have 4 elements

Expand Down
2 changes: 1 addition & 1 deletion features/main/non_resource.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Non-resources handling
"@context": "/contexts/ContainNonResource",
"@id": "/contain_non_resources/1",
"@type": "ContainNonResource",
"id": "1",
"id": 1,
"nested": {
"@id": "/contain_non_resources/1-nested",
"@type": "ContainNonResource",
Expand Down
Loading