|
| 1 | +# GitHub Copilot Setup Steps for rme |
| 2 | +# |
| 3 | +# This workflow configures the GitHub Copilot coding agent's environment |
| 4 | +# by preinstalling R, Quarto, TinyTeX, and all required dependencies. |
| 5 | +# |
| 6 | +# See: https://docs.github.com/en/copilot/how-tos/use-copilot-agents/coding-agent/customize-the-agent-environment |
| 7 | +# For detailed setup instructions, see .github/copilot-instructions.md |
| 8 | +# |
| 9 | +# This workflow aligns with the setup requirements documented in .github/copilot-instructions.md: |
| 10 | +# - R version >= 3.5 (as specified in DESCRIPTION, prefer latest release) |
| 11 | +# - Quarto CLI for rendering the website |
| 12 | +# - TinyTeX for PDF output |
| 13 | +# - JAGS for Bayesian analysis (rjags and runjags packages) |
| 14 | +# - All package dependencies managed via renv |
| 15 | + |
| 16 | +name: "Copilot Setup Steps" |
| 17 | + |
| 18 | +# Automatically run the setup steps when they are changed to allow for easy validation, |
| 19 | +# and allow manual testing through the repository's "Actions" tab |
| 20 | +on: |
| 21 | + workflow_dispatch: |
| 22 | + push: |
| 23 | + paths: |
| 24 | + - .github/workflows/copilot-setup-steps.yml |
| 25 | + pull_request: |
| 26 | + paths: |
| 27 | + - .github/workflows/copilot-setup-steps.yml |
| 28 | + |
| 29 | +jobs: |
| 30 | + # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. |
| 31 | + copilot-setup-steps: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + |
| 34 | + # Set the permissions to the lowest permissions possible needed for your steps. |
| 35 | + # Copilot will be given its own token for its operations. |
| 36 | + permissions: |
| 37 | + contents: read |
| 38 | + |
| 39 | + # Timeout after 55 minutes (max is 59 for copilot-setup-steps) |
| 40 | + timeout-minutes: 55 |
| 41 | + |
| 42 | + steps: |
| 43 | + # Checkout code - Copilot will do this automatically if we don't, |
| 44 | + # but we need it to install dependencies from renv.lock |
| 45 | + - name: Checkout code |
| 46 | + uses: actions/checkout@v4 |
| 47 | + |
| 48 | + # Install system dependencies required for R packages |
| 49 | + # See .github/copilot-instructions.md "System Dependencies" and "JAGS Dependencies" sections |
| 50 | + - name: Install system dependencies |
| 51 | + run: | |
| 52 | + sudo apt-get update |
| 53 | + sudo apt-get install -y \ |
| 54 | + jags \ |
| 55 | + libcurl4-openssl-dev \ |
| 56 | + libssl-dev \ |
| 57 | + libxml2-dev \ |
| 58 | + libfontconfig1-dev \ |
| 59 | + libharfbuzz-dev \ |
| 60 | + libfribidi-dev \ |
| 61 | + libfreetype6-dev \ |
| 62 | + libpng-dev \ |
| 63 | + libtiff5-dev \ |
| 64 | + libjpeg-dev |
| 65 | + |
| 66 | + # Set up pandoc for documentation |
| 67 | + - name: Set up Pandoc |
| 68 | + uses: r-lib/actions/setup-pandoc@v2 |
| 69 | + |
| 70 | + # Set up R using the standard GitHub Actions setup |
| 71 | + # R version >= 3.5 required (see DESCRIPTION and .github/copilot-instructions.md) |
| 72 | + # Using 'release' to get the latest R version |
| 73 | + - name: Set up R |
| 74 | + uses: r-lib/actions/setup-r@v2 |
| 75 | + with: |
| 76 | + r-version: 'release' |
| 77 | + use-public-rspm: true |
| 78 | + |
| 79 | + # Set up Quarto - required for rendering the website |
| 80 | + # See .github/copilot-instructions.md "Quarto Rendering" section |
| 81 | + - name: Set up Quarto |
| 82 | + uses: quarto-dev/quarto-actions/setup@v2 |
| 83 | + with: |
| 84 | + tinytex: true |
| 85 | + |
| 86 | + # Install R dependencies using renv |
| 87 | + # This project uses renv for package management |
| 88 | + # See .github/copilot-instructions.md "R Package Management" section |
| 89 | + - name: Install R dependencies via renv |
| 90 | + uses: r-lib/actions/setup-renv@v2 |
| 91 | + with: |
| 92 | + cache-version: 1 |
| 93 | + |
| 94 | + # Verify R environment is properly configured |
| 95 | + # See .github/copilot-instructions.md sections on development setup |
| 96 | + - name: Verify development environment |
| 97 | + run: | |
| 98 | + echo "=== R Development Environment Status ===" |
| 99 | + Rscript -e ' |
| 100 | + cat("R version:", R.version.string, "\n\n") |
| 101 | + |
| 102 | + # Check R version meets minimum requirement (>= 3.5) |
| 103 | + r_version <- paste(R.version$major, R.version$minor, sep = ".") |
| 104 | + cat("Checking R version >= 3.5... ") |
| 105 | + if (getRversion() >= "3.5") { |
| 106 | + cat("PASSED (", r_version, ")\n\n", sep = "") |
| 107 | + } else { |
| 108 | + cat("FAILED (", r_version, ")\n\n", sep = "") |
| 109 | + stop("R version must be >= 3.5") |
| 110 | + } |
| 111 | + |
| 112 | + # Display key installed packages from DESCRIPTION |
| 113 | + cat("Key installed packages:\n") |
| 114 | + key_packages <- c("arm", "arsenal", "cards", "cardx", "cvTools", "dobson", |
| 115 | + "forcats", "fs", "glmmTMB", "glmnet", "gtsummary", "here", |
| 116 | + "insight", "knitr", "latex2exp", "olsrr", "pander", "printr", |
| 117 | + "reactable", "rlang", "rmarkdown", "stringr", "table1", "tibble", |
| 118 | + "webshot2", "tidyverse", "rjags", "runjags", "ggplot2", "dplyr", |
| 119 | + "tidyr", "spelling", "gh", "lintr", "purrr", "pkgdown") |
| 120 | + for (pkg in key_packages) { |
| 121 | + if (requireNamespace(pkg, quietly = TRUE)) { |
| 122 | + cat(" -", pkg, ":", as.character(packageVersion(pkg)), "\n") |
| 123 | + } else { |
| 124 | + cat(" -", pkg, ": NOT INSTALLED\n") |
| 125 | + } |
| 126 | + } |
| 127 | + |
| 128 | + cat("\nTotal packages installed:", nrow(installed.packages()), "\n") |
| 129 | + ' |
| 130 | + |
| 131 | + # Verify Quarto is installed and working |
| 132 | + echo "" |
| 133 | + echo "=== Quarto Status ===" |
| 134 | + quarto --version |
| 135 | + quarto list tools |
| 136 | + |
| 137 | + # Verify JAGS is installed |
| 138 | + echo "" |
| 139 | + echo "=== JAGS Status ===" |
| 140 | + if which jags > /dev/null 2>&1; then |
| 141 | + echo "JAGS found in PATH" |
| 142 | + jags -v 2>&1 || echo "JAGS installed but version check failed" |
| 143 | + else |
| 144 | + echo "JAGS not found in PATH" |
| 145 | + fi |
| 146 | + |
| 147 | + # Verify renv is active |
| 148 | + echo "" |
| 149 | + echo "=== renv Status ===" |
| 150 | + Rscript -e 'cat("renv active:", !is.null(renv::project()), "\n")' |
| 151 | + Rscript -e 'cat("renv library path:", .libPaths()[1], "\n")' |
| 152 | + |
| 153 | + echo "" |
| 154 | + echo "Development environment setup complete!" |
0 commit comments