Skip to content

Conversation

baspeeters
Copy link
Contributor

@baspeeters baspeeters commented Oct 30, 2018

⚠️ #124 issue is another cause of the failing tests.

Background

Build was failing on Travis CI. Every tiny fix yielded the next error.

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? no
Fixed tickets N/A
License MIT
Doc PR N/A

Problems

Problem 1

$ if [[ $lint = 1 ]]; then composer global require --dev 'phpstan/phpstan:^0.8'; fi
Changed current directory to /home/travis/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Conclusion: don't install phpstan/phpstan 0.8.5
...
    - Conclusion: don't install phpstan/phpstan 0.8.1
    - Conclusion: remove nikic/php-parser v4.1.0
    - Installation request for phpstan/phpstan ^0.8 -> satisfiable by phpstan/phpstan[0.8, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5].
    - Conclusion: don't install nikic/php-parser v4.1.0
    - phpstan/phpstan 0.8 requires nikic/php-parser ^3.0.2 -> satisfiable by nikic/php-parser[v3.0.2, v3.0.3, v3.0.4, v3.0.5, v3.0.6, v3.1.0, v3.1.1, v3.1.2, v3.1.3, v3.1.4, v3.1.5].
    - Can only install one of: nikic/php-parser[v3.0.2, v4.1.0].
...
    - Can only install one of: nikic/php-parser[v3.1.5, v4.1.0].
    - Installation request for nikic/php-parser (locked at v4.1.0) -> satisfiable by nikic/php-parser[v4.1.0].

Installation failed, reverting ./composer.json to its original content.

The command "if [[ $lint = 1 ]]; then composer global require --dev 'phpstan/phpstan:^0.8'; fi" failed and exited with 2 during .

Your build has been stopped.

Fixed this by changing version ^0.8 for phpstan/phpstan to a higher stable one (^0.10).

Problem 2

0.07s$ if [[ $coverage = 1 ]]; then phpdbg -qrr phpunit-6.3.phar --coverage-clover build/logs/clover.xml; else php phpunit-6.5.phar; fi
[Could not open file /home/travis/build/baspeeters/schema-generator/phpunit-6.3.phar]
[Failed to compile /home/travis/build/baspeeters/schema-generator/phpunit-6.3.phar, cannot run]

Fixed this by correcting the reference to PHPUnit (earlier in .travis.yml it explicitly installs version 6.5).

Problem 3

$ if [[ $coverage = 1 ]]; then phpdbg -qrr phpunit-6.5.phar --coverage-clover build/logs/clover.xml; else php phpunit-6.5.phar; fi
...
1) ApiPlatform\SchemaGenerator\Tests\Command\GenerateTypesCommandTest::testFluentMutators
Failed asserting that '<?php\n
\n
...
\n
    public function addFriend(Person $friend): self\n
    {\n
        $this->friends[] = $friend;\n
...
' contains "    public function addFriend(self $friend): self
    {
        $this->friends[] = $friend;

At first I thought this was an issue with newlines, but it appeared that this test expected the reference to a friend to be of type self, but this is referenced as type Person. PHPUnit never got to this point because of the above problems. Updated the reference to Person.

Problem 4

Some phpstan analysis errors:

------ --------------------------------------- 
  Line   TypesGenerator.php                     
 ------ --------------------------------------- 
  139    Variable $graph might not be defined.  
 ------ --------------------------------------- 

Now the cursor gets out of the cycle when $graph is empty so that it won't reach the code trying to use this var which is declared in a previous foreach.

 ------ ------------------------------------------------------------------------- 
  Line   TypesGeneratorConfiguration.php                                          
 ------ ------------------------------------------------------------------------- 
  58     Call to an undefined method                                              
         Symfony\Component\Config\Definition\Builder\NodeDefinition::children().  
 ------ ------------------------------------------------------------------------- 

ArrayNode definitely has the method childred(), I've even checked it with a var dump. This took me ages. Eventually found this issue where the maintainer commented also. It claims the error message is wrong and you should ignore this specific error...

Problem 5

Installing packages with the lowest stable versions caused package friendsofphp/php-cs-fixer to format self-referencing entities to be formatted ad self instead of the entity name. Upgraded the version of this package by 0.1.

Problem 6


Composer could not find a composer.json file in /home/travis/build/api-platform/schema-generator/build/schema-generator
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Building...

  [RuntimeException]                                                                                              
  failed to get contents of '/home/travis/build/api-platform/schema-generator/build/schema-generator/bin/schema'  

#124

@baspeeters baspeeters changed the title Fix/travis lint Fix lint stage on Travis CI Oct 30, 2018
@baspeeters baspeeters force-pushed the fix/travis-lint branch 3 times, most recently from 3a1c37c to 43e9bc3 Compare October 30, 2018 06:46
@dunglas
Copy link
Member

dunglas commented Oct 30, 2018

Thank you very much for handling this!

@baspeeters baspeeters force-pushed the fix/travis-lint branch 2 times, most recently from 5d45f8f to cc08881 Compare October 30, 2018 07:35
@baspeeters baspeeters changed the title Fix lint stage on Travis CI Fix Travis CI tests Oct 30, 2018
@baspeeters baspeeters force-pushed the fix/travis-lint branch 12 times, most recently from 3e9e244 to 9054e0f Compare October 30, 2018 12:49
@baspeeters
Copy link
Contributor Author

@dunglas no worries! 🙂 I just seem to be stuck on 1 more weird error:

------ ----------------------------------------------------------------------------------------------------- 
  Line   TypesGeneratorConfiguration.php                                                                      
 ------ ----------------------------------------------------------------------------------------------------- 
  65     Call to an undefined method Symfony\Component\Config\Definition\Builder\NodeDefinition::children().  
 ------ -----------------------------------------------------------------------------------------------------

That's what phpstan says in the build with PHP: 7.2, coverage=1 lint=1. It's weird because the ArrayNode definitely has the method childred(), I've even checked it with a var dump. Previously it complained about this further down the tree as well, but I was able to fix it by changing prototype('array') to arrayPrototype(), however this does not seem to work for the $rootNode.

@baspeeters baspeeters force-pushed the fix/travis-lint branch 3 times, most recently from 0dd3301 to 83dd8f3 Compare October 31, 2018 12:41
@baspeeters
Copy link
Contributor Author

Tests are green now, but there's still an error message.

@dunglas
Copy link
Member

dunglas commented Oct 31, 2018

@baspeeters regarding the PHPStan error, it's a known issue with the Symfony Config component, you can just add it to the ignore list.

@baspeeters baspeeters force-pushed the fix/travis-lint branch 7 times, most recently from a767667 to 477571d Compare November 1, 2018 02:25
- Update phpstan/phpstan from ^0.8 to ^0.10
- Correct a reference to phpunit.phar
- Change expected type `self` to `Person` in testFluentMutators
- Ignore phpstan error (info: keboola/php-component#8)
@dunglas
Copy link
Member

dunglas commented Nov 2, 2018

Maybe can we just drop PHP Scoper in the meantime?

@theofidry
Copy link
Contributor

@dunglas done in #124 so maybe we can just ignore the PHAR related errors here

@dunglas dunglas merged commit 3aa758b into api-platform:master Nov 2, 2018
@dunglas
Copy link
Member

dunglas commented Nov 2, 2018

Merged then, thank you very much @baspeeters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants