-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
117 lines (90 loc) · 2.98 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# audit.connect
<!-- badges: start -->
[![R-CMD-check](https://github.com/jumpingrivers/audit.connect/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jumpingrivers/audit.connect/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
This checks that a variety of applications can be deployed to a Posit Connect Server.
## Installation
To install the R package, run
```{r, eval = FALSE}
install.packages("audit.connect")
```
For python based deployment, the python package, `rsconnect-python` is required
```{bash, eval = FALSE}
pip install rsconnect-python
```
## Usage
Running the test is straightforward
```{r, eval = FALSE}
library("audit.connect")
check(server = "https://www.connect.server.name/",
token = "API_TOKEN")
```
Alternatively, you can set environmental variables, `CONNECT_SERVER` and `CONNECT_API_KEY` in your
`.Renviron` file.
## Connect Package Pollution
If you are running this package on a machine you normally use to deploy to Connect, then
this isn't an issue - you can skip the next part.
**If** you are using a machine where you are deploying to Connect for the
first time, then read one!
Connect package pollution occurs when
* we use package manager binaries, **and**
* the OS on Connect differs to the OS on the deployment machine.
If you aren't using binaries or the OS is the same, then you won't have any issue.
If you want to be sure, we can use {renv}
```{r, eval = FALSE}
# Ensure we don't use the existing renv cache
fs::dir_delete(renv::paths$cache())
# Use the slow installation method
renv::init(repo = "https://cloud.r-project.org/")
renv::install("remotes")
```
## Config file
Experimental. You can skip deployment tests, by setting the appropriate value in `config-uat.yml`.
This file can be auto-generated via
```{r, eval = FALSE}
create_config()
```
If a test is missing in the config, the default value is TRUE.
## Creating a test
Tests are R6 classes. To be automatically detected, the class name **must**
start with `check_`. If you copy/paste the following code into `R/example.R`,
when you run `check()`, the test is automatically detected and run.
Likewise, `create_config()`
``` r
#' @export
check_example = R6::R6Class(
"check_example",
inherit = uatBase::base_check,
# A function is passed to checker()
# This runs the test, detects errors, and logs the result
public = list(
#' @description Runs a UAT check
check = function(account = NULL) {
private$checker(example_test())
return(invisible(NULL))
}
),
# Multiple classes can have the same group.
# But context/short should be unique
private = list(
context = "Human description",
short = "config_variable",
group = "config_group"
)
)
example_test = function() {
return(TRUE)
}
```