Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
351b581
Initial plan
Copilot Jan 6, 2026
1f54813
Initialize renv in repository
Copilot Jan 6, 2026
7563ea1
Update workflows to use renv
Copilot Jan 6, 2026
43c953d
fix
d-morrison Jan 6, 2026
18bcaa9
update lock file
d-morrison Jan 6, 2026
826edb8
update wordlist
d-morrison Jan 6, 2026
005c2d2
Add system dependencies and copilot instructions for workflow debugging
Copilot Jan 6, 2026
eaa44ba
Add copilot instructions file for workflow debugging
Copilot Jan 6, 2026
44598ae
Add libfontconfig1-dev system dependency to workflows
Copilot Jan 6, 2026
2f05695
Merge branch 'main' into copilot/configure-renv-in-repo
d-morrison Jan 6, 2026
5c44914
Update copilot instructions with libfontconfig1-dev dependency
Copilot Jan 6, 2026
9536136
Disable renv for spellcheck workflow
Copilot Jan 6, 2026
05f3858
Merge main into copilot/configure-renv-in-repo
Copilot Jan 6, 2026
a3eb15e
Merge branch 'main' into copilot/configure-renv-in-repo
d-morrison Jan 6, 2026
502409a
Add libjpeg-dev system dependency to all workflows
Copilot Jan 6, 2026
6ab1b14
Install local package before rendering Quarto documents
Copilot Jan 6, 2026
024d7d4
Add Quarto rendering instructions to copilot guidelines
Copilot Jan 6, 2026
59a6de4
Merge copilot instructions from hoff-bayesian-statistics repository
Copilot Jan 6, 2026
a6fbff0
use usethis and devtools
d-morrison Jan 6, 2026
03ed40f
Add rjags to renv.lock for Bayesian analysis support
Copilot Jan 6, 2026
cf3873e
Enable renv cache versioning for faster workflow runs
Copilot Jan 6, 2026
8cc4174
Remove cache-version parameter to use default renv caching
Copilot Jan 6, 2026
c0befd9
Merge branch 'main' into copilot/configure-renv-in-repo
d-morrison Jan 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
^renv$
^renv\.lock$
^LICENSE\.md$
^CODE_OF_CONDUCT\.md$
^.*\.Rproj$
Expand Down
6 changes: 6 additions & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source("renv/activate.R")

if (interactive()) {
require(usethis)
require(devtools)
}
196 changes: 194 additions & 2 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
# GitHub Copilot Instructions

