Skip to content
Closed
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
19 changes: 14 additions & 5 deletions src/codecovio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,19 @@ module Codecov
@debug "Codecov.io API URL:\n" * mask_token(uri_str)

if !dry_run
heads = Dict("Content-Type" => "application/json")
data = to_json(fcs)
req = HTTP.post(uri_str; body = JSON.json(data), headers = heads)
@debug "Result of submission:" * mask_token(String(req))
# 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)
s3url = get(split(String(response.body), '\n'), 2, "")
repr = chomp(replace(repr, s3url => ""))
@debug "Result of submission:" * repr
startswith(s3url, "https://") || error("Invalid codecov response: $s3url")
# Upload to S3
request = HTTP.put(s3url; body=json(to_json(fcs)),
header=Dict("Content-Type" => "application/json",
"x-amz-storage-class" => "REDUCED_REDUNDANCY"))
@debug "Result of submission:" * mask_token(String(request))
end
end

Expand All @@ -252,7 +261,7 @@ module Codecov
error("the codecov_url should not end with a /, given url $(repr(codecov_url))")
end

codecov_url_path = get(kwargs, :codecov_url_path, "/upload/v2")
codecov_url_path = get(kwargs, :codecov_url_path, "/upload/v4")
if isempty(codecov_url_path) || codecov_url_path[1] != '/' || codecov_url_path[end] == '/'
error("the codecov_url_path should begin with, but not end with, a /, given url $(repr(codecov_url_path))")
end
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ withenv(

# in the case above, the token is at the end. Let's test explicitly,
# that this also works if the token occurs earlier in the url
url = "https://enterprise-codecov-1.com/upload/v2?token=token_name_1&build=t_job_num"
url = "https://enterprise-codecov-1.com/upload/v4?token=token_name_1&build=t_job_num"
masked = Coverage.Codecov.mask_token(url)
@test masked == "https://enterprise-codecov-1.com/upload/v2?token=<HIDDEN>&build=t_job_num"
@test masked == "https://enterprise-codecov-1.com/upload/v4?token=<HIDDEN>&build=t_job_num"
end


Expand Down