Skip to content

Commit

Permalink
Update Github Actions (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
csgillespie committed Oct 23, 2023
1 parent bc6c510 commit e7c29e3
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 137 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
^README\.Rmd$
^\.Rprofile$
^\.github$
^codecov\.yml$
52 changes: 52 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 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
#
# NOTE: This workflow is overkill for most R packages and
# check-standard.yaml is likely a better choice.
# usethis::use_github_action("check-standard") will install it.
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: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}


env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- 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 }}
use-public-rspm: true

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

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
73 changes: 0 additions & 73 deletions .github/workflows/check-standard.yaml

This file was deleted.

69 changes: 31 additions & 38 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,55 +1,48 @@
# 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
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

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

- name: Query dependencies
run: |
install.packages('remotes', repos = "https://packagemanager.rstudio.com/cran/__linux__/focal/latest")
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}
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Cache R packages
uses: actions/cache@v2
- 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 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
extra-packages: any::pkgdown, local::.
needs: website

- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE, repos = "https://packagemanager.rstudio.com/cran/__linux__/focal/latest")
install.packages("pkgdown", repos = "https://packagemanager.rstudio.com/cran/__linux__/focal/latest")
- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
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)'
- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
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@v3

- 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(Sys.getenv("RUNNER_TEMP"), "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@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
26 changes: 13 additions & 13 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ knitr::opts_chunk$set(
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/rprofile)](https://CRAN.R-project.org/package=rprofile)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![R-CMD-check](https://github.com/csgillespie/rprofile/workflows/R-CMD-check/badge.svg)](https://github.com/csgillespie/rprofile/actions)
[![R-CMD-check](https://github.com/csgillespie/rprofile/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/csgillespie/rprofile/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/csgillespie/rprofile/branch/main/graph/badge.svg)](https://app.codecov.io/gh/csgillespie/rprofile?branch=main)
<!-- badges: end -->

A package (of my) Rprofile customisations. The goal is it broaden the package
Expand Down Expand Up @@ -111,32 +112,31 @@ Open your `.Rprofile`, e.g. `file.edit("~/.Rprofile")` and customise however you
Here's an example

```
# Set options for Rscript -e calls
if (requireNamespace("rprofile", quietly = TRUE)) {
if (requireNamespace("rprofile.setup", quietly = TRUE)) {
# Call here if needed
# rprofile::set_repos()
rprofile::set_startup_options()
# rprofile.setup::set_repos()
rprofile.setup::set_startup_options()
}
if (interactive() && requireNamespace("rprofile", quietly = TRUE)) {
rprofile::create_make_functions()
if (interactive() && requireNamespace("rprofile.setup", quietly = TRUE)) {
rprofile.setup::create_make_functions()
# Not RStudio OR RStudio console
if (rprofile::is_terminal()) {
rprofile::set_terminal()
if (rprofile.setup::is_terminal()) {
rprofile.setup::set_terminal()
} else {
rprofile::set_rstudio()
rprofile.setup::set_rstudio()
}
.env = rprofile::set_functions()
.env = rprofile.setup::set_functions()
attach(.env)
# Display wifi and no of R sessions
# Linux only
rprofile::set_startup_info()
rprofile.setup::set_startup_info()
}
# Prints RStudio project on start-up
setHook("rstudio.sessionInit", function(newSession) {
active_rproj = rprofile::get_active_rproj()
active_rproj = rprofile.setup::get_active_rproj()
if (!is.null(active_rproj)) {
message(glue::glue("{crayon::yellow('R-project:')} {active_rproj}"))
}
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
status](https://www.r-pkg.org/badges/version/rprofile)](https://CRAN.R-project.org/package=rprofile)
[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![R-CMD-check](https://github.com/csgillespie/rprofile/workflows/R-CMD-check/badge.svg)](https://github.com/csgillespie/rprofile/actions)
[![R-CMD-check](https://github.com/csgillespie/rprofile/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/csgillespie/rprofile/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/csgillespie/rprofile/branch/main/graph/badge.svg)](https://app.codecov.io/gh/csgillespie/rprofile?branch=main)
<!-- badges: end -->

A package (of my) Rprofile customisations. The goal is it broaden the
Expand Down Expand Up @@ -107,32 +109,31 @@ repositories - `set_repos()`. Probably not needed by most people.
Open your `.Rprofile`, e.g. `file.edit("~/.Rprofile")` and customise
however you want. Here’s an example


# Set options for Rscript -e calls
if (requireNamespace("rprofile", quietly = TRUE)) {
if (requireNamespace("rprofile.setup", quietly = TRUE)) {
# Call here if needed
# rprofile::set_repos()
rprofile::set_startup_options()
# rprofile.setup::set_repos()
rprofile.setup::set_startup_options()
}

if (interactive() && requireNamespace("rprofile", quietly = TRUE)) {
rprofile::create_make_functions()
if (interactive() && requireNamespace("rprofile.setup", quietly = TRUE)) {
rprofile.setup::create_make_functions()
# Not RStudio OR RStudio console
if (rprofile::is_terminal()) {
rprofile::set_terminal()
if (rprofile.setup::is_terminal()) {
rprofile.setup::set_terminal()
} else {
rprofile::set_rstudio()
rprofile.setup::set_rstudio()
}
.env = rprofile::set_functions()
.env = rprofile.setup::set_functions()
attach(.env)
# Display wifi and no of R sessions
# Linux only
rprofile::set_startup_info()
rprofile.setup::set_startup_info()
}

# Prints RStudio project on start-up
setHook("rstudio.sessionInit", function(newSession) {
active_rproj = rprofile::get_active_rproj()
active_rproj = rprofile.setup::get_active_rproj()
if (!is.null(active_rproj)) {
message(glue::glue("{crayon::yellow('R-project:')} {active_rproj}"))
}
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 e7c29e3

Please sign in to comment.