Skip to content

Commit

Permalink
use github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
njtierney committed Mar 4, 2024
1 parent 530236c commit bc53989
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^geotargets\.Rproj$
^\.Rproj\.user$
^README\.Rmd$
^\.github$
^codecov\.yml$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
72 changes: 72 additions & 0 deletions .github/workflows/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: 'check-r-package'
description: 'Action to check R package with rcmdcheck. Assumes that rcmdcheck has already been installed.'
author: 'Jim Hester'
inputs:
args:
description: 'Arguments to pass to the `args` parameter of rcmdcheck. Must be an R expression. Note that it often needs to be quoted in YAML, see the README for details.'
default: 'c("--no-manual", "--as-cran")'
build_args:
description: 'Arguments to pass to the `build_args` parameter of rcmdcheck. Note that it often needs to be quoted in YAML, see the README for details.'
default: '"--no-manual"'
error-on:
description: 'What type of result should cause a build error? Note that it often needs to be quoted in YAML, see the README for details.'
default: '"warning"'
check-dir:
description: 'Where should the check output go? Note that it often needs to be quoted in YAML, see the README for details.'
default: '"check"'
working-directory:
description: 'Using the working-directory keyword, you can specify the working directory of where "rcmdcheck::rcmdcheck" is run.'
default: '.'
upload-snapshots:
description: 'Whether to upload all testthat snapshots as an artifact.'
default: false
upload-results:
description: 'Whether to upload check results for successful runs too.'
default: false
artifact-name:
description: |
Use this to override the default artifact name for the check results.
snapshot-artifact-name:
description: |
Use this to override the default artifact name for testthat snapshots.
runs:
using: "composite"
steps:
- name: Check
id: rcmdcheck
run: |
## --------------------------------------------------------------------
options(crayon.enabled = TRUE)
cat("LOGNAME=", Sys.info()[["user"]], "\n", sep = "", file = Sys.getenv("GITHUB_ENV"), append = TRUE)
if (Sys.getenv("_R_CHECK_FORCE_SUGGESTS_", "") == "") Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "false")
if (Sys.getenv("_R_CHECK_CRAN_INCOMING_", "") == "") Sys.setenv("_R_CHECK_CRAN_INCOMING_" = "false")
cat("check-dir-path=", file.path(getwd(), (${{ inputs.check-dir }})), "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
check_results <- rcmdcheck::rcmdcheck(args = (${{ inputs.args }}), build_args = (${{ inputs.build_args }}), error_on = (${{ inputs.error-on }}), check_dir = (${{ inputs.check-dir }}))
shell: Rscript {0}
working-directory: ${{ inputs.working-directory }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
echo ::group::Show testthat output
find check -name 'testthat.Rout*' -exec cat '{}' \; || true
echo ::endgroup::
shell: bash
working-directory: ${{ inputs.working-directory }}

- name: Upload check results
if: failure() || inputs.upload-results != 'false'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name || format('{0}-{1}-r{2}-{3}-results', runner.os, runner.arch, matrix.config.r, matrix.config.id || strategy.job-index ) }}
path: ${{ steps.rcmdcheck.outputs.check-dir-path }}

- name: Upload snapshots
if: inputs.upload-snapshots != 'false'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.snapshot-artifact-name || format('{0}-{1}-r{2}-{3}-testthat-snapshots', runner.os, runner.arch, matrix.config.r, matrix.config.id || strategy.job-index ) }}
path: ${{ steps.rcmdcheck.outputs.check-dir-path }}/**/tests*/testthat/_snaps
if-no-files-found: ignore
50 changes: 50 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
3 changes: 3 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ knitr::opts_chunk$set(
# geotargets

<!-- badges: start -->
[![R Targetopia](https://img.shields.io/badge/R_Targetopia-member-blue?style=flat&labelColor=gray)](https://wlandau.github.io/targetopia/)
[![R-CMD-check](https://github.com/njtierney/geotargets/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/njtierney/geotargets/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/njtierney/geotargets/branch/master/graph/badge.svg)](https://app.codecov.io/gh/njtierney/geotargets?branch=master)
<!-- badges: end -->

The goal of geotargets is to extend targets to work with geospatial data, like shapefiles and rasters.
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
# geotargets

<!-- badges: start -->

[![R
Targetopia](https://img.shields.io/badge/R_Targetopia-member-blue?style=flat&labelColor=gray)](https://wlandau.github.io/targetopia/)
[![R-CMD-check](https://github.com/njtierney/geotargets/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/njtierney/geotargets/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/njtierney/geotargets/branch/master/graph/badge.svg)](https://app.codecov.io/gh/njtierney/geotargets?branch=master)
<!-- badges: end -->

The goal of geotargets is to extend targets to work with geospatial
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true

0 comments on commit bc53989

Please sign in to comment.