Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
612facc
Delete .DS_Store
JuanLiOHRI Jul 10, 2025
cb3c1ff
Delete Note- cchsflow.docx
JuanLiOHRI Jul 10, 2025
ed742c4
Merge branch 'master' of https://github.com/JuanLiOHRI/mock-data
JuanLiOHRI Jul 10, 2025
562541d
Test creating mock data for DemPoRT
JuanLiOHRI Jul 31, 2025
8decd27
update
JuanLiOHRI Jul 31, 2025
4f540f5
test
JuanLiOHRI Oct 1, 2025
ecc9e6d
test
JuanLiOHRI Oct 1, 2025
3965e93
test
JuanLiOHRI Oct 1, 2025
159dd99
Create README.md
JuanLiOHRI Oct 15, 2025
f2cdf9d
test
JuanLiOHRI Oct 15, 2025
d0ffc25
Merge branch 'master' of https://github.com/Big-Life-Lab/MockData
JuanLiOHRI Oct 15, 2025
f13d003
test
JuanLiOHRI Oct 15, 2025
f34c271
10-15
JuanLiOHRI Oct 15, 2025
c29da49
Repatriate mockdata functions from chmsflow as R package
DougManuel Oct 20, 2025
a202107
Add testing infrastructure and fix R CMD check issues
DougManuel Oct 20, 2025
5c9fae6
Remove duplicate function files
DougManuel Oct 20, 2025
7f5a1b6
Refactor MockData to R package
DougManuel Oct 21, 2025
903eeb3
change variables in example
reikookamoto Oct 21, 2025
d0729c6
Merge pull request #2 from Big-Life-Lab/update-readme
DougManuel Oct 21, 2025
87d2c86
Fix documentation examples and improve README clarity
DougManuel Oct 21, 2025
6f06e69
init create-date-var
reikookamoto Oct 23, 2025
b6afc10
init test for create_date_var
reikookamoto Oct 28, 2025
daf8251
add more code to create-date-var
reikookamoto Oct 29, 2025
d8e7965
uncomment tests
reikookamoto Oct 29, 2025
bf09295
Merge pull request #3 from Big-Life-Lab/package-repatriation
JuanLiOHRI Oct 29, 2025
3c60f06
Add complete date variable generation with survival distributions
DougManuel Oct 31, 2025
d02bc2f
feat: implement v0.2 configuration format with date variables and com…
DougManuel Nov 7, 2025
82ff177
feat: release v0.3.0 - unified garbage API and comprehensive test cov…
DougManuel Nov 18, 2025
0d15a59
chore: resolve merge conflicts with origin/create-date-var
DougManuel Nov 18, 2025
38b21d2
chore: remove legacy vignettes dates.qmd and tutorial-config-files.qmd
DougManuel Nov 18, 2025
7f1867f
removed news versions that were never released
DougManuel Nov 18, 2025
ce01049
chore: update deploy workflow branches
DougManuel Nov 24, 2025
76a4bb7
fix: add create_survival_dates to pkgdown reference index
DougManuel Nov 24, 2025
56cf088
feat: add deployment summary to manual deploy workflow
DougManuel Nov 24, 2025
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
Binary file removed .DS_Store
Binary file not shown.
28 changes: 28 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
^renv$
^renv\.lock$
^.*\.Rproj$
^\.Rproj\.user$
^\.DS_Store$
^\.git$
^\.github$
^\.claude$
^mockdata-tools$
^CODE_OF_CONDUCT\.md$
^CONTRIBUTING\.md$
^NEWS\.md$
^\.tmp$
^check_output.*\.txt$
^R_CMD_CHECK_FIXES\.md$
^CRITICAL_ISSUE_create_mock_data\.md$
^PKGDOWN_FIX_SUMMARY\.md$
^PKGDOWN_SETUP\.md$
^SURVIVAL_SECTION_IMPLEMENTED\.md$
^PR_REVIEW_STATUS\.md$
^PR_REVIEW_RESPONSE\.md$
^PR_DESCRIPTION_ADDENDUM\.md$
^REVIEWER_QUICKSTART\.md$
^LOCAL_TESTING_GUIDE\.md$
^docs$
^_pkgdown\.yml$
^development$
^\.claude$
1 change: 1 addition & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source("renv/activate.R")
250 changes: 250 additions & 0 deletions .claude/AI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
# MockData - AI Development Guidelines

