diff --git a/.Rbuildignore b/.Rbuildignore index d31234c..c09fe20 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -13,3 +13,7 @@ ^pkgdown$ ^project_metadata.yaml ^.lintr +^CRAN-SUBMISSION$ +^cran-comments\.md$ +^vignettes/get_and_store_data\.Rmd$ +^vignettes/get_files\.Rmd$ diff --git a/README.Rmd b/README.Rmd index d8319f0..8f6de2a 100644 --- a/README.Rmd +++ b/README.Rmd @@ -34,6 +34,12 @@ With GitStats you can pull git data in a uniform way (table format) from GitHub ## Installation ```r +From CRAN: + +install.packages("GitStats") + +Or development version: + devtools::install_github("r-world-devs/GitStats") ``` diff --git a/README.md b/README.md index f0b4643..decb72a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ GitHub and GitLab. For the time-being you can get data on: ## Installation ``` r +From CRAN: + +install.packages("GitStats") + +Or development version: + devtools::install_github("r-world-devs/GitStats") ``` diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..858617d --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,5 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* This is a new release. diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 0b13ecd..9704d42 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -1,53 +1,3 @@ -if (nchar(Sys.getenv("GITHUB_PAT")) == 0) { - cli::cli_abort(c( - "x" = "You did not set up your GITHUB_PAT environment variable.", - "i" = "If you wish to run tests for GitHub - set up your GITHUB_PAT - enviroment variable (as a GitHub access token on github.com)." - )) -} -if (nchar(Sys.getenv("GITHUB_PAT")) > 0) { - tryCatch({ - httr2::request("https://api.github.com") %>% - httr2::req_headers("Authorization" = paste0("Bearer ", Sys.getenv("GITHUB_PAT"))) %>% - httr2::req_perform() - }, - error = function(e) { - if (grepl("401", e$message)) { - cli::cli_abort(c( - "x" = "Your GITHUB_PAT enviroment variable does not grant access. Please - setup your GITHUB_PAT before running tests.", - "i" = "If you wish to run tests for GitHub - set up your GITHUB_PAT - enviroment variable (as a GitHub access token on github.com)." - )) - } - }) -} -if (nchar(Sys.getenv("GITLAB_PAT_PUBLIC")) == 0) { - cli::cli_abort(c( - "x" = "You did not set up your GITLAB_PAT_PUBLIC environment variable.", - "i" = "If you wish to run tests for GitLab - set up your GITLAB_PAT_PUBLIC - enviroment variable (as a GitLab access token on gitlab.com)." - )) -} -if (nchar(Sys.getenv("GITLAB_PAT_PUBLIC")) > 0) { - tryCatch({ - httr2::request("https://gitlab.com/api/v4/projects") %>% - httr2::req_headers("Authorization" = paste0("Bearer ", - Sys.getenv("GITLAB_PAT_PUBLIC"))) %>% - httr2::req_perform() - }, - error = function(e) { - if (grepl("401", e$message)) { - cli::cli_abort(c( - "x" = "Your GITLAB_PAT_PUBLIC enviroment variable does not grant access. - Please setup your GITLAB_PAT_PUBLIC before running tests.", - "i" = "If you wish to run tests for GitLab - set up your GITLAB_PAT_PUBLIC - enviroment variable (as a GitLab access token on gitlab.com)." - )) - } - }) -} - test_mocker <- Mocker$new() test_gitstats <- create_test_gitstats(hosts = 2) diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index 34c498b..86b4a34 100644 --- a/tests/testthat/test-helpers.R +++ b/tests/testthat/test-helpers.R @@ -152,6 +152,7 @@ test_that("`test_token` works properly", { }) test_that("`set_default_token` sets default token for GitLab", { + skip_on_cran() expect_snapshot( withr::with_envvar(new = c("GITLAB_PAT" = Sys.getenv("GITLAB_PAT_PUBLIC")), { default_token <- gitlab_testhost_priv$set_default_token(verbose = TRUE) diff --git a/vignettes/set_hosts.Rmd b/vignettes/set_hosts.Rmd index 976b7dc..74734a7 100644 --- a/vignettes/set_hosts.Rmd +++ b/vignettes/set_hosts.Rmd @@ -33,7 +33,7 @@ When setting hosts you need to take into account: If you connect to public hosts you simply call `set_github_host()` or `set_gitlab_host()` function without specifying `host` parameter. -```{r} +```{r, eval = FALSE} library(GitStats) git_stats <- create_gitstats() %>% set_github_host( @@ -72,7 +72,7 @@ When setting hosts you choose what scanning scope of your GitStats will be: * `organizations/groups` - in this case you need to pass character arguments (names of organizations (in case of GitHub) or groups (in case of GitLab)) to `orgs` parameter. -```{r} +```{r, eval = FALSE} git_stats <- create_gitstats() %>% set_github_host( orgs = c("r-world-devs", "openpharma"),