Skip to content

Commit

Permalink
Merge pull request #22 from lixun910/master
Browse files Browse the repository at this point in the history
add GitHub Actions for Rcheck, Rlint, pkgdown; fix some lint issues
  • Loading branch information
lixun910 authored Aug 4, 2021
2 parents 918a364 + 1b32d70 commit 8e7d130
Show file tree
Hide file tree
Showing 200 changed files with 1,287 additions and 23,815 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
^src/libgeoda/LICENSE
^src/libgeoda/README.md
^src/libgeoda/.git
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
123 changes: 123 additions & 0 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# NOTE: This workflow is overkill for most R packages
# check-standard.yaml is likely a better choice
# usethis::use_github_action("check-standard") will install it.
#
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
#- {os: windows-latest, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/latest"}
#- {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: ubuntu-18.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
#- {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
#- {os: ubuntu-18.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}

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

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

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

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

- 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}

- name: Restore R package cache
uses: actions/cache@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 'writeLines(remotes::system_requirements("ubuntu", "18.04"))')
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
remotes::install_cran("testthat")
remotes::install_cran("devtools")
remotes::install_cran("spdep")
remotes::install_cran("sf")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_: false
run: |
options(crayon.enabled = TRUE)
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Test
run: |
devtools::test()
shell: Rscript {0}

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check

- name: Don't use tar from old Rtools to store the cache
if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }}
shell: bash
run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH
31 changes: 31 additions & 0 deletions .github/workflows/lint-project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

name: lint-project

jobs:
lint-project:
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- uses: r-lib/actions/setup-r@v1

- name: Install lintr
run: install.packages("lintr")
shell: Rscript {0}

- name: Lint root directory
run: lintr::lint_dir()
shell: Rscript {0}
52 changes: 52 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
on:
push:
branches:
- main
- master
tags:
-'*'

name: pkgdown

jobs:
pkgdown:
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- uses: r-lib/actions/setup-r@v1

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

- 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}

- name: Restore R package cache
uses: actions/cache@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 dependencies
run: |
remotes::install_deps(dependencies = TRUE)
install.packages("pkgdown", type = "binary")
shell: Rscript {0}

- name: Install package
run: R CMD INSTALL .

- name: Deploy package
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: rgeoda
Type: Package
Title: R Library for Spatial Data Analysis
Version: 0.0.8-3
Date: 2021-07-21
Version: 0.0.8-4
Date: 2021-08-04
Authors@R:
c(person(given = "Xun", family = "Li", email="[email protected]", role=c("aut","cre")),
person(given = "Luc", family = "Anselin", email="[email protected]", role="aut"))
Expand Down
3 changes: 2 additions & 1 deletion R/clustering.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
############################################################
#' @title Spatial C(K)luster Analysis by Tree Edge Removal
#' @description SKATER forms clusters by spatially partitioning data that has similar values for features of interest.
#' @description SKATER forms clusters by spatially partitioning data that has
#' similar values for features of interest.
#' @param k The number of clusters
#' @param w An instance of Weight class
#' @param df A data frame with selected variables only. E.g. guerry[c("Crm_prs", "Crm_prp", "Litercy")]
Expand Down
12 changes: 6 additions & 6 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @useDynLib rgeoda
NULL

.onUnload = function(libname, pkgname) {
.onUnload <- function(libname, pkgname) {
}

# When creating weights from sf/sp object, the geoda object will be created and
Expand All @@ -26,19 +26,19 @@ getGeoDaObj <- function(sf_obj) {

geoda_obj <- NULL

if (exists(gda_uid, envir=cacheEnv)) {
if (exists(gda_uid, envir = cacheEnv)) {
# use it directly for weights creation
geoda_obj <- get(gda_uid, envir=cacheEnv)
geoda_obj <- get(gda_uid, envir = cacheEnv)
} else {
# create a geoda object from sf_obj, NOT copy table
geoda_obj <- as.geoda(sf_obj, with_table = FALSE)
# cache it
assign(gda_uid, geoda_obj, envir=cacheEnv)
assign(gda_uid, geoda_obj, envir = cacheEnv)
}

if (is.null(geoda_obj) || geoda_obj$GetNumObs() <=0) {
if (is.null(geoda_obj) || geoda_obj$GetNumObs() <= 0) {
stop("Failed to read sf object. Please submit a bug report to https://github.com/geodacenter/rgeoda")
}

return (geoda_obj)
return(geoda_obj)
}
Loading

0 comments on commit 8e7d130

Please sign in to comment.