Giter Club home page Giter Club logo

bcgovr's Introduction

bcgovr

img R-CMD-check License

Overview

An R package to automate set up and sharing of R projects in bcgov GitHub following bcgov guidelines.

All B.C. Government employees are responsible for determining whether bcgov R source code can be shared on bcgov GitHub and for following the BC-Policy-Framework-For-GitHub.

You will need to ensure that Git is installed on your computer. To add your project to bcgov GitHub users need to have a GitHub account and be a member of the bcgov GitHub organisation.

Features

Functions

create_bcgov_project() & create_bcgov_package() Create a newβ€”or populate an existingβ€”R project or R package with folders & files that encourage best practice in scientific computing and with files that ensure the project meets bcgov GitHub requirements.

use_bcgov_git() Initialise Git version control for an R project and add files that ensure the project meets bcgov GitHub requirements.

use_bcgov_github() Open a bcgov GitHub repository and synchronise with an existing local R project and add files that ensure the project meets bcgov GitHub requirements. use_bcgov_github() requires that your project already be a Git repository. Use use_bcgov_git() to initialise a Git repository.

create_from_bcgov_github() Clone a bcgov GitHub repository and add files that ensure the project meets bcgov GitHub requirements.

use_bcgov_req() Add files to a new or existing R project to meet bcgov GitHub requirements. You can also add the bcgov required files individually using use_bcgov_contributing(), use_bcgov_licence(), use_bcgov_readme(), use_bcgov_readme_rmd(), use_bcgov_code_of_conduct().

RStudio bcgovr Project & Package Templates

The create_bcgov_project() or create_bcgov_package() and use_bcgov_git functions can be used simultaneously through the bcgovr Project & Package templates in the RStudio New Project dialogue box. The dialogue box allows a user to create a new R project or package with the option to select and individualise the required bcgov GitHub files and initialise Git version control.

RStudio Addins

The bcgovr package installs a set of RStudio Addins:

  1. Insert the boiler-plate Apache 2.0 license header into the comments header of a source file (uses insert_bcgov_apache_header()).
  2. Insert the boiler-plate Creative Commons Attribution 4.0 International License header into the comments header of a source file (uses insert_bcgov_cc_header()).
  3. Insert a bcgov project lifecycle badge into an .Rmd or .md file to indicate the current state of a project (uses insert_bcgov_lifecycle_badge()).

Installation

You can install bcgovr directly from this GitHub repository. To do so, you will need the remotes package:

install.packages("remotes")

Next, install and load the bcgovr package using remotes::install_github():

remotes::install_github("bcgov/bcgovr")
library(bcgovr)

πŸŽ‰ The authors of bcgovr acknowledge and thank the authors of the usethis R packageβ€”bcgovr uses usethis a lot. And by a lot, we mean every bcgovr function uses usethis under the hood 🚘.

Usage

I WANT TO…

Create a new bcgov R project or package with a β€˜ready-to-go’ folder & file structure

Create and openβ€”or populateβ€”a local R project using bcgovr::create_bcgov_project(). Be sure to either specify your local directory using the path argument, or setwd("C:/my-new-project") before running create_bcgov_project(). The template bcgovr folders and files and required bcgov GitHub files will be created in the new directory. For using different project templates, see the Options section below. Type ?create_bcgov_project in the R console for help.

create_bcgov_project(path = "C:/my-new-project", coc_email = "[email protected]") 
C:/my-new-project
β”œβ”€β”€ 01_load.R
β”œβ”€β”€ 02_clean.R
β”œβ”€β”€ 03_analysis.R
β”œβ”€β”€ 04_output.R
β”œβ”€β”€ CODE_OF_CONDUCT.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ R
β”œβ”€β”€ README.Rmd
β”œβ”€β”€ data
β”œβ”€β”€ my-new-project.Rproj
β”œβ”€β”€ out
└── run_all.R

The create_bcgov_package() function is used the same way as create_bcgov_project() but will create all the folders & files to get started on creating an R package. Type ?create_bcgov_package in the R console for help. The R packages book by Hadley Wickham is a very useful resource if you are looking to create R packages.

