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

Add upload to coveralls #7

Open
thekid opened this issue Sep 23, 2018 · 2 comments
Open

Add upload to coveralls #7

thekid opened this issue Sep 23, 2018 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@thekid
Copy link
Member

thekid commented Sep 23, 2018

Usage

$ xp coverage -p src/main/php -j coveralls.json,$API_TOKEN src/test/php
# ...
$ curl -x POST -F 'json_file=@coveralls.json' https://coveralls.io/api/v1/jobs

API

POST https://coveralls.io/api/v1/jobs
{
   "run_at" : "2018-09-23 15:06:08 +0000",
   "git" : {
      "head" : {
         "author_name" : "Timm Friebe",
         "committer_email" : "thekid@example.com",
         "author_email" : "thekid@example.com",
         "id" : "d03c81753e382c494697e08f5a75826c3858a608",
         "message" : "Fix newline and comment handling inside structures",
         "committer_name" : "Timm Friebe"
      },
      "remotes" : [
         {
            "url" : "git@github.com:xp-forge/yaml.git",
            "name" : "origin"
         }
      ],
      "branch" : "master"
   },
   "repo_token" : "...",
   "service_name" : "php-coveralls",
   "service_event_type" : "manual",
   "source_files" : [
      {
         "coverage" : [
            null,
            null,
            0
         ],
         "source" : "<?php namespace xp;\n\n\\lang\\ClassLoader::registerPath(__DIR__);",
         "name" : "src\\main\\php\\autoload.php"
      },
      
   ]
}

See https://docs.coveralls.io/api-reference

Outcome

coveralls

The paths with the Windows directory separator \ break the detailed view in Coveralls and should probably be translated to / before uploading!

@thekid thekid added enhancement New feature or request help wanted Extra attention is needed labels Sep 23, 2018
@thekid
Copy link
Member Author

thekid commented Sep 23, 2018

The head commit details can be fetched by this:

$ git log -1 --pretty=format:'%H%n%aN%n%ae%n%cN%n%ce%n%s'
d03c81753e382c494697e08f5a75826c3858a608
Timm Friebe
thekid@example.com
Timm Friebe
thekid@example.com
Fix newline and comment handling inside structures

@thekid
Copy link
Member Author

thekid commented Sep 23, 2018

Basically, after test has run:

  1. For each file:
    1. Generate coverage arrays for each line, e.g. [null, 1, 0, null, 4, 15, null]
    2. Collect sourcecode into a string
  2. Gather head commit details
  3. Set "service_name" : "...", "service_event_type" : "..."
  4. Set "repo_token" : "..."

...and then write all that to a JSON file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant