Skip to content
This repository has been archived by the owner on Apr 12, 2018. It is now read-only.

How can I upload external code coverage to scrutinizer-ci #394

Open
jblanchon opened this issue Mar 2, 2017 · 1 comment
Open

How can I upload external code coverage to scrutinizer-ci #394

jblanchon opened this issue Mar 2, 2017 · 1 comment

Comments

@jblanchon
Copy link

Hi,
I've got an issue with ocular and scrutinizer-ci.
Following this documentation https://scrutinizer-ci.com/docs/tools/external-code-coverage/#php
I tried to upload a simple code coverage into a private scrutinizer repository, I follow all the documentation steps :

  1. I Updated the scrutinizer configuration (from scrutinizer-ci.com)
tools:
    external_code_coverage: true
filter:
    paths:
        - 'src/*'
    excluded_paths:
        - "*/config/*"
        - "*/Tests/*"
        - 'src/AuditBundle/*'
        - 'src/*/Behat/*'
        - 'app/DoctrineMigrations/*'
        - 'app/LegacyMigrations/*'
checks:
    php:
        duplication: false
        avoid_closing_tag: false
        avoid_conflicting_incrementers: false
        avoid_entity_manager_injection: false
        avoid_useless_overridden_methods: true
        closure_use_modifiable: false
        foreach_usable_as_reference: false
        no_commented_out_code: false
        no_empty_statements: false
        no_trait_type_hints: false
        single_namespace_per_use: false
        unused_parameters: false
        overriding_parameter: false

coding_style:
    php:
        spaces:
            around_operators:
                concatenation: false
            other:
                after_type_cast: false
  1. I created the access token in order to execute the upload. (with full access)

  2. I execute my tests : vendor/bin/phpunit --coverage-clover=coverage.clover Which gives me a coverage.clover file at the root directory of my projet

<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1488352865">
  <project timestamp="1488352865">
    <package name="TestPolaris">
      <file name="/home/me/www/test/src/Math.php">
        <class name="Math" namespace="TestPolaris">
          <metrics complexity="1" methods="1" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="1" coveredstatements="1" elements="2" coveredelements="2"/>
        </class>
        <line num="7" type="method" name="double" visibility="public" complexity="1" crap="1" count="1"/>
        <line num="8" type="stmt" count="1"/>
        <metrics loc="10" ncloc="10" classes="1" methods="1" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="1" coveredstatements="1" elements="2" coveredelements="2"/>
      </file>
    </package>
    <metrics files="1" loc="10" ncloc="10" classes="1" methods="1" coveredmethods="1" conditionals="0" coveredconditionals="0" statements="1" coveredstatements="1" elements="2" coveredelements="2"/>
  </project>
</coverage>
  1. execute the wget https://scrutinizer-ci.com/ocular.phar

And finaly,
5) Execute the following command with the created access-token :

php ocular.phar code-coverage:upload --access-token="ef247198b80ddb9358d8cf8e0ea1MYTOKEN789e0db0c6978e3777777777" --format=php-clover coverage.clover

The command result is :

#!/usr/bin/env php
Uploading code coverage for repository "b/snieditions/test" and revision "867595d41dfc747af619ec0085213d4c86b77dd8"... Done

(I executed all these command manually in my terminal and at the root directory of my project)
The command is telling me the job is done without any erros, but I did not manage to find my coverage in the scrutinizer interface. I don't think there is a big problem, I probably just miss a little thing but I don't know what. or maybe I don't look at place.

Thank you for your help,

@webmake
Copy link

webmake commented May 4, 2017

Hi,
if you still didn't succeeded to find it, here is the answer how to reach.
The coverage is under Inspections, click on any version you want, then click Code, there you will see Coverage changes. But actually all files have an option to show Code coverage as a filter

image
The url would be https://scrutinizer-ci.com/b/vendor/package/code-structure/master, then click any covered file. If file is not covered by tests, then Code coverage is inactive

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

No branches or pull requests

2 participants