> [!IMPORTANT]
> **MANDATORY TESTING BEFORE EVERY COMMIT:**
>
> Before committing ANY changes to `.qmd`, `.R`, or config files:
>
> 1. **Run `quarto render` on the FULL repository** (not individual files)
> 2. **Verify it completes successfully** (exit code 0, no errors)
> 3. **Run linter on changed files**:
> - For R files: `lintr::lint("path/to/file.R")`
> - For .qmd files with R code: Extract and lint R code chunks
> - **Fix lint issues in code you wrote or modified** - ignore pre-existing issues in unchanged code
> 4. **Run spellcheck**: `spelling::spell_check_package()`
> - **Fix spelling errors you introduced** - ignore pre-existing errors
> - Add technical terms to `inst/WORDLIST` if needed (create file if it doesn't exist, one word per line)
> 5. Only then commit your changes
>
> **CRITICAL RULES:**
> - **CI is NOT the test** - you must test locally BEFORE pushing
> - **NEVER rely on CI to discover rendering, lint, or spelling errors** - that's your job
> - **ALWAYS run full `quarto render`** - testing individual files is insufficient
> - **Only fix lint/spell issues in code YOU changed** - don't fix unrelated pre-existing issues
> - **This is a hard requirement - no exceptions, no excuses**

## General Development Principles

**CRITICAL**: Do not make assumptions about what code will do - always test it yourself.

- **Test your changes**: Run the actual commands to verify functionality
- **Run `quarto render` on FULL repository**: Testing individual files misses cross-file issues
- **Verify output**: Check that expected files are created with correct content
- **Never claim success without evidence**: Only report that something works after you've confirmed it yourself

## Pull Request Guidelines

- Always ensure that PR branch is up to date with main branch before requesting PR review
- **ALWAYS verify all changed hyperlinks are correct before requesting PR review**:
- Check that internal links point to existing files/sections
- Verify external URLs are accessible and correct
- Test cross-references and anchor links
- Ensure relative paths are correct

## Code Formatting Guidelines

Expand All @@ -28,8 +65,10 @@ Example:
When investigating CI/CD failures (build, test, or lint workflow issues):

1. **Use GitHub MCP tools to inspect job logs directly**:
- **ALWAYS read workflow logs directly** using GitHub MCP tools (`github-mcp-server-get_job_logs`, `github-mcp-server-list_workflow_runs`)
- Do NOT rely on assumptions or generic troubleshooting - examine the actual error output
- Use `list_workflow_runs` to see recent workflow runs and their status
- Use `get_job_logs` with `failed_only=true` to retrieve logs from failed jobs
- Use `get_job_logs` with `failed_only=true` and `return_content=true` to retrieve logs from failed jobs
- These tools provide direct access to workflow run details and logs without needing to manually check GitHub UI

2. **Running lintr locally**:
Expand All @@ -56,9 +95,162 @@ If the lint workflow fails with errors like "Could not find exported symbols for

4. **Alternative**: Move the package from `Suggests` to `Imports` if it's truly required for the package to function

## R Package Management

This repository uses `renv` for reproducible R package environments:

- Package versions are locked in `renv.lock`
- All workflows use `r-lib/actions/setup-renv@v2` for dependency installation
- CI dependencies (gh, lintr, purrr, pkgdown) are listed in DESCRIPTION Suggests

## System Dependencies

Some R packages require system-level libraries to compile from source:
- `curl` package requires `libcurl4-openssl-dev`
- `png` package requires `libpng-dev`
- `jpeg` package requires `libjpeg-dev`
- `systemfonts` package requires `libfontconfig1-dev`
- Consider using `rocker/verse` Docker image for workflows to reduce installation requirements

## JAGS Dependencies

This repository uses JAGS (Just Another Gibbs Sampler) for Bayesian analysis:
- JAGS must be installed in workflows that render Quarto documents
- JAGS must be installed in workflows that render Quarto documents (using `sudo apt-get install -y jags`)
- R packages `rjags` and `runjags` depend on JAGS being installed
- The lint workflow also needs these packages installed to avoid false positives

## Quarto Rendering

**CRITICAL REQUIREMENTS** before requesting code review:

1. **Run `quarto render` yourself locally** on the full repository and ensure it passes
2. **Verify it completes successfully** (exit code 0, no errors)
3. **Do NOT rely solely on CI workflows** to catch rendering issues
4. **Test the actual command and wait for completion** - do not assume success
5. **Check exit code to confirm success** - partial output doesn't count
6. **If quarto render fails locally**, investigate and fix the issue before pushing changes

**What "successful rendering" means**:
- The command completes without errors (exit code 0)
- All expected output files are generated
- No error messages in the output
- All documents render correctly (check for missing images, broken math, etc.)

**Common mistakes to avoid**:
- Testing individual files only (use `quarto render` for full repository)
- Not waiting for the command to complete
- Assuming success without checking the exit code
- Claiming "it works" without actually running the command
- Relying on CI to catch rendering issues

This ensures all dependencies are properly configured and all documents render successfully.

## Linting

**CRITICAL**: Always lint changed files before requesting code review and before committing.

```r
# Lint R code files you modified
lintr::lint("path/to/modified/file.R")

# Lint Quarto documents (lints R code chunks)
lintr::lint("path/to/modified/file.qmd")

# Lint all R files in the repository (use sparingly)
lintr::lint_dir()
```

**When to lint**:
- Before calling the `code_review` tool
- After making changes to R files (`.R`) or Quarto documents (`.qmd`)
- Before committing code changes

**Linting workflow for changed files**:
1. Identify which files you've changed
2. For `.R` files: Run `lintr::lint("filename.R")` on each changed file
3. For `.qmd` files: Run `lintr::lint("filename.qmd")` on each changed file to lint R code chunks
4. Fix any linting errors or warnings
5. Only then proceed to code review

**Important notes**:
- **Only fix lint issues in code you wrote or modified** - do not fix pre-existing issues in unchanged code
- If lint errors exist in code you didn't change, ignore them - they're not your responsibility
- The lint-changed-files workflow will flag issues, but you should catch them locally first

## Spell Checking

**CRITICAL**: Always run spellcheck locally BEFORE committing.

```r
# Run spell check on the entire repository
spelling::spell_check_package()

# Check specific files
spelling::spell_check_files("README.md")
spelling::spell_check_files("path/to/modified/file.qmd")
```

**Spell checking workflow**:
1. Identify which files you've changed
2. Run `spelling::spell_check_package()` to check all documentation
3. Review any spelling errors found
4. Either fix the spelling errors OR add legitimate technical terms to `inst/WORDLIST` (create this file if it doesn't exist, one word per line)
5. Re-run spell check to verify all errors are resolved
6. Only then proceed to code review or commit

**Important notes**:
- **Only fix spelling errors you introduced** - ignore pre-existing errors in unchanged files
- Add legitimate technical terms (e.g., "renv", "Bayesian", "MCMC") to `inst/WORDLIST`
- Don't add typos to the wordlist - fix the typos instead

## Code Review Workflow

**MANDATORY ORDER OF OPERATIONS** before finalizing a pull request:

1. **Lint changed files FIRST**
- Run `lintr::lint()` on all changed `.R` and `.qmd` files
- Fix any linting errors or warnings
- See the "Linting" section above for detailed commands

2. **Run spellcheck**
- Run `spelling::spell_check_package()`
- Fix spelling errors you introduced or add legitimate terms to `inst/WORDLIST`

3. **Then request code review**
- Use the `code_review` tool to get automated feedback
- The tool must be called AFTER linting and spellcheck are complete
- Review and address any valid comments from the code review

4. **Finally run security checks**
- Use the `codeql_checker` tool after code review
- Address any security vulnerabilities found
- Re-run if you make significant changes

**CRITICAL**: Never call `code_review` without linting and spell-checking changed files first. Linting and spell-checking catch basic issues that should be fixed before more comprehensive code review.

## Determining Responsibility for Workflow Failures

**IMPORTANT**: Not all workflow failures are your responsibility to fix.

**You ARE responsible for** fixing workflow failures if:
- The failure is in code or files you directly modified
- The failure is caused by changes you introduced (e.g., new dependencies, configuration changes)
- The error message indicates an issue with YOUR specific changes

**You are NOT responsible for** fixing workflow failures if:
- The failure is in pre-existing code you didn't modify
- Lint errors exist in unchanged files or unchanged sections of files
- Spelling errors exist in files you didn't modify
- The workflow itself has an environment or infrastructure issue (e.g., package installation failures, Docker issues)
- The error occurs in lines of code that existed before your changes

**How to determine responsibility**:
1. Check the workflow logs to identify which files/lines are causing the failure
2. Use `git diff` or `git show` to verify whether you modified those specific lines
3. If you only modified prose (text/comments) but errors are in code blocks, those are pre-existing
4. If the error is "file X line Y" and you didn't touch line Y, it's pre-existing

**What to do**:
- **If it's your responsibility**: Fix the issue and re-run the workflow
- **If it's NOT your responsibility**: Document it in your PR description and notify the repository maintainer
- **Never** fix unrelated pre-existing issues - focus on your changes only
3 changes: 3 additions & 0 deletions .github/workflows/check-spelling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ jobs:
with:
submodules: recursive

- name: Disable renv
run: echo "RENV_CONFIG_AUTOLOADER_ENABLED=FALSE" >> $GITHUB_ENV

- name: Run Spelling Check test
uses: insightsengineering/[email protected]
14 changes: 4 additions & 10 deletions .github/workflows/lint-changed-files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,12 @@ jobs:

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

- name: Install JAGS
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y jags

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::gh
any::lintr
any::purrr
dependencies: '"all"'
sudo apt-get install -y jags libcurl4-openssl-dev libpng-dev libfontconfig1-dev libjpeg-dev

- uses: r-lib/actions/setup-renv@v2

- name: Add lintr options
run: |
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,17 @@ jobs:
with:
use-public-rspm: true

- name: Install JAGS
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y jags
sudo apt-get install -y jags libcurl4-openssl-dev libpng-dev libfontconfig1-dev libjpeg-dev

- uses: r-lib/actions/setup-r-dependencies@HEAD
with:
needs: |
connect
website
extra-packages: |
local::.
any::pkgdown
- uses: r-lib/actions/setup-renv@v2

- name: Install local package
run: |
R CMD INSTALL .
shell: bash

- name: Render
if: github.event.action != 'closed' # skip the build if the PR has been closed
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,17 @@ jobs:
with:
use-public-rspm: true

- name: Install JAGS
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y jags
sudo apt-get install -y jags libcurl4-openssl-dev libpng-dev libfontconfig1-dev libjpeg-dev

- uses: r-lib/actions/setup-r-dependencies@HEAD
with:
needs: |
connect
website
extra-packages: |
local::.
any::pkgdown
- uses: r-lib/actions/setup-renv@v2

- name: Install local package
run: |
R CMD INSTALL .
shell: bash

- name: Render and Publish
uses: quarto-dev/quarto-actions/publish@HEAD
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,12 @@ rsconnect
!.github/copilot-instructions.md

**/*.quarto_ipynb

# renv files
renv/library/
renv/local/
renv/cellar/
renv/lock/
renv/python/
renv/sandbox/
renv/staging/
6 changes: 5 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ Suggests:
sjPlot,
equatiomatic,
broom (>= 1.0.8),
broom.helpers (>= 1.20.0)
broom.helpers (>= 1.20.0),
gh,
lintr,
purrr,
pkgdown
RoxygenNote: 7.3.3
License: MIT + file LICENSE
Config/build/copy-method: link
Expand Down
2 changes: 1 addition & 1 deletion dobson-stroke-bayes-Sec-14.6.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
library(dplyr)

library(reshape2)
stroke = melt(data=stroke.wide, id.vars=c('Subject','Group'),

Check warning on line 16 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=16,col=53,[quotes_linter] Only use double-quotes.

Check warning on line 16 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=16,col=53,[commas_linter] Put a space after a comma.

Check warning on line 16 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=16,col=43,[quotes_linter] Only use double-quotes.

Check warning on line 16 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=16,col=40,[infix_spaces_linter] Put spaces around all infix operators.

Check warning on line 16 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=16,col=19,[infix_spaces_linter] Put spaces around all infix operators.

Check warning on line 16 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=16,col=8,[assignment_linter] Use one of <-, <<- for assignment, not =.
value.name='ability', variable.name='week') |>

Check warning on line 17 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=17,col=51,[quotes_linter] Only use double-quotes.

Check warning on line 17 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=17,col=50,[infix_spaces_linter] Put spaces around all infix operators.

Check warning on line 17 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=17,col=26,[quotes_linter] Only use double-quotes.

Check warning on line 17 in dobson-stroke-bayes-Sec-14.6.qmd

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=dobson-stroke-bayes-Sec-14.6.qmd,line=17,col=25,[infix_spaces_linter] Put spaces around all infix operators.
mutate(
time = as.numeric(gsub('week', '', week)),
Group = as.numeric(as.factor(Group)),
Expand All @@ -26,7 +26,7 @@

```{r}
jags.post <- run.jags(
model = "inst/extdata/stroke.bugs.R",
model = "inst/extdata/stroke.bugs",
data = c(
stroke,
times = max(stroke$time),
Expand Down
4 changes: 0 additions & 4 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ Biostat
Epi
Github
Hua
LaTeX
MathJax
NoDerivatives
NonCommercial
Expand All @@ -12,9 +11,6 @@ UC
Zhou
callout
demstats
gitmodules
github
qmd
recurse
submodule
submodules
Loading
Loading