Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ ArgParse = "1"
Artifacts = "1"
CoverageTools = "1"
Downloads = "1.6.0"
HTTP = "0.8, 0.9, 1"
HTTP = "2"
JSON = "1"
MbedTLS = "0.6, 0.7, 1"
SHA = "0.7.0, 1"
Scratch = "1"
julia = "1"
julia = "1.10"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
8 changes: 4 additions & 4 deletions src/codecovio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ function submit_generic(fcs::Vector{FileCoverage}, kwargs::Dict)
# Tell Codecov we have an upload for them
response = HTTP.post(uri_str; headers=Dict("Accept" => "text/plain"))
# Get the temporary URL to use for uploading to S3
repr = String(response)
repr = string(response)
s3url = get(split(String(response.body), '\n'), 2, "")
repr = chomp(replace(repr, s3url => ""))
@debug "Result of submission:" * repr
Expand All @@ -309,9 +309,9 @@ function upload_to_s3(; s3url, fcs)
startswith(s3url, "https://") || error("Invalid codecov response: $s3url")
# Upload to S3
request = HTTP.put(s3url; body=JSON.json(to_json(fcs)),
header=Dict("Content-Type" => "application/json",
"x-amz-storage-class" => "REDUCED_REDUNDANCY"))
@debug "Result of submission:" * mask_token(String(request))
headers=Dict("Content-Type" => "application/json"))
@debug "Result of submission:" * mask_token(string(request))
return request
end

function construct_uri_string(kwargs::Dict)
Expand Down
2 changes: 1 addition & 1 deletion src/coveralls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function post_request(data)
coveralls_url = get(ENV, "COVERALLS_URL", "https://coveralls.io/api/v1/jobs")
headers = []
req = HTTP.post(coveralls_url, headers, HTTP.Form(makebody(data)))
@debug "Result of submission:\n" * String(req)
@debug "Result of submission:\n" * string(req)
nothing
end

Expand Down
12 changes: 9 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -585,14 +585,20 @@ withenv(
@test masked == "https://enterprise-codecov-1.com/upload/v4?token=<HIDDEN>&build=t_job_num"

@testset "Run the `Coverage.Codecov.upload_to_s3` function against the \"black hole\" server" begin
echo_server = "https://httpbingo.julialang.org/put"
black_hole_server = get(
ENV,
"JULIA_COVERAGE_BLACK_HOLE_SERVER_URL_PUT",
"https://httpbingo.julialang.org/put",
echo_server,
)
s3url = black_hole_server
fcs = Vector{CoverageTools.FileCoverage}(undef, 0)
Coverage.Codecov.upload_to_s3(; s3url=s3url, fcs=fcs)
response = Coverage.Codecov.upload_to_s3(; s3url=s3url, fcs=fcs)
if black_hole_server == echo_server
echoed = JSON.parse(String(response.body))["headers"]
@test echoed["Content-Type"] == ["application/json"]
@test !any(startswith(lowercase(k), "x-amz-") for k in keys(echoed))
end
end
end

Expand Down Expand Up @@ -1178,7 +1184,7 @@ withenv(
@test request.target ==
"/webhook?repo_token=token%20with%20%26%20symbols"
@test HTTP.header(request, "Content-Type") == "application/json"
@test JSON.parse(request.body) == Dict(
@test JSON.parse(String(request.body)) == Dict(
"payload" => Dict("build_num" => "123", "status" => "done"))

secret = "secret token&value"
Expand Down
Loading