mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 00:10:57 +01:00
122 lines
6.1 KiB
YAML
122 lines
6.1 KiB
YAML
# ==================================================================== #
|
|
# TITLE: #
|
|
# AMR: An R Package for Working with Antimicrobial Resistance Data #
|
|
# #
|
|
# SOURCE CODE: #
|
|
# https://github.com/msberends/AMR #
|
|
# #
|
|
# PLEASE CITE THIS SOFTWARE AS: #
|
|
# Berends MS, Luz CF, Friedrich AW, et al. (2022). #
|
|
# AMR: An R Package for Working with Antimicrobial Resistance Data. #
|
|
# Journal of Statistical Software, 104(3), 1-31. #
|
|
# https://doi.org/10.18637/jss.v104.i03 #
|
|
# #
|
|
# Developed at the University of Groningen and the University Medical #
|
|
# Center Groningen in the Netherlands, in collaboration with many #
|
|
# colleagues from around the world, see our website. #
|
|
# #
|
|
# This R package is free software; you can freely use and distribute #
|
|
# it for both personal and commercial purposes under the terms of the #
|
|
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
|
# the Free Software Foundation. #
|
|
# We created this package for both routine data analysis and academic #
|
|
# research and it was publicly released in the hope that it will be #
|
|
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
|
|
# #
|
|
# Visit our website for the full manual and a complete tutorial about #
|
|
# how to conduct AMR data analysis: https://amr-for-r.org #
|
|
# ==================================================================== #
|
|
|
|
# The AMR package must work fully without dplyr (and without tidyselect), as dplyr is only suggested.
|
|
# This workflow mimics a user who installs the CRAN binary (built on a machine with ALL suggested packages) but does not have dplyr: AMR is installed while dplyr and tidyselect are available, after which they and all packages depending on them are removed, and all unit tests and all examples are run against the installed package. R CMD check cannot detect these problems, as it reinstalls the package itself.
|
|
|
|
on:
|
|
pull_request:
|
|
# run in each PR in this repo
|
|
branches: '**'
|
|
push:
|
|
# only on main; pushing to a PR branch is already covered by pull_request above
|
|
branches: [main]
|
|
schedule:
|
|
# also run a schedule everyday at 2 AM
|
|
- cron: '0 2 * * *'
|
|
|
|
name: check-without-dplyr
|
|
|
|
# a new commit cancels the runs of the previous commit on the same PR or branch, a scheduled run is never cancelled by a push
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
setup:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
steps:
|
|
- id: set-matrix
|
|
shell: bash
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
|
echo 'matrix={"config":[{"os":"ubuntu-latest","r":"release","unavailable":"dplyr tidyselect"},{"os":"ubuntu-latest","r":"release","unavailable":"dplyr"}]}' >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo 'matrix={"config":[{"os":"ubuntu-latest","r":"release","unavailable":"dplyr tidyselect"},{"os":"ubuntu-latest","r":"release","unavailable":"dplyr"},{"os":"ubuntu-latest","r":"oldrel-1","unavailable":"dplyr tidyselect"},{"os":"windows-latest","r":"release","unavailable":"dplyr tidyselect"}]}' >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
R-without-dplyr:
|
|
needs: setup
|
|
runs-on: ${{ matrix.config.os }}
|
|
|
|
name: ${{ matrix.config.os }} (R-${{ matrix.config.r }}) without ${{ matrix.config.unavailable }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
|
|
|
|
env:
|
|
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
|
UNAVAILABLE: ${{ matrix.config.unavailable }}
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: r-lib/actions/setup-r@v2
|
|
with:
|
|
r-version: ${{ matrix.config.r }}
|
|
# use RStudio Package Manager to quickly install packages
|
|
use-public-rspm: true
|
|
|
|
- uses: r-lib/actions/setup-r-dependencies@v2
|
|
with:
|
|
# all dependencies, including suggested packages such as dplyr and tidyselect
|
|
dependencies: '"all"'
|
|
extra-packages: any::testthat
|
|
|
|
- name: Install AMR while dplyr and tidyselect are available
|
|
shell: Rscript {0}
|
|
run: |
|
|
stopifnot(requireNamespace("dplyr", quietly = TRUE), requireNamespace("tidyselect", quietly = TRUE))
|
|
install.packages(".", repos = NULL, type = "source")
|
|
stopifnot(requireNamespace("AMR", quietly = TRUE))
|
|
|
|
- name: Remove ${{ matrix.config.unavailable }} and all packages depending on them
|
|
shell: Rscript {0}
|
|
run: |
|
|
remove <- strsplit(Sys.getenv("UNAVAILABLE"), " ", fixed = TRUE)[[1]]
|
|
ip <- utils::installed.packages()
|
|
rev <- tools::dependsOnPkgs(remove, dependencies = c("Depends", "Imports", "LinkingTo"), recursive = TRUE, installed = ip)
|
|
drop <- setdiff(unique(c(remove, rev)), "AMR")
|
|
stopifnot(!"testthat" %in% drop)
|
|
cat("Removing", length(drop), "packages:", paste(sort(drop), collapse = ", "), "\n")
|
|
for (i in which(ip[, "Package"] %in% drop)) {
|
|
utils::remove.packages(ip[i, "Package"], lib = ip[i, "LibPath"])
|
|
}
|
|
for (pkg in remove) {
|
|
if (requireNamespace(pkg, quietly = TRUE)) stop(pkg, " is still available")
|
|
}
|
|
stopifnot(requireNamespace("testthat", quietly = TRUE), requireNamespace("AMR", quietly = TRUE))
|
|
|
|
- name: Run all unit tests and examples against the installed package
|
|
shell: bash
|
|
run: Rscript .github/scripts/test_installed_without.R $UNAVAILABLE
|