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

ocular.phar does not work on AppVeyor #40

Open
Majkl578 opened this issue Apr 7, 2018 · 13 comments
Open

ocular.phar does not work on AppVeyor #40

Majkl578 opened this issue Apr 7, 2018 · 13 comments

Comments

@Majkl578
Copy link

Majkl578 commented Apr 7, 2018

Hi,
while working on multriple coverage reports for Doctrine DBAL, I ran into problems with uploading coverage to Scrutinizer on AppVeyor. It seems to either fail executing the introspector processes or parse its CLI outputs correctly.

After simply running:

php.exe ocular.phar code-coverage:upload --format=php-clover clover.xml

I am getting the following error error:

#!/usr/bin/env php
php.exe : 
At line:3 char:3
+   php.exe ocular.phar code-coverage:upload --format=php-clover clover ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : NotSpecified: (:String) [], RemoteException
   + FullyQualifiedErrorId : NativeCommandError

                                          
 [RuntimeException]                       
 Could not extract repository name from:  
                                          
                                          
code-coverage:upload [--api-url="..."] [--repository="..."] [--revision="..."] [--format="..."] [--parent="..."] coverage-file
Command executed with exception:   Could not extract repository name from:  
                                          
                                          
code-coverage:upload [--api-url="..."] [--repository="..."] [--revision="..."] [--format="..."] [--parent="..."] coverage-file

I executed the commands ran by introspector separately to see if they work and they do:

git remote -v
origin	https://github.com/Majkl578/doctrine-dbal.git (fetch)
origin	https://github.com/Majkl578/doctrine-dbal.git (push)
git rev-parse HEAD
679ee9732663db57d7d3927770ab887fd4f11d58
git log --pretty="%P" -n1 HEAD
f28f0977ac78738bd777b05424988aa2b5e9c51c

You can find the failing build here: https://ci.appveyor.com/project/Majkl578/doctrine-dbal/build/1.0.310/job/20bkb4l3wn2uho0j#L1776
Used script is here: https://github.com/Majkl578/doctrine-dbal/blob/679ee9732663db57d7d3927770ab887fd4f11d58/.appveyor.yml#L115-L127

@morozov
Copy link

morozov commented Apr 7, 2018

The issue seems only reproducible when using the PHAR distribution but not with the clone from the master branch. Is PHAR up to date?

Git clone from master:

d:\Projects\dbal>php.exe ../ocular/bin/ocular code-coverage:upload --format=php-clover clover.xml
Uploading code coverage for repository "g/morozov/dbal" and revision "f8e884c628da185b692240e3b03d285ecce054c6"... Failed

In RequestException.php line 113:

  Client error: `POST https://scrutinizer-ci.com/api/repositories/g/morozov/dbal/data/code-coverage` resulted in a `404 Not Found` response:  {"error":{"code":404,"message":"Not Found"}}

code-coverage:upload [--api-url API-URL] [--repository REPOSITORY] [--revision REVISION] [--format FORMAT] [--parent PARENT] [--] <coverage-file>

PHAR:

d:\Projects\dbal>php.exe ../ocular.phar code-coverage:upload --format=php-clover clover.xml
#!/usr/bin/env php

  [RuntimeException]
  Could not extract repository name from:

code-coverage:upload [--api-url="..."] [--repository="..."] [--revision="..."] [--format="..."] [--parent="..."] coverage-file

@schmittjoh
Copy link
Member

As a quick fix (if this is the only error) I would recommend to pass the repository, revision and parents explicitly instead of relying on the introspector.

Have you tried that already?

@Majkl578
Copy link
Author

I did. I managed to pass repository and revivison using AppVeyor env vars, but I have no idea how to pass parents, especially if the commit has multiple (merge commit). I am not a Windows/PowerShell guy so I have no idea how to parse & pass the output of git log --pretty="%P" -n1 HEAD.
I could test using direct dependency instead of PHAR at least.

@morozov
Copy link

morozov commented Apr 11, 2018

Yes, but looks like it failed for a different reason (code, build). @Majkl578 did that.

@schmittjoh
Copy link
Member

The error should be due to the repository name, it should be g/doctrine/dbal since it's a GitHub repository.

As for parents, you would pass them like --parent=PARENT1 --parent=PARENT2, however unfortunately I can also not help you with how to accomplish this in Windows. We do not use it ourselves and have no Windows machine available to test at the moment.

As for the original error, could that be because we do not call git.exe, but just git in the introspector? If you have a Windows machine, maybe you could test changing this, then we could merge a fix for the original error, too.

@morozov
Copy link

morozov commented Apr 12, 2018

@schmittjoh I tried debugging ocular.phar on Windows, and there's definitely something going on in symfony/process. Particularly, without the debugger enabled, I get the "Could not extract repository name" exception, but if I do a step-by-step debugging of Process:run(), this issue goes away.

Most likely, it has something to do with their non-blocking reads from the pipes or file handles where the client exits too early before any output is generated in the process.

Could you point me to the composer.lock which ocular.phar was built from so that I could identify a potentially existing symfony/process issue which causes that?

@morozov
Copy link

morozov commented Apr 12, 2018

Okay, it must be symfony/process@5f48984 which fixed the issue. Particularly, in Ocular, it happens here:

https://github.com/symfony/process/blob/8ecb1c644d1a52f306d5a01c2c3817b5aaa92317/Process.php#L1003

They do not check for feof() but just check the length of the read data, however empty data doesn't mean end of file.

@schmittjoh Given the code has been modified in v2.2.7 and potentially fixed the issue, please see if you can update your dependencies to solve this problem.

@morozov
Copy link

morozov commented Apr 12, 2018

According to the PHAR, it was built from 8e0a8c7 — exactly 4 years ago. Time to upgrade!

@schmittjoh
Copy link
Member

Good catch! An upgrade was indeed not needed since then. I've gone ahead and pushed the current version which uses the Process component of Symfony 4.

Could you check if this is fixed now?

@Majkl578
Copy link
Author

@schmittjoh Seems to be working now!

Uploading code coverage for repository "g/doctrine/dbal" and revision "12e3a6fc2ae2e81cece8208e961de04e4f04c38e"... Done

I only had to manually download & set CA bundle for cURL, otherwise it crashed with missing CA info. But that is environment/runtime issue.

Thanks.

@schmittjoh
Copy link
Member

schmittjoh commented Apr 25, 2018

Unfortunately, we have to revert this change. The new version is too new unfortunately and breaks on certain PHP versions.

I'm reopening this for the moment. You can still get the newer ocular.phar from the GitHub release page here, f.e. https://github.com/scrutinizer-ci/ocular/releases/download/1.5.2/ocular.phar

@schmittjoh schmittjoh reopened this Apr 25, 2018
@mmucklo
Copy link

mmucklo commented Aug 11, 2019

Has this been fixed yet?

@schmittjoh
Copy link
Member

schmittjoh commented Aug 11, 2019

For the time being, we cannot update the version hosted at https://scrutinizer-ci.com/ocular.phar for compatibility reasons. However, you can directly download it from one the GitHub releases (see above) which should be equally stable.

Have you run into any issues with that?

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

No branches or pull requests

4 participants