diff --git a/.github/actions/r-check-env/action.yaml b/.github/actions/r-check-env/action.yaml new file mode 100644 index 0000000..231c622 --- /dev/null +++ b/.github/actions/r-check-env/action.yaml @@ -0,0 +1,32 @@ +name: "Setup R check environment" +description: "Common R environment (Pandoc, system libs, R, renv) for R CMD check and Copilot" + +runs: + using: "composite" + steps: + - name: Setup Pandoc + uses: r-lib/actions/setup-pandoc@v2 + + - name: Install system libraries (Linux only) + if: runner.os == 'Linux' + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y \ + cmake \ + libcurl4-openssl-dev \ + libgit2-dev libssh2-1-dev libssl-dev \ + libfontconfig1-dev libfreetype6-dev libharfbuzz-dev libfribidi-dev \ + libpng-dev libtiff5-dev libjpeg-dev libcairo2-dev \ + libx11-dev \ + libxml2-dev + + - name: Setup R + uses: r-lib/actions/setup-r@v2 + with: + r-version: renv # pick R version from renv.lock + Ncpus: 6 + use-public-rspm: true # faster Linux binaries + + - name: Setup renv + uses: r-lib/actions/setup-renv@v2 diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..04cb16e --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,41 @@ +# Copilot Instructions + +## Goal +Maintain passing CI (lint, unit tests, R CMD check). +Automatically fix failing tests and re-run until green. + +## Stack +R (≥4.2.2), Shiny, renv, testthat (edition 3), lintr, GitHub Actions. + +## Code and Naming Conventions +- Use native pipe |>, line length ≤80 and indent of 4 spaces. +- Ideally, the body of a function/module fits within 50 lines and + should rarely exceed 100 lines. If it does, consider refactoring. +- Document all functions with roxygen2 headers. The header should end + with an @noRd tag unless they are @export ed. +- Maintain file naming consistent with existing structure. + +## Test Practices +- Add tests for new logic immediately. +- Name tests: tests/testthat/test_.R +- Individual files can be tested via devtools::test(filter = .R). +- Use mockery for external deps. +- If a test fails: inspect, patch code or tests, and + re-run devtools::test(filter = .R). + +#### Full check (= “green CI pipeline”) + +When working on an issue, *before* creating a Pull Request, +you MUST follow these steps: + +1) `lintr::lint_package()` — fix all lints. +2) `devtools::test()` — fix failing tests. +3) `rcmdcheck::rcmdcheck(args='--no-manual', error_on='warning')` — fix all errors/warnings. + +Target in step 3: **0 errors / 0 warnings** (notes preferably 0). + +If you are unable to fix all issues within **45 minutes**, +commit your latest changes, then stop, and do *not* open a PR. + +## Commit Messages +Conventional commits (feat:, fix:, test:, refactor:, docs:). diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 424270b..d8f2f3c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,10 +28,12 @@ jobs: r-version: renv # pick R version from renv.lock Ncpus: 6 use-public-rspm: true + - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: any::lintr needs: lintr + - name: Lint shell: Rscript {0} run: | @@ -62,37 +64,13 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] + steps: - uses: actions/checkout@v4 with: lfs: true - # Pandoc for rmarkdown/knitr/pkgdown/vignettes - - uses: r-lib/actions/setup-pandoc@v2 - - - name: Install system libraries - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y \ - cmake \ - libcurl4-openssl-dev \ - libgit2-dev libssh2-1-dev libssl-dev \ - libfontconfig1-dev libfreetype6-dev libharfbuzz-dev libfribidi-dev \ - libpng-dev libtiff5-dev libjpeg-dev libcairo2-dev \ - libx11-dev \ - libxml2-dev - - - name: Setup R - uses: r-lib/actions/setup-r@v2 - with: - r-version: renv # pick R version from renv.lock - Ncpus: 6 - use-public-rspm: true # faster Linux binaries - # working-directory: . # set if renv.lock is not at repo root - - - name: Setup renv - uses: r-lib/actions/setup-renv@v2 + - uses: ./.github/actions/r-check-env - name: R CMD check with renv-pinned deps shell: Rscript {0} @@ -106,7 +84,6 @@ jobs: TESTTHAT_CPUS: 6 _R_CHECK_LIMIT_CORES_: FALSE # allow more than 2 cores - - name: R CMD check against current CRAN uses: r-lib/actions/check-r-package@v2 with: diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 0000000..dda05cd --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,26 @@ +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. In addition, the setup steps +# are run each time before Copilot starts working independently from below filters. +on: + workflow_dispatch: + push: + paths: + - .github/workflows/copilot-setup-steps.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + + +jobs: + copilot-setup-steps: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + with: + lfs: true + + - uses: ./.github/actions/r-check-env