create_bcgov_package(path = "C:/mynewrpackage", coc_email = "[email protected]") 
C:/mynewrpackage
β”œβ”€β”€ CODE_OF_CONDUCT.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ DESCRIPTION
β”œβ”€β”€ LICENSE
β”œβ”€β”€ NAMESPACE
β”œβ”€β”€ NEWS.md
β”œβ”€β”€ R
β”œβ”€β”€ README.Rmd
β”œβ”€β”€ man
β”œβ”€β”€ mynewrpackage.Rproj
└── vignettes
    └── mynewrpackage.Rmd

Users can also use the bcgovr Project & Package templates in the RStudio New Project dialogue box to create a new R project or package. The dialogue box provides the option to select and individualise the required bcgov GitHub files and initialise Git version control.


Initialise Git version control for my R project (without GitHub)

Put your local R project under version control by initialising a Git repository using use_bcgov_git()β€”this automatically completes staging and committing of the initial folders & files inside the project. The use_bcgov_git() function also ensures the project has the required bcgov GitHub files. Type ?use_bcgov_git in the R console for help.

use_bcgov_git(coc_email = "[email protected]") 

Open a bcgov GitHub repository and synchronise with my R project

Share your R project on bcgov GitHub using use_bcgov_github(). This requires that your project already be a Git repositoryβ€”use use_bcgov_git() to initialise a Git repository if necessary. The use_bcgov_github() function creates a repository on bcgov GitHub and adds and synchronises your local project with the newly created bcgov GitHub origin. The use_bcgov_github() function also ensures the project has the required bcgov GitHub files. Type ?use_bcgov_github in the R console for help.

use_bcgov_github(organisation = "bcgov", coc_email = "[email protected]") 

Clone and contribute to an existing bcgov GitHub repository

Create a new local Git repository with a project or repository cloned from bcgov GitHub using create_from_bcgov_github(). The create_from_bcgov_github() function also ensures the project has the required bcgov GitHub files. Type ?create_from_bcgov_github in the R console for help.

create_from_bcgov_github(repo = "bcgov/bcgovr", destdir = "C:/my_directory") 

Add all or some of the required bcgov GitHub files to my R project

Add the required bcgov GitHub filesβ€”a LICENCE, a README, a CODE OF CONDUCT and a CONTRIBUTING fileβ€”to any new or existing bcgov R project or package using use_bcgov_req(). Type ?use_bcgov_req in the R console for help.

You can use the licence, coc_email & rmarkdown arguments to change the default Apache 2.0 License, add your contact details to the Code of Conduct, or decline a README.Rmd fileβ€”maybe you only want a README.md for the project?

use_bcgov_req(licence = "cc-by", rmarkdown = FALSE, coc_email = "[email protected]")

You can also add the individual required files as needed using:

use_bcgov_licence()
use_bcgov_readme()
use_bcgov_contributing()
use_bcgov_code_of_conduct(coc_email = "[email protected]")

Insert a licence header into my source file

Need to add that Apache 2.0 or Creative Commons License header to a source file? Just click-click:

You can also use insert_bcgov_apache_header() or insert_bcgov_cc_header().


Insert a bcgov project lifecycle badge into my README file

Want to add a lifecycle badge to your README file to indicate the current state of the project? Just click-click-click-click:

You can also use insert_bcgov_lifecycle_badge("experimental"). Type ?insert_bcgov_lifecycle_badge in the R console for the list of badge options and other help.

Options

There are several options you can specify in your .Rprofile file to customise the default behaviour when using the create_bcgov_ and use_bcgov_ functions in bcgovr.

  • bcgovr.coc.email: Code of Conduct contact email address

  • bcgovr.dir.struct: Alternative project directory structure for create_bcgov_project(). This should be specified as a character vector of directory (i.e.Β folders) and file paths, relative to the root of the project. Directories should be identified by having a trailing forward-slash (e.g., "dir/").

    The default is: c("R/", "data/", "out/", "01_load.R", "02_clean.R", "03_analysis.R", "04_output.R", "internal.R", "run_all.R").

