Skip to content
Mark Clearwater edited this page Jun 1, 2018 · 2 revisions

Coveralls.net can be used to publish coverage on pull requests through GitHub. Build servers like TeamCity and Travis allow you to add secure environment variables without issue. From memory, these values are automatically blanked out in console output on Travis and TeamCity.

However for security reasons Appveyor secure variables are not always available during a Pull Request build.

If your Pull Request is between two branches on the upstream repository, then the token will be available.

**Note that if your Org/RepoName in GitHub doesn't match the one in AppVeyor (case sensitive) then it thinks the two branches are in different repos, and the token will not be set, either. update the name setting and this will be fixed. **

This means that you will need to add guarded checks around your coveralls.net code, if you have your COVERALLS_REPO_TOKEN in a secure variable (which is recommended). You can't run coverage without the token, so disabling when it is empty is your best option to avoid failing Pull Request builds.

Disabling Coveralls.net for Pull Requests

If you are using PSake for your builds, you can use a precondition on the env:COVERALLS_REPO_TOKEN variable to only run coveralls if you are not on a pull request. This will skip the step when the token is unavailable.

    task coveralls -precondition { return -not $COVERALLS_REPO_TOKEN }{
        exec { & $coveralls ... }
    }

Alternatively you could condition on the env:APPVEYOR_PULL_REQUEST_NUMBER variable, and disable coverage publishing on pull requests altogether.

Insecure Coveralls.io token for Pull Requests

You may not be worried about securing your token. maybe you have a private repository or are using GitHub Enterprise, or maybe the nature of your project means you can accept the consequences. If this is the case you can still publish coverage over your Pull Requests. Either put your token straight into your build script, or leave it insecure in your environment section on your appveyor.yml file. This will allow it to always work on all Pull Requests. This is a risk. You have been warned.