## R package development with pkgdown + Quarto + renv

### Context: Cutting-edge stack (2024-2025)

This project uses a relatively new combination:
- **pkgdown** for R package documentation sites
- **Quarto .qmd vignettes** (replacing traditional .Rmd)
- **renv** for reproducible dependency management
- **GitHub Actions** for automated deployment

This stack is newer than most online resources, so documented patterns are limited.

### Critical: renv snapshot configuration

**Problem**: Default `renv::snapshot()` only captures packages used in `R/` code, missing:
- DESCRIPTION Suggests field (pkgdown, quarto, devtools, roxygen2)
- Packages used only in vignettes (dplyr, stringr, lubridate)

**Solution**: Configure renv to capture ALL dependencies

```r
# Set snapshot type to "all" (persists in project settings)
renv::settings$snapshot.type("all")

# Snapshot with all DESCRIPTION dependencies
renv::snapshot()
```

**Result**: renv.lock now contains ~124 packages instead of just renv itself.

### Simplified GitHub Actions workflow

With complete renv.lock, the workflow is straightforward:

```yaml
- name: Install renv
run: Rscript -e "install.packages('renv')"

- name: Restore R packages with renv
run: Rscript -e "renv::restore(prompt = FALSE)"

- name: Build and install MockData package
run: |
Rscript -e "roxygen2::roxygenize()"
R CMD INSTALL .

- name: Build pkgdown site
run: Rscript -e 'pkgdown::build_site(new_process = FALSE)'
```

**No manual package installations needed.**
**No R_LIBS_USER path manipulation needed.**

### When to update renv.lock

```r
# After adding packages to DESCRIPTION
renv::snapshot()

# After removing packages from DESCRIPTION
renv::snapshot()

# To check what changed
renv::status()
```

### Known issues with pkgdown + Quarto

From official pkgdown documentation (as of 2025):
- Callouts not currently supported in Quarto vignettes
- Only HTML vignettes work (requires `minimal: true` in Quarto format)
- External files in vignettes/ may not be copied during rendering
- Mermaid diagrams require custom CSS instead of quarto themes

### Debugging tips

If vignettes fail to render:
```r
# Enable Quarto debugging
options(quarto.log.debug = TRUE)
pkgdown::build_site()
```

Check that all vignette dependencies are in DESCRIPTION Suggests and renv.lock.

### Debugging GitHub Actions failures: Lessons learned (2025-01-07)

**Context**: 10+ hour debugging session to fix "System command 'quarto' failed" error in GitHub Actions.

#### Start with minimal examples and successful patterns

**DON'T**: Try to debug complex failures in GitHub Actions directly
**DO**: Build from working examples (chmsflow, popcorn-data) and test locally first

**Minimal working workflow pattern**:

```yaml
name: pkgdown

on:
push:
branches: [main] # Don't include feature branches - causes duplicate runs with PRs
pull_request:
branches: [main]
workflow_dispatch:

permissions:
contents: write

jobs:
pkgdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install Quarto
uses: quarto-dev/quarto-actions/setup@v2

- name: Install roxygen2
run: Rscript -e "install.packages('roxygen2')"

- name: Generate documentation
run: Rscript -e "roxygen2::roxygenize()"

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

# Debug step - render single vignette to isolate failures
- name: Test render single vignette
run: quarto render vignettes/getting-started.qmd --to html
continue-on-error: true

- name: Build pkgdown site
run: |
options(rlib_message_verbosity = "verbose")
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, quiet = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub Pages
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs
branch: gh-pages
target-folder: .
clean: false
```

#### Critical debugging principles

1. **Make errors visible**
- Set `quiet = FALSE` in `build_site_github_pages()`
- Add `continue-on-error: true` test steps to see actual failures
- Use `options(rlib_message_verbosity = "verbose")`

2. **Test incrementally**
- Render one vignette at a time to isolate failures
- Test locally first: `quarto render vignettes/example.qmd --to html`
- Compare with working repos (chmsflow, popcorn-data)

3. **Environment differences matter**
- **Locales**: `en_CA` works on macOS but NOT on Ubuntu GitHub Actions
- **Solution**: Use `en_US.UTF-8` for cross-platform compatibility
- **Example**: `lubridate::parse_date_time(..., locale = "en_US.UTF-8")`

