Skip to content

Commit

Permalink
Support COVERALLS_PARALLEL environment variable (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash authored Nov 25, 2019
1 parent 9e3c9e2 commit bd7fe77
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ julia:
- nightly

notifications:
email: false
webhooks: https://coveralls.io/webhook
email: false

script:
- julia --check-bounds=yes etc/travis-test.jl
- export COVERALLS_PARALLEL=true
# submit coverage data, and collect new coverage data on that
- julia --code-coverage=user etc/travis-coverage.jl
# submit coverage data *again*, this time without code coverage
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ When using Coverage.jl locally, over time a lot of `.cov` files can accumulate.
- C:\projects\julia\bin\julia -e "using Pkg; Pkg.add(\"Coverage\"); using Coverage; Coveralls.submit(process_folder())"
```

4. If you are uploading from multiple jobs, you'll need to tell Coveralls to merge the results after all CI jobs have completed. See https://docs.coveralls.io/parallel-build-webhook for general instructions.

For Travis, this can be achieved by adding the following to `.travis.yml`:

env:
global:
- COVERALLS_PARALLEL=true
notifications:
webhooks: https://coveralls.io/webhook


## A note for advanced users

Coverage tracking in Julia is not yet quite perfect. One problem is that (at
Expand Down
4 changes: 4 additions & 0 deletions src/coveralls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ module Coveralls
end

data = add_repo_token(data, local_env)
if get(ENV, "COVERALLS_PARALLEL", "false") == "true"
data["parallel"] = "true"
end
return data
end

Expand Down Expand Up @@ -185,6 +188,7 @@ module Coveralls
verbose && @info "Submitting data to Coveralls..."
req = HTTP.post("https://coveralls.io/api/v1/jobs", HTTP.Form(makebody(data)))
verbose && @debug "Result of submission:\n" * String(req.body)
nothing
end

# adds the repo token to the data
Expand Down
9 changes: 7 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -600,29 +600,34 @@ withenv(
@test request["service_job_id"] == "my_job_id"
@test request["service_name"] == "appveyor"
@test request["service_pull_request"] == "t_pr"
@test !haskey(request, "parallel")
end

# test Travis
withenv("TRAVIS" => "true",
"TRAVIS_JOB_ID" => "my_job_id",
"TRAVIS_PULL_REQUEST" => "t_pr") do
"TRAVIS_PULL_REQUEST" => "t_pr",
"COVERALLS_PARALLEL" => "true") do
request = Coverage.Coveralls.prepare_request(fcs, false)
@test request["repo_token"] == "token_name_1"
@test request["service_job_id"] == "my_job_id"
@test request["service_name"] == "travis-ci"
@test request["service_pull_request"] == "t_pr"
@test request["parallel"] == "true"
end

# test Jenkins
withenv("JENKINS" => "true",
"BUILD_ID" => "my_job_id",
"CI_PULL_REQUEST" => true) do
"CI_PULL_REQUEST" => true,
"COVERALLS_PARALLEL" => "not") do
my_git_info = Dict("remote_name" => "my_origin")
request = Coverage.Coveralls.prepare_request(fcs, false)
@test request["repo_token"] == "token_name_1"
@test request["service_job_id"] == "my_job_id"
@test request["service_name"] == "jenkins-ci"
@test !haskey(request, "service_pull_request")
@test !haskey(request, "parallel")

withenv("CI_PULL_REQUEST" => "false",
"GIT_BRANCH" => "my_remote/my_branch") do
Expand Down

0 comments on commit bd7fe77

Please sign in to comment.