To make use of these options, there should be a section in your .Rprofile file that looks something like this:

if (interactive()) {
    options("bcgovr.coc.email" = "[email protected]")
    options("bcgovr.dir.struct" = c("doc/", "data/", "results/", "src/01_load.R", "src/02_clean.R",
            "src/03_analysis.R", "src/04_output.R", "src/run_all.R"))
}

The easiest way to edit your .Rprofile is to run usethis::edit_r_profile(). It will open up the file in RStudio for editing. Then save the file, restart R, and your settings will be saved.

Project Status

This package is relatively stable and available for general use.

Getting Help or Reporting an Issue

To report bugs/issues/feature requests, please file an Issue.

How to Contribute

If you would like to contribute to the package, please see our CONTRIBUTING guidelines.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

License

Copyright 2017 Province of British Columbia

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at 

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

This repository is maintained by Environmental Reporting BC. Click here for a complete list of our repositories on GitHub.

bcgovr's People

Contributors

ateucher avatar bonniejrobert avatar boshek avatar monkmanmh avatar repo-mountie[bot] avatar stephhazlitt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bcgovr's Issues

usethis::use_template fails when user chooses not to overwrite

If usethis::use_template() detects that a file it is trying to write already exists, it asks the user if it would like to overwrite it. If the user chooses yes, it proceeds, but if they choose no, it errors.

In many of the functions (eg., use_bcgov_req()) there are several consecutive calls to usethis::use_template()to add different files to the project. There are occasions when a user has some of the files in their project (e.g., a README), but not others (e.g., CODE_OF_CONDUCT). It would be nice if a user could choose to not overwrite a file, but have have the function execution continue onto writing the next one.

Options are:

  1. write a wrapper around usethis::use_template using tryCatch()
  2. Open a FR in usethis::use_template() to allow not overwriting without failure.

add use_gitattributes function

This would help correctly idenitify repos as R repos. All this function would do is add a .gitattributes file to the top-level of the repo with the following text:

* linguist-vendored
*.R linguist-vendored=false
*.Rmd linguist-vendored=false
*.Rdata linguist-vendored=false
*.rdb linguist-vendored=false       
*.rds linguist-vendored=false     
*.Rd linguist-vendored=false      
*.Rdx linguist-vendored=false      

Add project lifecycle badge

No Project Lifecycle Badge found in your readme!

Hello! I scanned your readme and could not find a project lifecycle badge. A project lifecycle badge will provide contributors to your project as well as other stakeholders (platform services, executive) insight into the lifecycle of your repository.

What is a Project Lifecycle Badge?

It is a simple image that neatly describes your project's stage in its lifecycle. More information can be found in the project lifecycle badges documentation.

What do I need to do?

I suggest you make a PR into your README.md and add a project lifecycle badge near the top where it is easy for your users to pick it up :). Once it is merged feel free to close this issue. I will not open up a new one :)

Change to usethis will require updates to bcgovr

Highlighting the fragile approach of relying on unexported functions, bcgovr will need to make some changes to accomodate an upcoming update of usethis. My initial survey indicates these internal functions have changed:

is_proj is now is_in_proj
bullet is not done_buller et al.

There may also be more substantive changes which will also require bcgovr code modifications.

It's Been a While Since This Repository has Been Updated

This issue is a kind reminder that your repository has been inactive for 181 days. Some repositories are maintained in accordance with business requirements that infrequently change thus appearing inactive, and some repositories are inactive because they are unmaintained.

To help differentiate products that are unmaintained from products that do not require frequent maintenance, repomountie will open an issue whenever a repository has not been updated in 180 days.

  • If this product is being actively maintained, please close this issue.
  • If this repository isn't being actively maintained anymore, please archive this repository. Also, for bonus points, please add a dormant or retired life cycle badge.

Thank you for your help ensuring effective governance of our open-source ecosystem!

README.Rmd vs README.md

In analysis_skeleton() and package_skeleton(), (and further down the stack in add_readme()), if the rmarkdown = TRUE, then both a README.md and README.Rmd are added to the directory - Is this necessary, or should just the .Rmd be added? @boshek @stephhazlitt

