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

added retry logic for HTTP calls #428

Merged
merged 2 commits into from
Apr 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion R/codecov.R
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ codecov <- function(...,

coverage_json <- to_codecov(coverage)

httr::content(httr::POST(url = codecov_url, query = codecov_query, body = coverage_json, encode = "json", httr::config(http_version = curl_http_1_1())))
httr::content(httr::RETRY("POST", url = codecov_url, query = codecov_query, body = coverage_json, encode = "json", httr::config(http_version = curl_http_1_1())))
}

curl_http_1_1 <- function() {
Expand Down
2 changes: 1 addition & 1 deletion R/coveralls.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ coveralls <- function(..., coverage = NULL,
coverage_json <- to_coveralls(coverage,
repo_token = repo_token, service_name = service)

result <- httr::POST(url = coveralls_url,
result <- httr::RETRY("POST", url = coveralls_url,
body = list(json_file = httr::upload_file(to_file(coverage_json))))

content <- httr::content(result)
Expand Down
32 changes: 16 additions & 16 deletions tests/testthat/test-codecov.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test_that("it generates a properly formatted json file", {

withr::with_envvar(ci_vars,
with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,
`covr:::local_branch` = function() "master",
`covr:::current_commit` = function() "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
Expand All @@ -78,7 +78,7 @@ test_that("it adds a flags argument to the query if specified", {

withr::with_envvar(ci_vars,
with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,
`covr:::local_branch` = function() "master",
`covr:::current_commit` = function() "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
Expand All @@ -93,7 +93,7 @@ test_that("it works with local repos", {
withr::with_envvar(ci_vars, {

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,
`covr:::local_branch` = function() "master",
`covr:::current_commit` = function() "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
Expand All @@ -110,7 +110,7 @@ test_that("it works with local repos and explicit branch and commit", {
withr::with_envvar(ci_vars, {

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov, branch = "master", commit = "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3"),
Expand All @@ -127,7 +127,7 @@ test_that("it adds the token to the query if available", {
"CODECOV_TOKEN" = "codecov_test"
),
with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,
`covr:::local_branch` = function() "master",
`covr:::current_commit` = function() "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
Expand All @@ -144,7 +144,7 @@ test_that("it adds the token to the query if available", {
test_that("it looks for token in a .yml file", {
withr::with_envvar(c(ci_vars),
with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,
`covr:::local_branch` = function() "master",
`covr:::current_commit` = function() "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
Expand All @@ -170,7 +170,7 @@ test_that("it works with jenkins", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand Down Expand Up @@ -198,7 +198,7 @@ test_that("it works with travis normal builds", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand Down Expand Up @@ -228,7 +228,7 @@ test_that("it works with travis pull requests", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand Down Expand Up @@ -256,7 +256,7 @@ test_that("it works with codeship", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand All @@ -282,7 +282,7 @@ test_that("it works with circleci", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand All @@ -308,7 +308,7 @@ test_that("it works with semaphore", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand All @@ -334,7 +334,7 @@ test_that("it works with drone", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand Down Expand Up @@ -362,7 +362,7 @@ test_that("it works with AppVeyor", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand All @@ -388,7 +388,7 @@ test_that("it works with Wercker", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand All @@ -415,7 +415,7 @@ test_that("it works with GitLab", {
),

with_mock(
`httr::POST` = function(...) list(...),
`httr::RETRY` = function(...) list(...),
`httr::content` = identity,

res <- codecov(coverage = cov),
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-coveralls.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test_that("coveralls generates a properly formatted json file", {

withr::with_envvar(c(ci_vars, "CI_NAME" = "FAKECI"),
with_mock(
`httr:::POST` = function(...) list(...),
`httr:::RETRY` = function(...) list(...),
`httr::content` = identity,
`httr::upload_file` = function(file) readChar(file, file.info(file)$size),

Expand All @@ -78,7 +78,7 @@ test_that("coveralls can spawn a job using repo_token", {

withr::with_envvar(c(ci_vars, "CI_NAME" = "DRONE"),
with_mock(
`httr:::POST` = function(...) list(...),
`httr:::RETRY` = function(...) list(...),
`httr::content` = identity,
`httr::upload_file` = function(file) readChar(file, file.info(file)$size),
`covr::system_output` = function(...) paste0(c("a", "b", "c", "d", "e", "f"), collapse = "\n"),
Expand Down Expand Up @@ -126,7 +126,7 @@ test_that("coveralls can spawn a job using repo_token - travis-pro #285", {

withr::with_envvar(c(ci_vars, "CI_NAME" = "travis-pro"),
with_mock(
`httr:::POST` = function(...) list(...),
`httr:::RETRY` = function(...) list(...),
`httr::content` = identity,
`httr::upload_file` = function(file) readChar(file, file.info(file)$size),
`covr::system_output` = function(...) paste0(c("a", "b", "c", "d", "e", "f"), collapse = "\n"),
Expand All @@ -153,4 +153,4 @@ test_that("coveralls can spawn a job using repo_token - travis-pro #285", {
expect_equal(json$git$head$message, "f")
)
)
})
})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this newline was added automatically by my editor. If you'd like me to revert it, let me know.