Skip to content

Merge main into cran-submission #59

Merge main into cran-submission

Merge main into cran-submission #59

# GitHub Copilot Setup Steps for serodynamics
#
# This workflow configures the GitHub Copilot coding agent's environment
# by preinstalling R, JAGS, and all required dependencies.
#
# See: https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment
# For detailed setup instructions, see .github/copilot-instructions.md
#
# This workflow aligns with the setup requirements documented in .github/copilot-instructions.md:
# - R version >= 4.1.0 (as specified in DESCRIPTION)
# - JAGS 4.3.1 system library and R interface
# - All package dependencies (Imports, Suggests, and development needs)
name: "Copilot Setup Steps"
# Automatically run the setup steps when they are changed to allow for easy validation,
# and allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest
# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
contents: read
# Timeout after 55 minutes (max is 59 for copilot-setup-steps)
timeout-minutes: 55
steps:
# Checkout code - Copilot will do this automatically if we don't,
# but we need it to install dependencies from DESCRIPTION
- name: Checkout code
uses: actions/checkout@v4
# Install system dependencies required for R packages
# See .github/copilot-instructions.md "Verify Development Environment" section
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev \
libfontconfig1-dev \
libharfbuzz-dev \
libfribidi-dev \
libfreetype6-dev \
libpng-dev \
libtiff5-dev \
libjpeg-dev
# Install JAGS (Just Another Gibbs Sampler) - REQUIRED for this package
# Version 4.3.1 as documented in .github/copilot-instructions.md
- name: Install JAGS
run: |
sudo apt-get install -y jags
echo "JAGS installed successfully"
# Set up pandoc for documentation
- name: Set up Pandoc
uses: r-lib/actions/setup-pandoc@v2
# Set up R using the standard GitHub Actions setup
# R version >= 4.1.0 required (see DESCRIPTION and .github/copilot-instructions.md)
- name: Set up R
uses: r-lib/actions/setup-r@HEAD
with:
r-version: 'release'
use-public-rspm: true
# Install R dependencies with caching for faster subsequent runs
- name: Install R dependencies
uses: r-lib/actions/setup-r-dependencies@HEAD
with:
extra-packages: |
any::devtools
any::rcmdcheck
any::lintr
any::spelling
any::rmarkdown
needs: check
# Install rjags from source to ensure proper linking with JAGS
# See .github/copilot-instructions.md "JAGS Installation" section
- name: Install rjags
run: |
install.packages("rjags",
repos = "https://cloud.r-project.org",
type = "source",
verbose = TRUE)
withr::local_options(warn = 2)
library(rjags)
library(runjags)
runjags::findjags()
runjags::testjags()
shell: Rscript {0}
# Verify JAGS installation
# See .github/copilot-instructions.md "JAGS Installation" section for details
- name: Verify JAGS installation
run: |
echo "=== Verifying JAGS Installation ==="
echo "System JAGS command:"
which jags || echo "Warning: jags command not found in PATH"
echo ""
echo "R JAGS interface packages:"
Rscript -e 'cat("rjags version:", as.character(packageVersion("rjags")), "\n")'
Rscript -e 'cat("runjags version:", as.character(packageVersion("runjags")), "\n")'
echo ""
echo "JAGS location (from runjags):"
Rscript -e 'print(runjags::findjags())'
echo ""
echo "Running JAGS test:"
Rscript -e 'runjags::testjags()'
# Verify R environment is properly configured
# See .github/copilot-instructions.md "Verify Development Environment" section
- name: Verify development environment
run: |
echo "=== R Development Environment Status ==="
Rscript -e '
cat("R version:", R.version.string, "\n\n")
# Check R version meets minimum requirement (>= 4.1.0)
r_version <- paste(R.version$major, R.version$minor, sep = ".")
cat("Checking R version >= 4.1.0... ")
if (getRversion() >= "4.1.0") {
cat("PASSED (", r_version, ")\n\n", sep = "")
} else {
cat("FAILED (", r_version, ")\n\n", sep = "")
stop("R version must be >= 4.1.0")
}
# Display key installed packages
cat("Key installed packages:\n")
key_packages <- c("devtools", "rjags", "runjags", "rcmdcheck", "lintr", "spelling", "testthat")
for (pkg in key_packages) {
if (requireNamespace(pkg, quietly = TRUE)) {
cat(" -", pkg, ":", as.character(packageVersion(pkg)), "\n")
} else {
cat(" -", pkg, ": NOT INSTALLED\n")
}
}
cat("\nTotal packages installed:", nrow(installed.packages()), "\n")
cat("\nDevelopment environment setup complete!\n")
'