diff --git a/.Rbuildignore b/.Rbuildignore index d31234c8..c09fe20f 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/.github/workflows/version.yaml b/.github/workflows/version.yaml index ecae3763..c41515eb 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -2,8 +2,7 @@ name: ⬆️ Check Version Bump on: pull_request: - paths: - - DESCRIPTION + branches: [devel, test, master] jobs: check-version: diff --git a/DESCRIPTION b/DESCRIPTION index 5cf3f4cc..7fc26d69 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,15 +1,15 @@ Package: GitStats Title: Get Statistics from GitHub and GitLab -Version: 2.1.1 +Version: 2.1.1.9000 Authors@R: c( person(given = "Maciej", family = "Banas", email = "banasmaciek@gmail.com", role = c("aut", "cre")), person(given = "Kamil", family = "Koziej", email = "koziej.k@gmail.com", role = "aut"), person(given = "Karolina", family = "Marcinkowska", email = "karolina_marcinkowska@onet.pl", role = "aut"), person(given = "Matt", family = "Secrest", email = "secrestm@gene.com", role = "aut") ) -Description: Obtain statistics in a standardized way from multiple Git services: GitHub and GitLab for the time-being. - Its main purpose is to help teams, whose activities are spread across multiple git platforms, get their repository - metadata in a standardized way from all these platforms. +Description: Obtain statistics in a standardized way from multiple Git services. Its main purpose is to help teams, + whose activities are spread across multiple git platforms, get their repository metadata in a standardized way + from all these platforms. License: MIT + file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE, r6 = TRUE) diff --git a/NEWS.md b/NEWS.md index 8d5645fc..f953c45c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -75,7 +75,7 @@ This is a major release with general changes in workflow (simplifying it), chang ## Simplifying workflow: -- GitStats workflow is now simplified. To pull data on `repositories`, `commits`, `R_package_usage` or other you should use directly corresponding `get_*()` functions instead of `pull_*()` which are deprecated. These `get_*()` functions pull data from API, parse it into table, add some goodies (additional columns) if needed and return table instead of `GitStats` object, which in our opinion is more intuitive and user-friendly ([#345]((https://github.com/r-world-devs/GitStats/issues/345))). That means you do not need to run in pipe two or three additional function calls as before, e.g. `pull_repos(gitstats_object) %>% get_repos() %>% get_repos_stats()`, but you just run +- GitStats workflow is now simplified. To pull data on `repositories`, `commits`, `R_package_usage` or other you should use directly corresponding `get_*()` functions instead of `pull_*()` which are deprecated. These `get_*()` functions pull data from API, parse it into table, add some goodies (additional columns) if needed and return table instead of `GitStats` object, which in our opinion is more intuitive and user-friendly ([#345](https://github.com/r-world-devs/GitStats/issues/345)). That means you do not need to run in pipe two or three additional function calls as before, e.g. `pull_repos(gitstats_object) %>% get_repos() %>% get_repos_stats()`, but you just run `get_repos(gitstats_object)` to get data you need. - Moreover, if you run for the second time `get_*()` function `GitStats` will pull the data from its storage and not from API as for the first time, unless you change parameters for the function (e.g. starting date with `since` in `get_commits()`) or change directly the `cache` parameter in the function. ([#333](https://github.com/r-world-devs/GitStats/issues/333)) - `pull_repos_contributors()` as a separate function is deprecated. The parameter `add_contributors` is now set by default to `TRUE` in `get_repos()` which seems more reasonable as user gets all the data. diff --git a/README.Rmd b/README.Rmd index d8319f04..8f6de2aa 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 f0b46433..decb72a6 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 00000000..858617db --- /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/_snaps/01-get_repos-GitHub.md b/tests/testthat/_snaps/01-get_repos-GitHub.md index 9ca42bbd..b4419cf2 100644 --- a/tests/testthat/_snaps/01-get_repos-GitHub.md +++ b/tests/testthat/_snaps/01-get_repos-GitHub.md @@ -5,35 +5,10 @@ Output [1] "\n query GetReposByOrg($login: String! $repoCursor: String!) {\n repositoryOwner(login: $login) {\n ... on Organization {\n \n repositories(first: 100 after: $repoCursor) {\n totalCount\n pageInfo {\n endCursor\n hasNextPage\n }\n nodes {\n repo_id: id\n repo_name: name\n default_branch: defaultBranchRef {\n name\n }\n stars: stargazerCount\n forks: forkCount\n created_at: createdAt\n last_activity_at: pushedAt\n languages (first: 5) { nodes {name} }\n issues_open: issues (first: 100 states: [OPEN]) {\n totalCount\n }\n issues_closed: issues (first: 100 states: [CLOSED]) {\n totalCount\n }\n organization: owner {\n login\n }\n repo_url: url\n }\n }\n \n }\n }\n }" -# `prepare_repos_table()` prepares repos table +# `get_all_repos()` prints proper message Code - gh_repos_by_code_table <- test_rest_github$prepare_repos_table(repos_list = test_mocker$ - use("gh_repos_by_code_tailored")) - Message - i Preparing repositories table... - -# `prepare_repos_table()` prepares minimum version of repos table - - Code - gh_repos_by_code_table_min <- test_rest_github$prepare_repos_table(repos_list = test_mocker$ - use("gh_repos_by_code_tailored_min"), output = "table_min") - Message - i Preparing repositories table... - -# `get_all_repos()` works as expected - - Code - gh_repos_table <- github_testhost_priv$get_all_repos() + gh_repos_table <- github_testhost_priv$get_all_repos(verbose = TRUE) Message i [Host:GitHub][Engine:GraphQl][Scope:test-org] Pulling repositories... -# `get_repos_contributors()` works on GitHost level - - Code - gh_repos_with_contributors <- github_testhost_priv$get_repos_contributors( - repos_table = test_mocker$use("gh_repos_table_with_platform"), verbose = TRUE, - progress = FALSE) - Message - i [Host:GitHub][Engine:REST] Pulling contributors... - diff --git a/tests/testthat/_snaps/01-get_repos-GitLab.md b/tests/testthat/_snaps/01-get_repos-GitLab.md index b1db1759..632c8019 100644 --- a/tests/testthat/_snaps/01-get_repos-GitLab.md +++ b/tests/testthat/_snaps/01-get_repos-GitLab.md @@ -5,11 +5,3 @@ Output [1] "\n query GetReposByOrg($org: ID! $repo_cursor: String!) {\n group(fullPath: $org) {\n projects(first: 100 after: $repo_cursor) {\n \n count\n pageInfo {\n hasNextPage\n endCursor\n }\n edges {\n node {\n repo_id: id\n repo_name: name\n repo_path: path\n ... on Project {\n repository {\n rootRef\n }\n }\n stars: starCount\n forks: forksCount\n created_at: createdAt\n last_activity_at: lastActivityAt\n languages {\n name\n }\n issues: issueStatusCounts {\n all\n closed\n opened\n }\n namespace {\n path\n }\n repo_url: webUrl\n }\n }\n }\n }\n }" -# REST client prepares table from GitLab repositories response - - Code - gl_repos_by_code_table <- test_rest_gitlab$prepare_repos_table(repos_list = test_mocker$ - use("gl_repos_by_code_tailored")) - Message - i Preparing repositories table... - diff --git a/tests/testthat/_snaps/01-get_repos-GitStats.md b/tests/testthat/_snaps/01-get_repos-GitStats.md deleted file mode 100644 index a9bca13f..00000000 --- a/tests/testthat/_snaps/01-get_repos-GitStats.md +++ /dev/null @@ -1,8 +0,0 @@ -# get_repos works properly and for the second time uses cache - - Code - repos_table <- test_gitstats$get_repos() - Message - ! Retrieving repositories from the GitStats storage. - i If you wish to pull the data from API once more, set `cache` parameter to `FALSE`. - diff --git a/tests/testthat/_snaps/get_commits-GitLab.md b/tests/testthat/_snaps/get_commits-GitLab.md deleted file mode 100644 index 439f03b4..00000000 --- a/tests/testthat/_snaps/get_commits-GitLab.md +++ /dev/null @@ -1,8 +0,0 @@ -# `get_commits_authors_handles_and_names()` adds author logis and names to commits table - - Code - gl_commits_table <- test_rest_gitlab$get_commits_authors_handles_and_names( - commits_table = test_mocker$use("gl_commits_table"), verbose = TRUE) - Message - i Looking up for authors' names and logins... - diff --git a/tests/testthat/_snaps/get_commits-GitStats.md b/tests/testthat/_snaps/get_commits-GitStats.md new file mode 100644 index 00000000..0963c7f0 --- /dev/null +++ b/tests/testthat/_snaps/get_commits-GitStats.md @@ -0,0 +1,9 @@ +# get_commits() returns error when since is not defined + + You need to pass date to `since` parameter. + +# get_commits_stats returns error when no commits + + x No commits found in GitStats storage. + i Run first `get_commits()`. + diff --git a/tests/testthat/_snaps/get_files_content-GitLab.md b/tests/testthat/_snaps/get_files_content-GitLab.md index 076446d5..f7b8d5dd 100644 --- a/tests/testthat/_snaps/get_files_content-GitLab.md +++ b/tests/testthat/_snaps/get_files_content-GitLab.md @@ -12,13 +12,3 @@ Output [1] "\n query GetFilesByRepo($fullPath: ID!, $file_paths: [String!]!) {\n project(fullPath: $fullPath) {\n name\n id\n webUrl\n repository {\n blobs(paths: $file_paths) {\n nodes {\n name\n rawBlob\n size\n }\n }\n }\n }\n }\n " -# Gitlab GraphQL switches to pulling files per repositories when query is too complex - - Code - gitlab_files_response_by_repos <- test_graphql_gitlab$get_files_from_org(org = "mbtests", - type = "organization", repos = NULL, file_paths = c("DESCRIPTION", - "project_metadata.yaml", "README.md"), host_files_structure = NULL, - only_text_files = TRUE, verbose = TRUE, progress = FALSE) - Message - i I will switch to pulling files per repository. - diff --git a/tests/testthat/_snaps/get_files_structure-GitLab.md b/tests/testthat/_snaps/get_files_structure-GitLab.md index 5fdb0493..342d0ead 100644 --- a/tests/testthat/_snaps/get_files_structure-GitLab.md +++ b/tests/testthat/_snaps/get_files_structure-GitLab.md @@ -5,15 +5,6 @@ Output [1] "\n query GetFilesTree ($fullPath: ID!, $file_path: String!) {\n project(fullPath: $fullPath) {\n repository {\n tree(path: $file_path) {\n trees (first: 100) {\n pageInfo{\n endCursor\n hasNextPage\n }\n nodes {\n name\n }\n }\n blobs (first: 100) {\n pageInfo{\n endCursor\n hasNextPage\n }\n nodes {\n name\n }\n }\n }\n }\n }\n }\n " -# get_files_structure_from_orgs pulls files structure for repositories in orgs - - Code - gl_files_structure_from_orgs <- gitlab_testhost_priv$ - get_files_structure_from_orgs(pattern = "\\.md", depth = 1L, verbose = TRUE, - progress = FALSE) - Message - i [Host:GitLab][Engine:GraphQl][Scope:mbtests] Pulling files structure...[files matching pattern: '\.md']... - # get_files_content makes use of files_structure Code diff --git a/tests/testthat/_snaps/get_files_structure-GitStats.md b/tests/testthat/_snaps/get_files_structure-GitStats.md index 1f0e3190..a3cf4497 100644 --- a/tests/testthat/_snaps/get_files_structure-GitStats.md +++ b/tests/testthat/_snaps/get_files_structure-GitStats.md @@ -7,9 +7,3 @@ ! No files structure found for matching pattern \.png in 1 level of dirs. ! Files structure will not be saved in GitStats. -# get_files_structure works as expected - - Code - files_structure <- test_gitstats$get_files_structure(pattern = "\\.md", depth = 2L, - verbose = TRUE) - diff --git a/tests/testthat/_snaps/get_release-GitHub.md b/tests/testthat/_snaps/get_release-GitHub.md index 116312b0..a46f4267 100644 --- a/tests/testthat/_snaps/get_release-GitHub.md +++ b/tests/testthat/_snaps/get_release-GitHub.md @@ -5,3 +5,11 @@ Output [1] "query GetReleasesFromRepo ($org: String!, $repo: String!) {\n repository(owner:$org, name:$repo){\n name\n url\n releases (last: 100) {\n nodes {\n name\n tagName\n publishedAt\n url\n description\n }\n }\n }\n }" +# `get_release_logs()` prints proper message when running + + Code + releases_table <- github_testhost$get_release_logs(since = "2023-05-01", until = "2023-09-30", + verbose = TRUE, progress = FALSE) + Message + i [Host:GitHub][Engine:GraphQl][Scope:test-org] Pulling release logs... + diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 0b13ecd4..9704d42a 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-01-get_repos-GitHub.R b/tests/testthat/test-01-get_repos-GitHub.R index 6111ee36..3e1ccb48 100644 --- a/tests/testthat/test-01-get_repos-GitHub.R +++ b/tests/testthat/test-01-get_repos-GitHub.R @@ -226,10 +226,9 @@ test_that("GitHub tailors `repos_list` to minimal version of table", { }) test_that("`prepare_repos_table()` prepares repos table", { - expect_snapshot( - gh_repos_by_code_table <- test_rest_github$prepare_repos_table( - repos_list = test_mocker$use("gh_repos_by_code_tailored") - ) + gh_repos_by_code_table <- test_rest_github$prepare_repos_table( + repos_list = test_mocker$use("gh_repos_by_code_tailored"), + verbose = FALSE ) expect_repos_table( gh_repos_by_code_table @@ -238,11 +237,10 @@ test_that("`prepare_repos_table()` prepares repos table", { }) test_that("`prepare_repos_table()` prepares minimum version of repos table", { - expect_snapshot( - gh_repos_by_code_table_min <- test_rest_github$prepare_repos_table( - repos_list = test_mocker$use("gh_repos_by_code_tailored_min"), - output = "table_min" - ) + gh_repos_by_code_table_min <- test_rest_github$prepare_repos_table( + repos_list = test_mocker$use("gh_repos_by_code_tailored_min"), + output = "table_min", + verbose = FALSE ) expect_repos_table( gh_repos_by_code_table_min, @@ -399,8 +397,8 @@ test_that("`get_all_repos()` works as expected", { "graphql_engine$prepare_repos_table", test_mocker$use("gh_repos_table") ) - expect_snapshot( - gh_repos_table <- github_testhost_priv$get_all_repos() + gh_repos_table <- github_testhost_priv$get_all_repos( + verbose = FALSE ) expect_repos_table( gh_repos_table @@ -408,6 +406,19 @@ test_that("`get_all_repos()` works as expected", { test_mocker$cache(gh_repos_table) }) +test_that("`get_all_repos()` prints proper message", { + mockery::stub( + github_testhost_priv$get_all_repos, + "graphql_engine$prepare_repos_table", + test_mocker$use("gh_repos_table") + ) + expect_snapshot( + gh_repos_table <- github_testhost_priv$get_all_repos( + verbose = TRUE + ) + ) +}) + test_that("GitHost adds `repo_api_url` column to GitHub repos table", { repos_table <- test_mocker$use("gh_repos_table") gh_repos_table_with_api_url <- github_testhost_priv$add_repo_api_url(repos_table) @@ -469,12 +480,10 @@ test_that("`get_repos_contributors()` works on GitHost level", { "rest_engine$get_repos_contributors", test_mocker$use("gh_repos_with_contributors") ) - expect_snapshot( - gh_repos_with_contributors <- github_testhost_priv$get_repos_contributors( - repos_table = test_mocker$use("gh_repos_table_with_platform"), - verbose = TRUE, - progress = FALSE - ) + gh_repos_with_contributors <- github_testhost_priv$get_repos_contributors( + repos_table = test_mocker$use("gh_repos_table_with_platform"), + verbose = FALSE, + progress = FALSE ) expect_repos_table( gh_repos_with_contributors, diff --git a/tests/testthat/test-01-get_repos-GitLab.R b/tests/testthat/test-01-get_repos-GitLab.R index 751455f6..fffd5153 100644 --- a/tests/testthat/test-01-get_repos-GitLab.R +++ b/tests/testthat/test-01-get_repos-GitLab.R @@ -189,10 +189,9 @@ test_that("`tailor_repos_response()` tailors precisely `repos_list`", { }) test_that("REST client prepares table from GitLab repositories response", { - expect_snapshot( - gl_repos_by_code_table <- test_rest_gitlab$prepare_repos_table( - repos_list = test_mocker$use("gl_repos_by_code_tailored") - ) + gl_repos_by_code_table <- test_rest_gitlab$prepare_repos_table( + repos_list = test_mocker$use("gl_repos_by_code_tailored"), + verbose = FALSE ) expect_repos_table( gl_repos_by_code_table diff --git a/tests/testthat/test-01-get_repos-GitStats.R b/tests/testthat/test-01-get_repos-GitStats.R index 6f581d96..90bcdd6f 100644 --- a/tests/testthat/test-01-get_repos-GitStats.R +++ b/tests/testthat/test-01-get_repos-GitStats.R @@ -72,8 +72,8 @@ test_that("get_repos works properly and for the second time uses cache", { repos_object = repos_table, with_cols = c("contributors", "contributors_n") ) - expect_snapshot( - repos_table <- test_gitstats$get_repos() + repos_table <- test_gitstats$get_repos( + verbose = FALSE ) expect_repos_table_object( repos_object = repos_table, diff --git a/tests/testthat/test-get_commits-GitLab.R b/tests/testthat/test-get_commits-GitLab.R index d75360e0..bfca6d1d 100644 --- a/tests/testthat/test-get_commits-GitLab.R +++ b/tests/testthat/test-get_commits-GitLab.R @@ -61,11 +61,9 @@ test_that("`get_commits_authors_handles_and_names()` adds author logis and names "private$get_authors_dict", test_mocker$use("authors_dict") ) - expect_snapshot( - gl_commits_table <- test_rest_gitlab$get_commits_authors_handles_and_names( - commits_table = test_mocker$use("gl_commits_table"), - verbose = TRUE - ) + gl_commits_table <- test_rest_gitlab$get_commits_authors_handles_and_names( + commits_table = test_mocker$use("gl_commits_table"), + verbose = FALSE ) expect_commits_table( gl_commits_table, diff --git a/tests/testthat/test-get_commits-GitStats.R b/tests/testthat/test-get_commits-GitStats.R index aa23335f..c82e2d8d 100644 --- a/tests/testthat/test-get_commits-GitStats.R +++ b/tests/testthat/test-get_commits-GitStats.R @@ -42,11 +42,50 @@ test_that("get_commits works properly", { test_mocker$cache(commits_table) }) +test_that("get_commits() works", { + mockery::stub( + get_commits, + "gitstats_object$get_commits", + test_mocker$use("commits_table") + ) + commits_table <- get_commits( + test_gitstats, + since = "2023-06-15", + until = "2023-06-30", + verbose = FALSE + ) + expect_s3_class( + commits_table, + "commits_data" + ) +}) + +test_that("get_commits() returns error when since is not defined", { + mockery::stub( + get_commits, + "gitstats_object$get_commits", + test_mocker$use("commits_table") + ) + expect_snapshot_error( + get_commits( + test_gitstats, + verbose = FALSE + ) + ) +}) + test_gitstats <- create_test_gitstats( hosts = 2, inject_commits = "commits_table" ) +test_that("get_commits_stats returns error when no commits", { + test_gitstats <- create_test_gitstats() + expect_snapshot_error( + get_commits_stats(test_gitstats) + ) +}) + test_that("get_commits_stats prepares table with statistics on commits", { commits_stats <- get_commits_stats(test_gitstats) expect_s3_class(commits_stats, "commits_stats") diff --git a/tests/testthat/test-get_files_content-GitLab.R b/tests/testthat/test-get_files_content-GitLab.R index 45e40f38..1c84606a 100644 --- a/tests/testthat/test-get_files_content-GitLab.R +++ b/tests/testthat/test-get_files_content-GitLab.R @@ -111,17 +111,15 @@ test_that("Gitlab GraphQL switches to pulling files per repositories when query "private$is_complexity_error", TRUE ) - expect_snapshot( - gitlab_files_response_by_repos <- test_graphql_gitlab$get_files_from_org( - org = "mbtests", - type = "organization", - repos = NULL, - file_paths = c("DESCRIPTION", "project_metadata.yaml", "README.md"), - host_files_structure = NULL, - only_text_files = TRUE, - verbose = TRUE, - progress = FALSE - ) + gitlab_files_response_by_repos <- test_graphql_gitlab$get_files_from_org( + org = "mbtests", + type = "organization", + repos = NULL, + file_paths = c("DESCRIPTION", "project_metadata.yaml", "README.md"), + host_files_structure = NULL, + only_text_files = TRUE, + verbose = FALSE, + progress = FALSE ) expect_gitlab_files_from_org_by_repos_response( response = gitlab_files_response_by_repos, diff --git a/tests/testthat/test-get_files_structure-GitLab.R b/tests/testthat/test-get_files_structure-GitLab.R index 5898ec98..e2bf6450 100644 --- a/tests/testthat/test-get_files_structure-GitLab.R +++ b/tests/testthat/test-get_files_structure-GitLab.R @@ -174,13 +174,11 @@ test_that("get_files_structure_from_orgs pulls files structure for repositories "graphql_engine$get_files_structure_from_org", test_mocker$use("gl_files_structure_shallow") ) - expect_snapshot( - gl_files_structure_from_orgs <- gitlab_testhost_priv$get_files_structure_from_orgs( - pattern = "\\.md", - depth = 1L, - verbose = TRUE, - progress = FALSE - ) + gl_files_structure_from_orgs <- gitlab_testhost_priv$get_files_structure_from_orgs( + pattern = "\\.md", + depth = 1L, + verbose = FALSE, + progress = FALSE ) expect_equal( names(gl_files_structure_from_orgs), diff --git a/tests/testthat/test-get_files_structure-GitStats.R b/tests/testthat/test-get_files_structure-GitStats.R index eff6fb16..280f5873 100644 --- a/tests/testthat/test-get_files_structure-GitStats.R +++ b/tests/testthat/test-get_files_structure-GitStats.R @@ -37,12 +37,10 @@ test_that("get_files_structure works as expected", { "private$get_files_structure_from_hosts", test_mocker$use("files_structure_from_hosts") ) - expect_snapshot( - files_structure <- test_gitstats$get_files_structure( - pattern = "\\.md", - depth = 2L, - verbose = TRUE - ) + files_structure <- test_gitstats$get_files_structure( + pattern = "\\.md", + depth = 2L, + verbose = FALSE ) expect_s3_class(files_structure, "files_structure") test_mocker$cache(files_structure) diff --git a/tests/testthat/test-get_release-GitHub.R b/tests/testthat/test-get_release-GitHub.R index 3c93c179..60a0e56b 100644 --- a/tests/testthat/test-get_release-GitHub.R +++ b/tests/testthat/test-get_release-GitHub.R @@ -67,3 +67,24 @@ test_that("`get_release_logs()` pulls release logs in the table format", { expect_lt(max(releases_table$published_at), as.POSIXct("2023-09-30")) test_mocker$cache(releases_table) }) + +test_that("`get_release_logs()` prints proper message when running", { + mockery::stub( + github_testhost$get_release_logs, + "graphql_engine$prepare_releases_table", + test_mocker$use("releases_table") + ) + mockery::stub( + github_testhost$get_release_logs, + "private$set_repositories", + test_mocker$use("repos_names") + ) + expect_snapshot( + releases_table <- github_testhost$get_release_logs( + since = "2023-05-01", + until = "2023-09-30", + verbose = TRUE, + progress = FALSE + ) + ) +}) diff --git a/tests/testthat/test-helpers.R b/tests/testthat/test-helpers.R index 34c498bb..86b4a349 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/tests/testthat/test-z-GitStats.R b/tests/testthat/test-z-GitStats.R index 31df2b45..cff3110b 100644 --- a/tests/testthat/test-z-GitStats.R +++ b/tests/testthat/test-z-GitStats.R @@ -14,6 +14,7 @@ test_that("GitStats prints the proper info when connections are added.", { }) test_that("GitStats prints the proper info when repos are passed instead of orgs.", { + skip_on_cran() suppressMessages( test_gitstats <- create_gitstats() %>% set_github_host( @@ -107,15 +108,15 @@ test_that("show_orgs print orgs properly", { ) }) -suppressMessages( - test_gitstats <- create_gitstats() %>% - set_gitlab_host( - token = Sys.getenv("GITLAB_PAT_PUBLIC"), - orgs = "mbtests/subgroup" - ) -) - test_that("show_orgs print subgroups properly", { + skip_on_cran() + suppressMessages( + test_gitstats <- create_gitstats() %>% + set_gitlab_host( + token = Sys.getenv("GITLAB_PAT_PUBLIC"), + orgs = "mbtests/subgroup" + ) + ) expect_equal( test_gitstats$show_orgs(), "mbtests/subgroup" @@ -123,6 +124,14 @@ test_that("show_orgs print subgroups properly", { }) test_that("subgroups are cleanly printed in GitStats", { + skip_on_cran() + suppressMessages( + test_gitstats <- create_gitstats() %>% + set_gitlab_host( + token = Sys.getenv("GITLAB_PAT_PUBLIC"), + orgs = "mbtests/subgroup" + ) + ) expect_snapshot( test_gitstats ) diff --git a/vignettes/set_hosts.Rmd b/vignettes/set_hosts.Rmd index 976b7dc4..74734a71 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"),