Use 'usethis' package

For functions likeadd_code_of_conduct, add_contributing etc., usethis likely has more robust implementations than we have - should import usethis when it hits CRAN.

Unable to use remote repository field in project/package template GUI Addin

The template box has to have a path field, which can't be blank. But if you want to clone from a repo then the repo ends up being inside the directory specified in path, but the project opens up in path, with the cloned repo inside that, so you end up with nested projects and a confused user.

This is baked into the way RStudio project templates work so there's no way around it that I can find.

Add project lifecycle badge

No Project Lifecycle Badge found in your readme!

Hello! I scanned your readme and could not find a project lifecycle badge. A project lifecycle badge will provide contributors to your project as well as other stakeholders (platform services, executive) insight into the lifecycle of your repository.

What is a Project Lifecycle Badge?

It is a simple image that neatly describes your project's stage in its lifecycle. More information can be found in the project lifecycle badges documentation.

What do I need to do?

I suggest you make a PR into your README.md and add a project lifecycle badge near the top where it is easy for your users to pick it up :). Once it is merged feel free to close this issue. I will not open up a new one :)

add compliance audit file

The bcgov github policies now require a compliance audit file; it would be handy to have a template accessible via {bcgovr}. Thanks!

warning when providing custom directory structure

I wanted to setup my own directory structure, specifically for shiny apps, and I get a warning about the length of nzchar(dir_struct)

dirs <-  c("app/", "app/app.R")

bcgovr::create_bcgov_project(path = "C:/testproject",
                             coc_email = "[email protected]",
                             dir_struct = dirs)
#> <U+2605> Setting up the testproject project
#> v Setting active project to 'C:/testproject'
#> v Creating 'R/'
#> v Writing a sentinel file '.here'
#> * Build robust paths within your project via `here::here()`
#> * Learn more at <https://here.r-lib.org>
#> v Setting active project to '<no active project>'
#> v Setting active project to 'C:/testproject'
#> v Writing 'README.Rmd'
#> v Writing 'CONTRIBUTING.md'
#> v Writing 'CODE_OF_CONDUCT.md'
#> v Writing 'LICENSE'
#> v Writing '.gitattributes'
#> Warning in if (!nzchar(dir_struct)) dir_struct <- character(0): the condition
#> has length > 1 and only the first element will be used
#> <U+2714> Creating new project
#> <U+2714> Populating with directory structure
#> <U+2714> Adding Apache boilerplate header to the top of 'C:\\testproject/app/app.R'
#> <U+2605> Your new project is created in C:/testproject

The issue is that nzchar does not return a single value:

dirs <-  c("app/", "app/app.R")
nzchar(dirs)
#> [1] TRUE TRUE

Wiki entry idea

Basic git vocabulary:
Leaving this here as a reminder.
Rather than another git tutorial this space could simply provide some easy to understand definitions of some git terms:

  • Commit
  • Stage
  • Push
  • Pull
  • Merge
  • Stash
  • Pull request
  • Repo
  • Branch

May be more helpful than antoehr tutorial as it gives readers some context when reading tutorials.

Add missing topics

TL;DR

Topics greatly improve the discoverability of repos; please add the short code from the table below to the topics of your repo so that ministries can use GitHub's search to find out what repos belong to them and other visitors can find useful content (and reuse it!).

Why Topic

In short order we'll add our 800th repo. This large number clearly demonstrates the success of using GitHub and our Open Source initiative. This huge success means its critical that we work to make our content as discoverable as possible; Through discoverability, we promote code reuse across a large decentralized organization like the Government of British Columbia as well as allow ministries to find the repos they own.

What to do

Below is a table of abbreviation a.k.a short codes for each ministry; they're the ones used in all @gov.bc.ca email addresses. Please add the short codes of the ministry or organization that "owns" this repo as a topic.

add a topic

That's in, you're done!!!

How to use

