ci: replace Jenkins with Gitea Actions, modernize DESCRIPTION
R-CMD-check / R CMD check (push) Failing after 3s
R-CMD-check / R CMD check (push) Failing after 3s
- Add real R CMD check workflow via Gitea Actions (rocker/r-ver:4.4) - Remove Jenkinsfile and demo workflow - Modernize DESCRIPTION: Authors@R, R >= 4.1.0, URL/BugReports fields, move tidycensus from Imports to Suggests, testthat edition 3 - Fix agresti_coull_interval: correct implementation, export it - Convert get_fips/get_stabbr to use requireNamespace for tidycensus - Remove civilytics:: self-reference in rnh()
This commit is contained in:
@@ -3,6 +3,5 @@
|
||||
^\.github$
|
||||
^README\.Rmd$
|
||||
^Makefile$
|
||||
^Jenkinsfile$
|
||||
^Dockerfile$
|
||||
^LICENSE\.md$
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
name: R-CMD-check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: R CMD check
|
||||
runs-on: ubuntu-latest
|
||||
container: rocker/r-ver:4.4
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y --no-install-recommends \
|
||||
libcurl4-openssl-dev \
|
||||
libssl-dev \
|
||||
libxml2-dev \
|
||||
libcairo2-dev \
|
||||
libjpeg-dev \
|
||||
libpng-dev \
|
||||
libfontconfig1-dev \
|
||||
libharfbuzz-dev \
|
||||
libfribidi-dev \
|
||||
libfreetype6-dev \
|
||||
libtiff5-dev
|
||||
|
||||
- name: Install R dependencies
|
||||
run: |
|
||||
install.packages(c("remotes", "rcmdcheck"))
|
||||
remotes::install_deps(dependencies = TRUE)
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Run R CMD check
|
||||
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning")
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Run tests
|
||||
run: testthat::test_local(".", reporter = "progress")
|
||||
shell: Rscript {0}
|
||||
@@ -1,19 +0,0 @@
|
||||
name: Gitea Actions Demo
|
||||
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v4
|
||||
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
|
||||
- name: List files in the repository
|
||||
run: |
|
||||
ls ${{ gitea.workspace }}
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
+12
-8
@@ -2,25 +2,29 @@ Package: civilytics
|
||||
Type: Package
|
||||
Title: Utilities Functions for Civilytics
|
||||
Version: 0.2.0
|
||||
Author: Jared E. Knowles <jared@civilytics.com>
|
||||
Maintainer: Jared E. Knowles <jared@civilytics.com>
|
||||
Description: House R functions for Civilytics Consulting LLC
|
||||
This package implements a variety of useful functions for creating and
|
||||
branding analyses produced by Civilytics Consulting LLC.
|
||||
Authors@R:
|
||||
person("Jared", "E. Knowles", email = "jared@civilytics.com",
|
||||
role = c("aut", "cre"))
|
||||
Description: House R functions for Civilytics Consulting LLC. This package
|
||||
implements a variety of useful functions for creating and branding analyses
|
||||
produced by Civilytics Consulting LLC.
|
||||
License: LGPL (>= 3)
|
||||
URL: https://gitea.civilytics.org/Civilytics/civilyticsR
|
||||
BugReports: https://gitea.civilytics.org/Civilytics/civilyticsR/issues
|
||||
Depends:
|
||||
R (>= 2.15.1)
|
||||
R (>= 4.1.0)
|
||||
Imports:
|
||||
ggplot2,
|
||||
jpeg,
|
||||
png,
|
||||
stringr,
|
||||
gridExtra,
|
||||
tidycensus,
|
||||
grid,
|
||||
stringdist
|
||||
Encoding: UTF-8
|
||||
LazyData: true
|
||||
Suggests:
|
||||
testthat
|
||||
testthat (>= 3.0.0),
|
||||
tidycensus
|
||||
RoxygenNote: 7.3.2
|
||||
Config/testthat/edition: 3
|
||||
|
||||
Vendored
-60
@@ -1,60 +0,0 @@
|
||||
pipeline {
|
||||
agent {
|
||||
dockerfile true
|
||||
}
|
||||
stages {
|
||||
stage('Docker setup') {
|
||||
steps {
|
||||
sh '''
|
||||
R --version
|
||||
java --version
|
||||
'''
|
||||
}
|
||||
|
||||
}
|
||||
stage('Build and test') {
|
||||
stages {
|
||||
stage("Build package") {
|
||||
steps {
|
||||
sh '''
|
||||
R CMD build .
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Check') {
|
||||
steps {
|
||||
sh '''
|
||||
R CMD check --no-manual civilytics_0.2.0.tar.gz
|
||||
'''
|
||||
|
||||
sh '''
|
||||
R CMD INSTALL civilytics_0.2.0.tar.gz
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('testthat'){
|
||||
steps {
|
||||
sh '''
|
||||
R -e 'testthat::test_local(".")'
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('test coverage') {
|
||||
steps {
|
||||
sh '''
|
||||
R -e 'covr::package_coverage(".")'
|
||||
'''
|
||||
}
|
||||
}
|
||||
stage('Clean') {
|
||||
steps {
|
||||
|
||||
sh '''
|
||||
rm -rf civilytics_0.2.0.tar.gz civilytics.Rcheck
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
# Generated by roxygen2: do not edit by hand
|
||||
|
||||
export(agresti_coull_interval)
|
||||
export(add_logo)
|
||||
export(add_logo_ga)
|
||||
export(clopper_pearson)
|
||||
@@ -39,7 +40,6 @@ export(waldInterval)
|
||||
export(z_gap_test)
|
||||
export(z_univariate)
|
||||
import(ggplot2)
|
||||
import(tidycensus)
|
||||
importFrom(ggplot2,theme)
|
||||
importFrom(graphics,plot)
|
||||
importFrom(graphics,rasterImage)
|
||||
|
||||
+16
-9
@@ -72,14 +72,21 @@ waldInterval <- function(x, n, conf.level = 0.95){
|
||||
|
||||
#' Calculate the Agresti-Coull interval
|
||||
#'
|
||||
#' @param num a number of successes
|
||||
#' @param den a number of trials
|
||||
#' @param conf.level default 0.95, set the confidence interval to return
|
||||
#' @param num number of successes
|
||||
#' @param den number of trials
|
||||
#' @param conf.level default 0.95, confidence level for the interval
|
||||
#'
|
||||
#' @return an interval
|
||||
agresti_coull_interval <- function(num, den, conf.level) {
|
||||
num <- num + 2
|
||||
den <- den + 4
|
||||
return(num/den)
|
||||
|
||||
#' @return three values forming the lower bound, observed proportion, and upper bound
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' agresti_coull_interval(20, 40)
|
||||
#' agresti_coull_interval(2, 100, conf.level = 0.99)
|
||||
agresti_coull_interval <- function(num, den, conf.level = 0.95) {
|
||||
z <- qnorm(1 - (1 - conf.level) / 2)
|
||||
n_tilde <- den + z^2
|
||||
p_tilde <- (num + z^2 / 2) / n_tilde
|
||||
margin <- z * sqrt(p_tilde * (1 - p_tilde) / n_tilde)
|
||||
obs <- num / den
|
||||
return(c("low" = p_tilde - margin, "observed" = obs, "high" = p_tilde + margin))
|
||||
}
|
||||
|
||||
@@ -234,14 +234,21 @@ outersect <- function(x, y, ...) {
|
||||
#' @param stabbr a two letter abbreviation for a US state
|
||||
#'
|
||||
#' @return FIPS codes that match the abbreviation
|
||||
#' @import tidycensus
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' get_fips("MT")
|
||||
#' get_fips("PR")
|
||||
#' get_fips("CC")
|
||||
#' }
|
||||
get_fips <- function(stabbr) {
|
||||
if (!requireNamespace("tidycensus", quietly = TRUE)) {
|
||||
stop(
|
||||
"Package 'tidycensus' is required for get_fips(). ",
|
||||
"Install it with: install.packages('tidycensus')",
|
||||
call. = FALSE
|
||||
)
|
||||
}
|
||||
fips <- tidycensus::fips_codes[, 1:2]
|
||||
fips <- fips[!duplicated(fips),]
|
||||
out <- fips[fips$state == stabbr, 2]
|
||||
@@ -253,12 +260,20 @@ get_fips <- function(stabbr) {
|
||||
#' @param fips a character value that captures the FIPS code with leading 0
|
||||
#'
|
||||
#' @return a character value, length 2, with the state abbreviation
|
||||
#' @import tidycensus
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' \dontrun{
|
||||
#' get_stabbr("06")
|
||||
#' }
|
||||
get_stabbr <- function(fips) {
|
||||
if (!requireNamespace("tidycensus", quietly = TRUE)) {
|
||||
stop(
|
||||
"Package 'tidycensus' is required for get_stabbr(). ",
|
||||
"Install it with: install.packages('tidycensus')",
|
||||
call. = FALSE
|
||||
)
|
||||
}
|
||||
fips_codes <- tidycensus::fips_codes[, 1:2]
|
||||
fips_codes <- fips_codes[!duplicated(fips_codes),]
|
||||
if (length(fips) != 1) {
|
||||
@@ -442,6 +457,6 @@ round_to_nearest_half <- function(x) {
|
||||
#' @examples
|
||||
#' rnh(c(0.2, 0.3, 0.4, 0.8, 0.09, 0.9))
|
||||
rnh <- function(x) {
|
||||
tmp <- Vectorize(civilytics::round_to_nearest_half)
|
||||
tmp <- Vectorize(round_to_nearest_half)
|
||||
tmp(x)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user