4. **Avoid duplicate workflow runs**
- **DON'T**: `push: branches: [main, feature-branch]`
- **DO**: `push: branches: [main]`
- **Why**: PRs already trigger on `pull_request` event

5. **Use r-lib actions for dependency management**
- Prefer `r-lib/actions/setup-r-dependencies@v2` over manual renv
- Let `setup-r-dependencies` handle dependency installation
- **Always generate documentation first** with `roxygen2::roxygenize()`

#### Common pitfalls

1. **Generic error messages**: "System command 'quarto' failed" tells you nothing
- **Fix**: Add `quiet = FALSE` to see actual errors

2. **Locale issues**: Hardcoded locales fail in CI/CD
- **Fix**: Use `en_US.UTF-8` instead of `en_CA`

3. **Missing documentation**: pkgdown can't find topics if man/ files don't exist
- **Fix**: Run `roxygen2::roxygenize()` before building site

4. **Vignette dependencies**: Packages used only in vignettes must be in DESCRIPTION
- **Fix**: Add to Suggests field, then `renv::snapshot()`

#### Quick diagnostic checklist

When GitHub Actions fails:

- [ ] Test locally: `pkgdown::build_site()`
- [ ] Render vignettes individually: `quarto render vignettes/example.qmd --to html`
- [ ] Check for hardcoded locales (use `en_US.UTF-8`)
- [ ] Verify all vignette packages in DESCRIPTION Suggests
- [ ] Add `quiet = FALSE` to see actual error messages
- [ ] Compare workflow with working repos (chmsflow)
- [ ] Check for duplicate triggers (push + pull_request)

#### GitHub Pages deployment tips

**Start early**: Set up GitHub Pages deployment from the beginning, not as an afterthought.

**Multi-branch deployment pattern**:

```yaml
- name: Determine deployment path
id: deploy-path
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
echo "target_path=." >> $GITHUB_OUTPUT
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
echo "target_path=dev" >> $GITHUB_OUTPUT
else
echo "target_path=preview/${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs
branch: gh-pages
target-folder: ${{ steps.deploy-path.outputs.target_path }}
clean: false
```

**Result**:
- `main` → https://yoursite.github.io/repo/
- `dev` → https://yoursite.github.io/repo/dev/
- Other branches → https://yoursite.github.io/repo/preview/branch-name/

### References

- [pkgdown Quarto vignettes documentation](https://pkgdown.r-lib.org/articles/quarto.html)
- [renv CI/CD guide](https://rstudio.github.io/renv/articles/ci.html)
- [Quarto with renv discussion](https://github.com/quarto-dev/quarto-cli/discussions/9150)
- [r-lib/actions GitHub repository](https://github.com/r-lib/actions)
88 changes: 88 additions & 0 deletions .github/workflows/deploy-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy'
required: true
default: 'v030-refactor'
type: choice
options:
- main
- v030-refactor
target:
description: 'Deployment target (root, dev, or custom path)'
required: true
default: 'dev'
type: string

name: Manual Deploy

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

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

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- name: Install Quarto
uses: quarto-dev/quarto-actions/setup@v2

- name: Install roxygen2
run: Rscript -e "install.packages('roxygen2')"

- name: Generate documentation
run: Rscript -e "roxygen2::roxygenize()"

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

- name: Build pkgdown site
run: |
options(rlib_message_verbosity = "verbose")
pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE, quiet = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs
branch: gh-pages
target-folder: ${{ inputs.target }}
clean: false

- name: Deployment Summary
run: |
if [ "${{ inputs.target }}" = "." ]; then
TARGET_PATH=""
TARGET_DESC="root"
else
TARGET_PATH="${{ inputs.target }}/"
TARGET_DESC="${{ inputs.target }}"
fi

echo "## 🚀 Deployment Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Setting | Value |" >> $GITHUB_STEP_SUMMARY
echo "|---------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| **Branch** | \`${{ inputs.branch }}\` |" >> $GITHUB_STEP_SUMMARY
echo "| **Target** | \`${TARGET_DESC}\` |" >> $GITHUB_STEP_SUMMARY
echo "| **URL** | https://big-life-lab.github.io/MockData/${TARGET_PATH} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### ℹ️ Target options" >> $GITHUB_STEP_SUMMARY
echo "- Use \`.\` to deploy to the site root" >> $GITHUB_STEP_SUMMARY
echo "- Use \`dev\` or other path for subfolder deployment" >> $GITHUB_STEP_SUMMARY
Loading