Once topics are added, you can use them in GitHub's search. For example, enter something like org:bcgov topic:citz to find all the repos that belong to Citizens' Services. You can refine this search by adding key words specific to a subject you're interested in. To learn more about searching through repos check out GitHub's doc on searching.

Pro Tip πŸ€“

  • If your org is not in the list below, or the table contains errors, please create an issue here.

  • While you're doing this, add additional topics that would help someone searching for "something". These can be the language used javascript or R; something like opendata or data for data only repos; or any other key words that are useful.

  • Add a meaningful description to your repo. This is hugely valuable to people looking through our repositories.

  • If your application is live, add the production URL.

Ministry Short Codes

Short Code Organization Name
AEST Advanced Education, Skills & Training
AGRI Agriculture
ALC Agriculture Land Commission
AG Attorney General
MCF Children & Family Development
CITZ Citizens' Services
DBC Destination BC
EMBC Emergency Management BC
EAO Environmental Assessment Office
EDUC Education
EMPR Energy, Mines & Petroleum Resources
ENV Environment & Climate Change Strategy
FIN Finance
FLNR Forests, Lands, Natural Resource Operations & Rural Development
HLTH Health
FLNR Indigenous Relations & Reconciliation
JEDC Jobs, Economic Development & Competitiveness
LBR Labour Policy & Legislation
LDB BC Liquor Distribution Branch
MMHA Mental Health & Addictions
MAH Municipal Affairs & Housing
BCPC Pension Corporation
PSA Public Safety & Solicitor General & Emergency B.C.
SDPR Social Development & Poverty Reduction
TCA Tourism, Arts & Culture
TRAN Transportation & Infrastructure

NOTE See an error or omission? Please create an issue here to get it remedied.

Add project lifecycle badge

No Project Lifecycle Badge found in your readme!

Hello! I scanned your readme and could not find a project lifecycle badge. A project lifecycle badge will provide contributors to your project as well as other stakeholders (platform services, executive) insight into the lifecycle of your repository.

What is a Project Lifecycle Badge?

It is a simple image that neatly describes your project's stage in its lifecycle. More information can be found in the project lifecycle badges documentation.

What do I need to do?

I suggest you make a PR into your README.md and add a project lifecycle badge near the top where it is easy for your users to pick it up :). Once it is merged feel free to close this issue. I will not open up a new one :)

create_bcgov_project not creating specified folders

This code:

bcgovr/R/create.R

Lines 63 to 66 in bfc55e8

