-
Notifications
You must be signed in to change notification settings - Fork 3
feat: runtime version scanner: adopt content search #280
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
6f23b5a
reorganize files
toph-allen 2d8cf96
update github action
toph-allen f4f3ed2
adopt search_content in runtime version scanner
toph-allen 063b21a
format
toph-allen b95ca0e
migrate to connectapi’s built-in get_usage
toph-allen 8ecda42
adopt search_content in runtime version scanner
toph-allen b1b0cad
format
toph-allen 65c2a9d
Merge branch 'toph/rvs-use-search-content' of https://github.com/posi…
toph-allen 360c58c
Update extensions/runtime-version-scanner/.Rbuildignore
toph-allen 00cb27e
Update extensions/runtime-version-scanner/DESCRIPTION
toph-allen 7054cc4
Merge branch 'main' into toph/rvs-organize-like-r-package
toph-allen 3809dac
Merge remote-tracking branch 'refs/remotes/origin/toph/rvs-organize-l…
toph-allen 1fcc615
Update DESCRIPTION
toph-allen 9c321c4
Merge branch 'toph/rvs-organize-like-r-package' into toph/rvs-use-sea…
toph-allen 14ce3b4
Merge branch 'main' into toph/rvs-use-search-content
toph-allen 5d258fb
update support for search_content()
toph-allen 9348011
Update extensions/runtime-version-scanner/R/fetch_content.R
toph-allen c4d2f5b
extract app mdoe groups into function
toph-allen 995db43
Merge branch 'toph/rvs-use-search-content' of https://github.com/posi…
toph-allen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| library(connectapi) | ||
|
|
||
| fetch_content <- function(client, content_type_filter = NULL) { | ||
| owner <- "owner:@me" | ||
| type <- type_query(content_type_filter) | ||
|
|
||
| parts <- Filter(nzchar, c(owner, type)) | ||
| query <- paste(parts, collapse = " ") | ||
|
|
||
| search_content(client, q = query, include = "owner") | ||
| } | ||
|
|
||
| type_query <- function(content_types) { | ||
| if (length(content_types) == 0 || is.null(content_types)) { | ||
| return(character(0)) | ||
| } | ||
| app_mode_groups <- list( | ||
| "API" = c("api", "python-fastapi", "python-api", "tensorflow-saved-model"), | ||
| "Application" = c( | ||
| "shiny", | ||
| "python-shiny", | ||
| "python-dash", | ||
| "python-gradio", | ||
| "python-streamlit", | ||
| "python-bokeh" | ||
| ), | ||
| "Jupyter" = c("jupyter-static", "jupyter-voila"), | ||
| "Quarto" = c("quarto-shiny", "quarto-static"), | ||
| "R Markdown" = c("rmd-shiny", "rmd-static"), | ||
| "Pin" = c("pin"), | ||
| "Other" = c("unknown") | ||
| ) | ||
toph-allen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| app_modes <- paste(unlist(app_mode_groups[content_types]), collapse = ",") | ||
| if (!nzchar(app_modes)) { | ||
| return(character(0)) | ||
| } | ||
| paste0("type:", app_modes) | ||
| } | ||
|
|
||
| content_list_to_data_frame <- function(content_list) { | ||
| connectapi:::parse_connectapi_typed( | ||
| content_list, | ||
| connectapi:::connectapi_ptypes$content | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -415,40 +415,41 @@ | |
| } | ||
| }, | ||
| "connectapi": { | ||
| "Source": "CRAN", | ||
| "Repository": "https://packagemanager.posit.co/cran/latest", | ||
| "Source": "github", | ||
| "Repository": null, | ||
| "description": { | ||
| "Type": "Package", | ||
| "Package": "connectapi", | ||
| "Title": "Utilities for Interacting with the 'Posit Connect' Server API", | ||
| "Version": "0.8.0", | ||
| "Version": "0.8.0.9000", | ||
| "Authors@R": "c(\n person(given = \"Toph\",\n family = \"Allen\",\n role = c(\"aut\", \"cre\"),\n email = \"[email protected]\"),\n person(given = \"Neal\",\n family = \"Richardson\",\n role = c(\"aut\")),\n person(given = \"Sean\",\n family = \"Lopp\",\n role = c(\"aut\")),\n person(given = \"Cole\",\n family = \"Arendt\",\n role = c(\"aut\")),\n person(given = \"Posit, PBC\",\n role = c(\"cph\", \"fnd\")))", | ||
| "Description": "Provides a helpful 'R6' class and methods for interacting with\n the 'Posit Connect' Server API along with some meaningful utility functions\n for regular tasks. API documentation varies by 'Posit Connect' installation\n and version, but the latest documentation is also hosted publicly at\n <https://docs.posit.co/connect/api/>.", | ||
| "License": "MIT + file LICENSE", | ||
| "URL": "https://posit-dev.github.io/connectapi/,\nhttps://github.com/posit-dev/connectapi", | ||
| "URL": "https://posit-dev.github.io/connectapi/, https://github.com/posit-dev/connectapi", | ||
| "BugReports": "https://github.com/posit-dev/connectapi/issues", | ||
| "Imports": "bit64, fs, glue, httr, mime, jsonlite, lifecycle, magrittr,\npurrr, R6, rlang (>= 0.4.2), tibble, uuid, vctrs (>= 0.3.0),\nbase64enc", | ||
| "Suggests": "covr, dbplyr, dplyr, ggplot2, gridExtra, httptest, knitr,\nlubridate, progress, rmarkdown, rprojroot, rsconnect, spelling,\ntestthat, tidyr, webshot2, withr", | ||
| "Imports": "bit64,\nfs,\nglue,\nhttr,\nmime,\njsonlite,\nlifecycle,\nmagrittr,\npurrr,\nR6,\nrlang (>= 0.4.2),\ntibble,\nuuid,\nvctrs (>= 0.3.0),\nbase64enc", | ||
| "Suggests": "covr,\ndbplyr,\ndplyr,\nggplot2,\ngridExtra,\nhttptest,\nknitr,\nlubridate,\nprogress,\nrmarkdown,\nrprojroot,\nrsconnect,\nspelling,\ntestthat,\ntidyr,\nwebshot2,\nwithr", | ||
| "VignetteBuilder": "knitr", | ||
| "Encoding": "UTF-8", | ||
| "Language": "en-US", | ||
| "RoxygenNote": "7.3.2", | ||
| "Roxygen": "list(markdown = TRUE)", | ||
| "Config/testthat/edition": "3", | ||
| "Collate": "'audits.R' 'browse.R' 'connect.R' 'connectapi-package.R'\n'connectapi.R' 'content.R' 'deploy.R' 'get.R' 'git.R'\n'groups.R' 'integrations.R' 'lazy.R' 'page.R' 'parse.R'\n'promote.R' 'ptype.R' 'remote.R' 'runtime-caches.R'\n'schedule.R' 'tags.R' 'utils.R' 'thumbnail.R' 'user.R'\n'utils-ci.R' 'utils-pipe.R' 'variant.R'", | ||
| "NeedsCompilation": "no", | ||
| "Packaged": "2025-07-30 21:46:47 UTC; toph", | ||
| "Collate": "'audits.R'\n'browse.R'\n'connect.R'\n'connectapi-package.R'\n'connectapi.R'\n'content.R'\n'deploy.R'\n'get.R'\n'git.R'\n'groups.R'\n'integrations.R'\n'lazy.R'\n'page.R'\n'parse.R'\n'promote.R'\n'ptype.R'\n'remote.R'\n'runtime-caches.R'\n'schedule.R'\n'tags.R'\n'utils.R'\n'thumbnail.R'\n'user.R'\n'utils-ci.R'\n'utils-pipe.R'\n'variant.R'", | ||
| "Author": "Toph Allen [aut, cre],\n Neal Richardson [aut],\n Sean Lopp [aut],\n Cole Arendt [aut],\n Posit, PBC [cph, fnd]", | ||
| "Maintainer": "Toph Allen <[email protected]>", | ||
| "Repository": "RSPM", | ||
| "Date/Publication": "2025-07-30 22:00:11 UTC", | ||
| "Built": "R 4.3.0; ; 2025-07-31 10:36:47 UTC; unix", | ||
| "RemoteType": "standard", | ||
| "RemoteRef": "connectapi", | ||
| "RemotePkgRef": "connectapi", | ||
| "RemoteRepos": "https://packagemanager.posit.co/cran/latest", | ||
| "RemoteReposName": "CRAN", | ||
| "RemotePkgPlatform": "aarch64-apple-darwin20", | ||
| "RemoteSha": "0.8.0" | ||
| "Built": "R 4.3.3; ; 2025-10-08 18:39:18 UTC; unix", | ||
| "RemoteType": "github", | ||
| "RemoteHost": "api.github.com", | ||
| "RemoteUsername": "posit-dev", | ||
| "RemoteRepo": "connectapi", | ||
| "RemoteRef": "main", | ||
| "RemoteSha": "dc55d835d1b90c9dd5dba48d0951b8ae682e857a", | ||
| "GithubHost": "api.github.com", | ||
| "GithubRepo": "connectapi", | ||
| "GithubUsername": "posit-dev", | ||
| "GithubRef": "main", | ||
| "GithubSHA1": "dc55d835d1b90c9dd5dba48d0951b8ae682e857a" | ||
| } | ||
| }, | ||
| "cpp11": { | ||
|
|
@@ -2624,19 +2625,22 @@ | |
| }, | ||
| "files": { | ||
| "app.R": { | ||
| "checksum": "7960398b11756a0ace37e183f84b7a9f" | ||
| "checksum": "8a431830398cb8960e4790641032e491" | ||
| }, | ||
| "R/connect_module.R": { | ||
| "checksum": "469dbae2ebdf431cad52f0ed98793366" | ||
| }, | ||
| "R/fetch_content.R": { | ||
| "checksum": "3a22ff4a6498c6ad6c035141bfa27eae" | ||
| }, | ||
| "R/supported_versions.R": { | ||
| "checksum": "ca8c4181bddf00f8e7e0797671ae01c6" | ||
| }, | ||
| "R/version_ordering.R": { | ||
| "checksum": "dc05d91a7b8cf813f03f519b5ecb72dc" | ||
| }, | ||
| "renv.lock": { | ||
| "checksum": "4d741f52dfe275c669083e78147ea3f9" | ||
| "checksum": "d98fa015a15df805ee9ec47ea3277e7a" | ||
| }, | ||
| "www/styles.css": { | ||
| "checksum": "48340b42bcc9fbed7bdac0c216bb6964" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -385,8 +385,8 @@ | |
| }, | ||
| "connectapi": { | ||
| "Package": "connectapi", | ||
| "Version": "0.8.0", | ||
| "Source": "Repository", | ||
| "Version": "0.8.0.9000", | ||
| "Source": "GitHub", | ||
| "Type": "Package", | ||
| "Title": "Utilities for Interacting with the 'Posit Connect' Server API", | ||
| "Authors@R": "c( person(given = \"Toph\", family = \"Allen\", role = c(\"aut\", \"cre\"), email = \"[email protected]\"), person(given = \"Neal\", family = \"Richardson\", role = c(\"aut\")), person(given = \"Sean\", family = \"Lopp\", role = c(\"aut\")), person(given = \"Cole\", family = \"Arendt\", role = c(\"aut\")), person(given = \"Posit, PBC\", role = c(\"cph\", \"fnd\")))", | ||
|
|
@@ -434,12 +434,17 @@ | |
| "Encoding": "UTF-8", | ||
| "Language": "en-US", | ||
| "RoxygenNote": "7.3.2", | ||
| "Roxygen": "list(markdown = TRUE)", | ||
| "Config/testthat/edition": "3", | ||
| "Collate": "'audits.R' 'browse.R' 'connect.R' 'connectapi-package.R' 'connectapi.R' 'content.R' 'deploy.R' 'get.R' 'git.R' 'groups.R' 'integrations.R' 'lazy.R' 'page.R' 'parse.R' 'promote.R' 'ptype.R' 'remote.R' 'runtime-caches.R' 'schedule.R' 'tags.R' 'utils.R' 'thumbnail.R' 'user.R' 'utils-ci.R' 'utils-pipe.R' 'variant.R'", | ||
| "NeedsCompilation": "no", | ||
| "Author": "Toph Allen [aut, cre], Neal Richardson [aut], Sean Lopp [aut], Cole Arendt [aut], Posit, PBC [cph, fnd]", | ||
| "Maintainer": "Toph Allen <[email protected]>", | ||
| "Repository": "CRAN" | ||
| "RemoteType": "github", | ||
| "RemoteHost": "api.github.com", | ||
| "RemoteUsername": "posit-dev", | ||
| "RemoteRepo": "connectapi", | ||
| "RemoteRef": "main", | ||
| "RemoteSha": "dc55d835d1b90c9dd5dba48d0951b8ae682e857a" | ||
| }, | ||
| "cpp11": { | ||
| "Package": "cpp11", | ||
|
|
||
3 changes: 3 additions & 0 deletions
3
...runtime-version-scanner/tests/testthat/mocks/connect.example/__api__/server_settings.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "version": "2025.10.0" | ||
| } |
3 changes: 3 additions & 0 deletions
3
extensions/runtime-version-scanner/tests/testthat/mocks/connect.example/__ping__.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
|
|
||
| } |
48 changes: 48 additions & 0 deletions
48
extensions/runtime-version-scanner/tests/testthat/test_fetch_content.R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| with_mock_api({ | ||
| client <- Connect$new("https://connect.example", api_key = "fake") | ||
| client$version # To hydrate the version property | ||
|
|
||
| without_internet({ | ||
| test_that("fetch_content() with no type query makes expected request", { | ||
| expect_GET( | ||
| fetch_content(client), | ||
| "https://connect.example/__api__/v1/search/content?q=owner%3A%40me&page_number=1&page_size=500&include=owner" | ||
| ) | ||
| }) | ||
| test_that("fetch_content() with type query makes expected request", { | ||
| expect_GET( | ||
| fetch_content(client, content_type_filter = "Pin"), | ||
| "https://connect.example/__api__/v1/search/content?q=owner%3A%40me%20type%3Apin&page_number=1&page_size=500&include=owner" | ||
| ) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| test_that("type_query handles NULL, empty, and unknown inputs", { | ||
| expect_equal(type_query(NULL), character(0)) | ||
| expect_equal(type_query(character(0)), character(0)) | ||
| expect_equal(type_query("NonExistent"), character(0)) | ||
| }) | ||
|
|
||
| test_that("type_query returns correct queries for single content types", { | ||
| expect_equal( | ||
| type_query("API"), | ||
| "type:api,python-fastapi,python-api,tensorflow-saved-model" | ||
| ) | ||
| expect_equal( | ||
| type_query("Application"), | ||
| "type:shiny,python-shiny,python-dash,python-gradio,python-streamlit,python-bokeh" | ||
| ) | ||
| expect_equal(type_query("Jupyter"), "type:jupyter-static,jupyter-voila") | ||
| expect_equal(type_query("Quarto"), "type:quarto-shiny,quarto-static") | ||
| expect_equal(type_query("R Markdown"), "type:rmd-shiny,rmd-static") | ||
| expect_equal(type_query("Pin"), "type:pin") | ||
| expect_equal(type_query("Other"), "type:unknown") | ||
| }) | ||
|
|
||
| test_that("type_query handles multiple content types", { | ||
| result <- type_query(c("API", "Jupyter")) | ||
| expect_true(grepl("^type:", result)) | ||
| expect_true(grepl("api", result)) | ||
| expect_true(grepl("jupyter-static", result)) | ||
| }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.