[mirror] Opinionated R package quickstart
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Swapped to snapshots

VisruthSK 8f2dff7d 406bedf9

+137 -76
+22
tests/testthat/_snaps/workflow.md
··· 1 + # workflow step: create_package creates git-backed package skeleton 2 + 3 + Code 4 + sort(list.files(".", recursive = TRUE, all.files = TRUE, no.. = TRUE)) 5 + Output 6 + [1] ".Rbuildignore" 7 + [2] ".git/config" 8 + [3] ".git/hooks/pre-commit" 9 + [4] ".github/dependabot.yml" 10 + [5] ".github/workflows/check-standard.yaml" 11 + [6] ".github/workflows/format-suggest.yaml" 12 + [7] ".github/workflows/test-coverage.yaml" 13 + [8] ".vscode/extensions.json" 14 + [9] "AGENTS.md" 15 + [10] "DESCRIPTION" 16 + [11] "LICENSE.md" 17 + [12] "NEWS.md" 18 + [13] "README.md" 19 + [14] "air.toml" 20 + [15] "tests/jarl.toml" 21 + [16] "tests/testthat.R" 22 +
+2
tests/testthat/_snaps/workflow/workflow--Rbuildignore
··· 1 + README\.Rmd 2 + AGENTS.md
+2
tests/testthat/_snaps/workflow/workflow--git-config
··· 1 + [remote "origin"] 2 + url = git@github.com:example/demoPkg.git
+14
tests/testthat/_snaps/workflow/workflow--git-hooks-pre-commit
··· 1 + #!/usr/bin/env bash 2 + set -euo pipefail 3 + 4 + air format . --check || { 5 + air format . 6 + echo "Air reformatted files. Stage and recommit." >&2 7 + exit 1 8 + } 9 + 10 + jarl check . || { 11 + jarl check . --fix --allow-dirty || true 12 + echo "Jarl fixed issues. Stage and recommit." >&2 13 + exit 1 14 + }
+6
tests/testthat/_snaps/workflow/workflow--github-dependabot-yml
··· 1 + version: 2 2 + updates: 3 + - package-ecosystem: "github-actions" 4 + directory: "/" 5 + schedule: 6 + interval: "weekly"
+5
tests/testthat/_snaps/workflow/workflow--github-workflows-check-standard-yaml
··· 1 + name: check 2 + steps: 3 + - uses: actions/checkout@v6 4 + - uses: actions/upload-artifact@v6 5 + - uses: JamesIves/github-pages-deploy-action@v4
+3
tests/testthat/_snaps/workflow/workflow--github-workflows-format-suggest-yaml
··· 1 + name: format-suggest 2 + steps: 3 + - uses: actions/checkout@v6
+6
tests/testthat/_snaps/workflow/workflow--github-workflows-test-coverage-yaml
··· 1 + name: coverage 2 + permissions: 3 + contents: read 4 + id-token: write 5 + steps: 6 + - use_oidc: true
+6
tests/testthat/_snaps/workflow/workflow--vscode-extensions-json
··· 1 + { 2 + "recommendations": [ 3 + "Posit.air-vscode", 4 + "etiennebacher.jarl-vscode" 5 + ] 6 + }
+18
tests/testthat/_snaps/workflow/workflow-AGENTS-md
··· 1 + # General 2 + - Read DESCRIPTION, README 3 + - Red/green TDD 4 + 5 + # Personality 6 + Literal, direct, concise, high-signal, non-empathic. No hedging, both-sidesing, closing summaries, or offers. Only ask questions if functionally blocked. 7 + 8 + # R Dev Rules 9 + - No manual edits: `.Rd`, `NAMESPACE` 10 + - Use `devtools::document()`, `test()`, `check()` 11 + - Deps: prefer Base R or current closure. Permission required for new deps to make code better 12 + - Add deps via `usethis::use_import_from()` or `use_package()` 13 + - Completion Pipeline (ordered, all must pass): 14 + 1. `air format .` 15 + 2. `jarl check . --fix --allow-dirty` 16 + 3. `devtools::document()` 17 + 4. `devtools::check()` 18 + 5. Report `covr::package_coverage()`
+2
tests/testthat/_snaps/workflow/workflow-DESCRIPTION
··· 1 + Package: demoPkg 2 + Version: 0.0.0.9000
+1
tests/testthat/_snaps/workflow/workflow-LICENSE-md
··· 1 + MIT License
+1
tests/testthat/_snaps/workflow/workflow-NEWS-md
··· 1 + demoPkg 0.0.0.9000
+1
tests/testthat/_snaps/workflow/workflow-README-md
··· 1 + # demoPkg
+2
tests/testthat/_snaps/workflow/workflow-tests-jarl-toml
··· 1 + [lint] 2 + extend-select = ["TESTTHAT"]
+1
tests/testthat/_snaps/workflow/workflow-tests-testthat-R
··· 1 + testthat::test_check("demoPkg")
+45 -76
tests/testthat/test-workflow.R
··· 154 154 fs::path(fixture$pkg_path, ...) 155 155 } 156 156 157 + snapshot_workflow_files <- function(fixture, files) { 158 + for (f in files) { 159 + expect_true(file.exists(file_in_pkg(fixture, f)), info = f) 160 + expect_snapshot_file( 161 + file_in_pkg(fixture, f), 162 + compare = testthat::compare_file_text, 163 + name = paste0( 164 + "workflow-", 165 + gsub("[^A-Za-z0-9_-]", "-", f) 166 + ) 167 + ) 168 + } 169 + } 170 + 157 171 test_that("workflow step: create_package creates git-backed package skeleton", { 158 172 fixture <- run_workflow_fixture() 159 173 160 174 expect_true(isTRUE(fixture$github_private)) 161 - expect_true(file.exists(file_in_pkg(fixture, "DESCRIPTION"))) 162 - expect_true(file.exists(file_in_pkg(fixture, "LICENSE.md"))) 163 - expect_true(file.exists(file_in_pkg(fixture, ".git", "config"))) 164 175 expect_false(file.exists(file_in_pkg(fixture, "demoPkg.Rproj"))) 165 176 166 - rbuildignore <- readLines(file_in_pkg(fixture, ".Rbuildignore"), warn = FALSE) 167 - expect_false(any(grepl("\\.Rproj", rbuildignore))) 177 + old <- setwd(fixture$pkg_path) 178 + on.exit(setwd(old), add = TRUE) 179 + expect_snapshot(sort(list.files( 180 + ".", 181 + recursive = TRUE, 182 + all.files = TRUE, 183 + no.. = TRUE 184 + ))) 185 + 186 + snapshot_workflow_files( 187 + fixture, 188 + c("DESCRIPTION", "LICENSE.md", ".Rbuildignore", ".git/config") 189 + ) 168 190 }) 169 191 170 192 test_that("workflow step: pkg_setup creates core package files", { 171 193 fixture <- run_workflow_fixture() 172 194 173 - expected_core_files <- c( 174 - file_in_pkg(fixture, "README.md"), 175 - file_in_pkg(fixture, "NEWS.md"), 176 - file_in_pkg(fixture, "tests", "testthat.R") 195 + snapshot_workflow_files( 196 + fixture, 197 + c("README.md", "NEWS.md", "tests/testthat.R") 177 198 ) 178 - for (f in expected_core_files) { 179 - expect_true(file.exists(f), info = f) 180 - } 181 - 182 - news <- readLines(file_in_pkg(fixture, "NEWS.md"), warn = FALSE) 183 - expect_true(any(grepl("0.0.0.9000", news, fixed = TRUE))) 184 199 }) 185 200 186 201 test_that("workflow step: setup_gha writes and rewrites workflow files", { ··· 194 209 "https://github.com/visruthsk/bootstrapper/blob/main/.github/workflows/format-suggest.yaml" 195 210 ) 196 211 197 - check_standard <- readLines( 198 - file_in_pkg(fixture, ".github", "workflows", "check-standard.yaml"), 199 - warn = FALSE 212 + snapshot_workflow_files( 213 + fixture, 214 + c( 215 + ".github/workflows/check-standard.yaml", 216 + ".github/workflows/test-coverage.yaml", 217 + ".github/workflows/format-suggest.yaml" 218 + ) 200 219 ) 201 - expect_true(any(grepl("actions/checkout@v6", check_standard, fixed = TRUE))) 202 - expect_true(any(grepl( 203 - "actions/upload-artifact@v6", 204 - check_standard, 205 - fixed = TRUE 206 - ))) 207 - expect_true(any(grepl( 208 - "JamesIves/github-pages-deploy-action@v4", 209 - check_standard, 210 - fixed = TRUE 211 - ))) 212 - 213 - coverage <- readLines( 214 - file_in_pkg(fixture, ".github", "workflows", "test-coverage.yaml"), 215 - warn = FALSE 216 - ) 217 - expect_true(any(grepl("use_oidc: true", coverage, fixed = TRUE))) 218 - expect_true(any(grepl("id-token: write", coverage, fixed = TRUE))) 219 - expect_false(any(grepl("CODECOV_TOKEN", coverage, fixed = TRUE))) 220 220 }) 221 221 222 222 test_that("workflow step: setup templates are copied to expected locations", { 223 223 fixture <- run_workflow_fixture(setup_AGENTS = TRUE) 224 224 225 - expect_identical( 226 - readLines(file_in_pkg(fixture, ".github", "dependabot.yml"), warn = FALSE), 227 - readLines( 228 - fs::path_package("bootstrapper", "templates", "dependabot.yml"), 229 - warn = FALSE 230 - ) 231 - ) 232 - expect_identical( 233 - readLines(file_in_pkg(fixture, "AGENTS.md"), warn = FALSE), 234 - readLines( 235 - fs::path_package("bootstrapper", "templates", "AGENTS.md"), 236 - warn = FALSE 237 - ) 238 - ) 239 - expect_identical( 240 - readLines(file_in_pkg(fixture, "tests", "jarl.toml"), warn = FALSE), 241 - readLines( 242 - fs::path_package("bootstrapper", "templates", "jarl.toml"), 243 - warn = FALSE 244 - ) 245 - ) 246 - expect_identical( 247 - readLines(file_in_pkg(fixture, ".vscode", "extensions.json"), warn = FALSE), 248 - readLines( 249 - fs::path_package("bootstrapper", "templates", "extensions.json"), 250 - warn = FALSE 251 - ) 252 - ) 253 - expect_identical( 254 - readLines( 255 - file_in_pkg(fixture, ".git", "hooks", "pre-commit"), 256 - warn = FALSE 257 - ), 258 - readLines( 259 - fs::path_package("bootstrapper", "templates", "pre-commit"), 260 - warn = FALSE 225 + snapshot_workflow_files( 226 + fixture, 227 + c( 228 + ".github/dependabot.yml", 229 + "AGENTS.md", 230 + "tests/jarl.toml", 231 + ".vscode/extensions.json", 232 + ".git/hooks/pre-commit" 261 233 ) 262 234 ) 263 - 264 - rbuildignore <- readLines(file_in_pkg(fixture, ".Rbuildignore"), warn = FALSE) 265 - expect_true("AGENTS.md" %in% rbuildignore) 266 235 })