if (is.null(dir_struct)) {
dir_struct <- file.path(normalizePath(path),
c("out/", "data/", "01_load.R", "02_clean.R",
"03_analysis.R", "04_output.R", "run_all.R"))

is creating files rather than folders for out and data.

These should be folders.

Session Info
Session info ---------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.0 (2018-04-23)
 system   x86_64, mingw32             
 ui       RStudio (1.2.688)           
 language (EN)                        
 collate  English_Canada.1252         
 tz       America/Los_Angeles         
 date     2018-06-07                  

Packages -------------------------------------------------------------------------------------------------------------------------------
 package   * version    date       source                       
 backports   1.1.2      2017-12-13 CRAN (R 3.5.0)               
 base      * 3.5.0      2018-04-23 local                        
 compiler    3.5.0      2018-04-23 local                        
 datasets  * 3.5.0      2018-04-23 local                        
 devtools  * 1.13.5     2018-02-18 CRAN (R 3.5.0)               
 digest      0.6.15     2018-01-28 CRAN (R 3.5.0)               
 graphics  * 3.5.0      2018-04-23 local                        
 grDevices * 3.5.0      2018-04-23 local                        
 lobstr    * 0.0.0.9000 2018-04-30 Github (r-lib/lobstr@75254f1)
 magrittr    1.5        2014-11-22 CRAN (R 3.5.0)               
 memoise     1.1.0      2017-04-21 CRAN (R 3.5.0)               
 methods   * 3.5.0      2018-04-23 local                        
 R6          2.2.2      2017-06-17 CRAN (R 3.5.0)               
 Rcpp        0.12.17    2018-05-18 CRAN (R 3.5.0)               
 rlang       0.2.1      2018-05-30 CRAN (R 3.5.0)               
 stats     * 3.5.0      2018-04-23 local                        
 testthat  * 2.0.0      2017-12-13 CRAN (R 3.5.0)               
 tools       3.5.0      2018-04-23 local                        
 usethis   * 1.3.0      2018-02-24 CRAN (R 3.5.0)               
 utils     * 3.5.0      2018-04-23 local                        
 withr       2.1.2      2018-03-15 CRAN (R 3.5.0) 

Add empty tmp etc folders to skeleton

analysis_skeleton makes a tmp folder that is then added to .gitignore, to hold intermediate objects. But if someone else pulls the code and runs it, it errors because the tmp folder doesn't exist.

So instead of having tmp be in the global .gitignore, add the tmp folder with a .gitignore file inside, that just contains:

*
!.gitignore

This will enable the folder to be committed, but not its contents.

Proper documentation for defunct `devex_badge()` function?

We decided to skip deprecation/defunct documentation for the changes in bcgovr functions, given that bcgovr functionality is fully interactive, or is intended to be. With test driving, I have realized that we have devex_badge() scripted in almost every EnvReportBC repo.

Given this, and that perhaps others have used this function in the same way, I suggest we add in either a defunct error message, or keep devex_badge() with a deprecation message to now use insert_bcgov_devex_badge()?

Warning message upon installation and package error message

  1. During the installation of the devel branch, there are several of the following warnings:
    RD warning: C:/Users/username/AppData/Local/Temp/RtmpELYh1H/remotes2d1428837be6/bcgov-bcgovr-5b3c598/man/use_bcgov_git.Rd:20: file link 'edit_r_profile' in package 'usethis' does not exist and so has been treated as a topic
    use_bcgov_gitattributes html
    use_bcgov_github html
    At the end of installation after DONE (bcgovr) it says In R CMD INSTALL.

  2. When using create_bcgov_package(), there is an error message that package roxygen2 is required. This package can be installed altogether with bcgovr so that the message does not appear later on?

It's Been a While Since This Repository has Been Updated

This issue is a kind reminder that your repository has been inactive for 180 days. Some repositories are maintained in accordance with business requirements that infrequently change thus appearing inactive, and some repositories are inactive because they are unmaintained.

To help differentiate products that are unmaintained from products that do not require frequent maintenance, repomountie will open an issue whenever a repository has not been updated in 180 days.

  • If this product is being actively maintained, please close this issue.
  • If this repository isn't being actively maintained anymore, please archive this repository. Also, for bonus points, please add a dormant or retired life cycle badge.

Thank you for your help ensuring effective governance of our open-source ecosystem!

Change default branch name?

This quoted line below assumes that the user has named their default branch on GitHub "master", which isn't always the case. Especially with the @repomountie bot guidelines on master and main branch naming (i.e. both are suggested choices). Perhaps choose one as the "default" but allow user to specify a different branch name with a keyword argument?

bcgovr/R/use.R

Line 208 in affe8ce

repo_clone_cmd <- paste0("git push -u origin master")

Note: There is a similar phrasing in the template CONTRIBUTING.md file generated too. Is there a branch-name-agnostic way to rephrase:

Pull requests will be evaluated by the repository guardians on a schedule and if deemed beneficial will be committed to the master.

Thanks for your consideration!

Tests failing with R CMD check

From R CMD check:

checking tests ... ERROR
  Running 'testthat.R'
Running the tests in 'tests/testthat.R' failed.
Last 13 lines of output:
  sort(normalizePath(files, winslash = "/")) not equal to sort(normalizePath(file.path(dir, expected_files), winslash = "/")).
  Lengths differ: 15 vs 16
  
  
  testthat results ================================================================
  OK: 20 SKIPPED: 0 FAILED: 6
  1. Failure: analysis_skeleton works with dot path and git_init (@test-analysis_skeleton.R#29) 
  2. Failure: analysis_skeleton works with relative path and git init (@test-analysis_skeleton.R#46) 
  3. Failure: analysis_skeleton works with absolute path and git init (@test-analysis_skeleton.R#61) 
  4. Failure: analysis_skeleton works with dot path and git clone (@test-analysis_skeleton.R#80) 
  5. Failure: analysis_skeleton works with relative path and git clone (@test-analysis_skeleton.R#95) 
  6. Failure: analysis_skeleton works with absolute path and git clone (@test-analysis_skeleton.R#111) 

But devtools::test() passes no problem. I think this is related to calls to setwd() though I can't quite figure out where.

Tried but didn't work:

  • Adding Sys.setenv("R_TESTS" = "") to testthat.R
  • Resetting directory to original directory after analysis_skeleton() changes it
  • Print statements don't seem to appear with R CMD check and devtools::check. For example, this:
test_that("analysis_skeleton works with dot path and git_init", {
  base_dir <- increment_foo()
  dir <- tempdir()
  dir.create(file.path(dir, base_dir))
  setwd(file.path(dir, base_dir))
  ret <- analysis_skeleton(rstudio = FALSE)
  skip_on_travis()
  expect_equal(normalizePath(ret, winslash = "/"), 
               normalizePath(".", winslash = "/"))
  files <- list.files(all.files = TRUE, full.names = TRUE, include.dirs = TRUE, no.. = TRUE)
  skip_on_travis()
  actual <- sort(normalizePath(files, winslash = "/"))
  print(actual)
  expected <- sort(normalizePath(file.path(".", expected_files), winslash = "/"))
  print(expected)
  expect_equal(actual, expected)
})

do not print any help info about exactly what actual and expected are. There should be 16 files but when using check actual only has 15 though I don't know exactly why.

Package vignettes for package_skeleton

Because the vast majority of packages created here will not end up on CRAN the build_vignettes() function in devtools may prove problematic because it doesn't keep a .md file around that is easily readable for github. For README's this isn't a problem as we can set the .yaml to something like this:

---
output:
  md_document:
    variant: markdown_github
---

However for a vignette this isn't the typical .yaml. Since vignettes are a critical way of communicating a package I wonder if some sort of custom rendering function might be useful. There are likely other ways to do this but one option is to define a function like this to keep the .md file so that at least it can pointed to on github

render_keep_md = function(vignette_name){
  rmarkdown::render(paste0("./vignettes/",vignette_name, ".Rmd"), clean=FALSE)
  files_to_remove = paste0("./vignettes/",vignette_name,c(".html",".md",".utf8.md"))
  lapply(files_to_remove, file.remove)
  
  file.rename(from = paste0("./vignettes/",vignette_name, ".knit.md"), to = paste0("./vignettes/",vignette_name, ".md"))
}

Library location setup code

E.g., set_home(), setup_r() are more for new users and only needs to be done once. This information is probably better for a wiki with instructions or a gist. For now just don't export these, and have a package startup check that checks for location of library and throws a warning with a link to the wiki.

Depend more on usethis package, including the create_from_github()

I wonder about simplifying bcgovr to rely more on the usethis package, including a function that both opens a GH repo & clones the repo locally e.g. usethis::create_from_github. This is still a friction point for users, in my opinion. I know we are already using some elements of usethis under the hood, but I wonder if we could rely more on this maturing rstudio package and strip down bcgovr for delivery of only the bcgov-specific set-up tasks?

Using: create_bcgov_project()

trying to make an existing .Rproj of mine bcgovr-proof: the code in this repo for create_bcgov_projec() gives errors, may I know the dependencies of this repo?

add License-Apache badge to use_apache_licence()

use_apache_licence() should automatically populate the README.md or README.Rmd with the licence badge.

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Consider changing default for Rmd README?

This default behaviour has been discussed before, however opening again for consideration.

Why again now? I have seen a number of unrendered Rmd READMEs in bcgov repos setup with {bcgovr}. IMO most users expect or only need the .md README out of the box, especially novice users of the package, so wonder if this should be the default? And then require a user to set rmarkdown = TRUE manually if that approach is needed?

e.g., https://github.com/bcgov/bcgovr/blob/master/R/create.R#L42

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.