Skip to content

Commit

Permalink
updates, cleanup, R CMD check
Browse files Browse the repository at this point in the history
  • Loading branch information
achubaty committed Jan 24, 2023
1 parent 381d984 commit b753742
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 80 deletions.
82 changes: 18 additions & 64 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ on:
branches:
- master
- development
- LandWeb
pull_request:
branches:
- master
Expand All @@ -13,6 +12,7 @@ name: R-CMD-check

jobs:
R-CMD-check:
if: "!contains(github.event.commits[0].message, '[skip-ci]')"
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})
Expand All @@ -21,81 +21,35 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'devel'}
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: '3.6'}
- {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
- {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
- {os: macOS-latest, nosuggests: false, r: 'release'}
- {os: windows-latest, nosuggests: false, r: 'devel'}
- {os: windows-latest, nosuggests: false, r: 'release'}
- {os: ubuntu-20.04, nosuggests: false, r: 'devel'}
- {os: ubuntu-20.04, nosuggests: false, r: 'release'}
- {os: ubuntu-20.04, nosuggests: true, r: 'release'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
_R_CHECK_DEPENDS_ONLY_: ${{ matrix.config.nosuggests }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@master
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}

- uses: r-lib/actions/setup-pandoc@master

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
use-public-rspm: true

- name: Install additional dependencies
run: |
remotes::install_github('PredictiveEcology/Require@development')
remotes::install_github('PredictiveEcology/reproducible@development')
shell: Rscript {0}

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-

- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
sudo apt-get install -y hunspell-en-ca
- name: Install dependencies
run: |
if (R.version$major < 4) {
remotes::install_cran("versions")
versions::install.versions("XML", "3.99-0.3")
}
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}
extra-packages: |
any::rcmdcheck
any::XML
- name: Check
env:
_R_CHECK_CRAN_INCOMING_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
- uses: r-lib/actions/check-r-package@v2

- name: Show testthat output
if: always()
Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: usefulFuns
Type: Package
Title: Useful functions for my modules and packages
Version: 0.1.0
Version: 0.1.1
Author: Tati Micheletti
Maintainer: Tati Micheletti <[email protected]>
Description: A few functions and wrappers around useful code.
Expand All @@ -10,7 +10,7 @@ Encoding: UTF-8
Language: en-CA
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.2.3
Depends:
R (>= 3.6)
Imports:
Expand All @@ -33,8 +33,8 @@ Imports:
raster,
rasterVis,
RColorBrewer,
remotes,
reproducible,
Require,
sp,
sf,
showtext,
Expand All @@ -45,6 +45,7 @@ Imports:
Suggests:
covr,
lintr,
remotes,
spelling
Remotes:
achubaty/amc@development,
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ importFrom(LandR,prepInputsLCC)
importFrom(LandR,sppColors)
importFrom(LandR,vegTypeMapGenerator)
importFrom(RColorBrewer,brewer.pal)
importFrom(Require,Require)
importFrom(SpaDES.core,paddedFloatToChar)
importFrom(SpaDES.tools,randomPolygon)
importFrom(SpaDES.tools,rasterizeReduced)
Expand Down Expand Up @@ -108,7 +109,6 @@ importFrom(raster,writeRaster)
importFrom(raster,xyFromCell)
importFrom(rasterVis,gplot)
importFrom(reproducible,Cache)
importFrom(reproducible,Require)
importFrom(reproducible,asPath)
importFrom(reproducible,assessDataType)
importFrom(reproducible,basename2)
Expand Down
4 changes: 2 additions & 2 deletions R/bootstrapPercentChanges.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @param n numeric. Default is 100. How many iterations (random selection of `sampleSize` pixels) should be done?
#' @param species character. Default is NULL. Which species should this function be ran ?
#' @param useFuture logical. Should use \pkg{future} to parallelize?
#' Requires `future` and `future_apply`` packages.
#' Requires `future` and `future_apply` packages.
#'
#' @return list of significant species or scenarios with indication of increasing or decreasing
#'
Expand Down Expand Up @@ -38,7 +38,7 @@ bootstrapPercentChanges <- function(dataPath,
n = 100,
shp = NULL,
species = NULL, useFuture = FALSE) {
if (class(shp) == "character") {
if (inherits(shp, "character")) {
studyArea <- Cache(.prepStudyAreaForBirds,
studyArea = shp,
dataPath = reproducible::checkPath(file.path(dataPath, "birdRTMEdehzhieRAS"),
Expand Down
3 changes: 2 additions & 1 deletion R/createDynamicLayersRSF.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#' @export
#' @importFrom data.table data.table setkey
#' @importFrom raster raster projectRaster extract dropLayer stack nlayers extent
#' @importFrom reproducible prepInputs postProcess Require
#' @importFrom reproducible prepInputs postProcess
#' @importFrom Require Require
#' @importFrom SpaDES.tools rasterizeReduced
#' @include burnFromAge.R
#' @include nameAndBringOn.R
Expand Down
2 changes: 1 addition & 1 deletion R/createModObject.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ createModObject <- function(data, sim = NULL, pathInput, currentTime, fun = read
)) == 0) {
stop(paste0("Please place the data in the input folder ", pathInput))
}
if (class(currentTime) != "numeric") {
if (inherits(currentTime, "numeric")) {
stop("Current time needs to be numeric!")
}
dataName <- grepMulti(
Expand Down
3 changes: 2 additions & 1 deletion R/createShrubHerbLayers.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ utils::globalVariables(c("classesECCC", "ECCC_Description"))
#' @export
#' @importFrom data.table data.table setkey
#' @importFrom raster raster setValues
#' @importFrom reproducible prepInputs postProcess Require
#' @importFrom reproducible prepInputs postProcess
#' @importFrom Require Require
#'
#' @rdname createShrubHerbLayers
createShrubHerbLayers <- function(landCoverECCC, reclassLCC05, layerName, includeCrops = FALSE) {
Expand Down
3 changes: 2 additions & 1 deletion R/createStaticLayersRSF.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
#' @export
#' @importFrom data.table data.table setkey
#' @importFrom raster dropLayer extent extract nlayers projectRaster raster reclassify stack
#' @importFrom reproducible prepInputs postProcess Require
#' @importFrom reproducible prepInputs postProcess
#' @importFrom Require Require
#' @importFrom SpaDES.tools rasterizeReduced
#' @include createShrubHerbLayers.R
#' @include nameAndBringOn.R
Expand Down
5 changes: 3 additions & 2 deletions R/defineStudyArea.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ utils::globalVariables(c("PRENAME"))
#' @rdname defineStudyArea
#'
#' @examples
#' \donttest{
#' ## rp is the whole North American boreal region
#' rp <- defineStudyArea(testArea = TRUE, specificTestArea = "boreal", mapSubset = NULL)
#'
#' ## Alberta
#' rp <- defineStudyArea(testArea = TRUE, specificTestArea = "Alberta", mapSubset = NULL)
#' \dontrun{
#'
#' ## Alberta inside boreal extension
#' rp <- defineStudyArea(testArea = TRUE, specificTestArea = "boreal", mapSubset = "Alberta")
#' }
Expand Down Expand Up @@ -57,7 +58,7 @@ defineStudyArea <- function(testArea = NULL, specificTestArea = NULL, mapSubset
if (is.null(mapSubset)) {
message(crayon::yellow("Test area is TRUE, specificTestArea is 'boreal', and mapSubset is NULL. Cropping and masking to the whole Boreal."))
rP <- reproducible::prepInputs(
url = "http://206.167.182.7/BAM/dataset/EnvironmentCanada/Brandt_boreal.zip",
url = "http://206.167.182.7/BAM/dataset/EnvironmentCanada/Brandt_boreal.zip", ## TODO: invalid URL
destinationPath = destinationFolder
)
}
Expand Down
2 changes: 1 addition & 1 deletion man/bootstrapPercentChanges.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions man/createDynamicLayersRSF.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/defineStudyArea.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions usefulFuns.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageCheckArgs: --as-cran
PackageRoxygenize: rd,collate,namespace,vignette

QuitChildProcessesOnExit: Yes
DisableExecuteRprofile: Yes

0 comments on commit b753742

Please sign in to comment.