diff --git a/.Rbuildignore b/.Rbuildignore index 6e6438d..71e8dee 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,8 @@ ^docs$ ^pkgdown$ ^\.github$ + +# Tech stack +^\.devcontainer$ +^\.vscode$ +^\.github$ diff --git a/.devcontainer/.vscode/settings.json b/.devcontainer/.vscode/settings.json new file mode 100644 index 0000000..cbd71a7 --- /dev/null +++ b/.devcontainer/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "r.plot.useHttpgd": true, + "r.alwaysUseActiveTerminal": true +} diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile new file mode 100644 index 0000000..d80c90d --- /dev/null +++ b/.devcontainer/Containerfile @@ -0,0 +1,43 @@ +FROM ghcr.io/rocker-org/devcontainer/r-ver:4.5 + +# Architecture-specific variable (built in Docker BuildKit) +ARG TARGETARCH + +# Runtime dependency for R package 'fs' (provides libuv.so.1) +RUN apt-get update && \ + apt-get install -y --no-install-recommends libuv1t64 && \ + rm -rf /var/lib/apt/lists/* + +# Install quarto-cli and the orange-book extension +RUN wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.9.35/quarto-1.9.35-linux-${TARGETARCH}.deb && \ + dpkg -i quarto-1.9.35-linux-${TARGETARCH}.deb && \ + rm quarto-1.9.35-linux-${TARGETARCH}.deb + +# Adding R packages +RUN install2.r --error fable \ + fabletools \ + progressr \ + feasts \ + tsibble \ + dplyr \ + tidyr \ + ggplot2 \ + distributional \ + epidatr \ + rlang \ + EpiEstim \ + projections \ + incidence \ + jsonlite \ + baselinenowcast \ + DiagrammeR \ + knitr \ + rmarkdown \ + devtools \ + pipetime \ + fable.prophet \ + testthat + +RUN installGithub.r hubverse-org/hubEvals + +CMD ["bash"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..3f1b0df --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,42 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/cpp +{ + "name": "ACCIDDA - acciddasuite", + "build": { + "dockerfile": "Containerfile" + }, + "customizations": { + "vscode": { + "extensions": [ + "reditorsupport.r", + "rdebugger.r-debugger", + "quarto.quarto", + "tianyishi.rmarkdown", + "github.vscode-github-actions", + "ms-vscode.live-server" + ] + } + }, + "mounts": [ + // Mount the .vscode configuration into the container + "source=${localWorkspaceFolder}/.devcontainer/.vscode,target=/workspaces/${localWorkspaceFolderBasename}/.vscode,type=bind,consistency=cached" + ], + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + "ghcr.io/devcontainers/features/github-cli:1": { + "version": "2.68.1" + } + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "gcc -v", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + "remoteUser": "root" +} diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml new file mode 100644 index 0000000..7bd9eef --- /dev/null +++ b/.github/workflows/copilot-setup-steps.yml @@ -0,0 +1,42 @@ +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: + # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. + contents: read + + # You can define any steps you want, and they will run before the agent starts. + # If you do not check out your code, Copilot will do this for you. + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up R + uses: r-lib/actions/setup-r@v2 + with: + r-version: 'release' + + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: | + any::rcmdcheck + any::testthat + needs: check diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml new file mode 100644 index 0000000..3432d38 --- /dev/null +++ b/.github/workflows/coverage.yaml @@ -0,0 +1,39 @@ +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: Coverage + +jobs: + coverage: + runs-on: ubuntu-latest + name: Coverage + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2.9.0 + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: | + any::covr + needs: check + + - name: Running coverage + run: | + # Files to exclude + files <- list.files("inst/", full.names = TRUE, recursive = TRUE) + + # Run coverage + covr::codecov( + line_exclusions = as.list(files), + token = Sys.getenv("CODECOV_TOKEN") + ) + shell: Rscript {0} + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index bfc9f4d..96976d0 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -10,7 +10,9 @@ on: name: pkgdown.yaml -permissions: read-all +permissions: + read-all: + pull-requests: write jobs: pkgdown: @@ -40,6 +42,23 @@ jobs: run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} + # Upload artifact for PR preview (only for pull requests) + - name: Upload PR artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v4 + with: + name: pkgdown-site + path: docs + + # Post comment with link to artifact on PRs + - name: Post artifact link to PR + if: github.event_name == 'pull_request' + uses: CDCgov/cfa-actions/post-artifact@v1.2.0 + with: + artifact-name: pkgdown-site + gh-token: ${{ secrets.GITHUB_TOKEN }} + message: 'Thank you for your contribution @${{ github.actor }} :rocket:! The pkgdown site preview is ready for review :point_right: [Download here]({ artifact-url }) :point_left:!' + - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' uses: JamesIves/github-pages-deploy-action@v4.5.0 diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml new file mode 100644 index 0000000..24e1083 --- /dev/null +++ b/.github/workflows/r.yml @@ -0,0 +1,99 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +# +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check-final + +env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + +jobs: + + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macOS-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + # - {os: macOS-latest, r: 'devel', http-user-agent: 'release'} + - {os: windows-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v6 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: quarto-dev/quarto-actions/setup@v2.2.0 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tinytex: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + install-quarto: false + install-pandoc: false + extra-packages: + any::rcmdcheck + any::testthat + needs: check + + - uses: r-lib/actions/check-r-package@v2 + if: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.r == 'release' }} + with: + args: 'c("--as-cran", "--no-manual")' + upload-snapshots: false + upload-results: false + check-dir: '"check"' + error-on: '"warning"' + + - uses: r-lib/actions/check-r-package@v2 + if: ${{ matrix.config.os != 'windows-latest' && (matrix.config.os != 'ubuntu-latest' || matrix.config.r != 'release') }} + with: + upload-snapshots: false + upload-results: false + check-dir: '"check"' + error-on: '"warning"' + + - name: Check package (Windows) + if: ${{ matrix.config.os == 'windows-latest' }} + run: | + R.exe CMD build . + R.exe CMD check --no-manual (Get-Item acciddasuite_*.tar.gz).Name + shell: pwsh + + - name: Build the package + if: ${{ matrix.config.os == 'ubuntu-latest' && (matrix.config.r == 'release' || matrix.config.r == 'devel') }} + run: R CMD build . + + - uses: actions/upload-artifact@v4 + if: ${{ matrix.config.os == 'ubuntu-latest' && (matrix.config.r == 'release' || matrix.config.r == 'devel') }} + with: + name: acciddasuite-built-package-${{ matrix.config.os }}-${{ matrix.config.r }} + path: acciddasuite_*.tar.gz + retention-days: 7 + diff --git a/.gitignore b/.gitignore index e09b039..eff3778 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ docs .Ruserdata **/*.quarto_ipynb +.vscode/ +*.html diff --git a/README.Rmd b/README.Rmd index 57aaddd..12c7faf 100644 --- a/README.Rmd +++ b/README.Rmd @@ -4,6 +4,13 @@ output: github_document +```{=markdown} +[![R-CMD-check](https://github.com/ACCIDDA/acciddasuite/actions/workflows/r.yml/badge.svg)](https://github.com/ACCIDDA/acciddasuite/actions/workflows/r.yml) +[![codecov](https://codecov.io/gh/ACCIDDA/acciddasuite/graph/badge.svg?token=ZB8FVLI7GN)](https://app.codecov.io/gh/ACCIDDA/acciddasuite) +[![status](https://tinyverse.netlify.app/badge/acciddasuite)](https://CRAN.R-project.org/package=acciddasuite) +``` + + ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, diff --git a/README.md b/README.md index 1720174..011d8ae 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ +[![R-CMD-check](https://github.com/ACCIDDA/acciddasuite/actions/workflows/r.yml/badge.svg)](https://github.com/ACCIDDA/acciddasuite/actions/workflows/r.yml) +[![codecov](https://codecov.io/gh/ACCIDDA/acciddasuite/graph/badge.svg?token=ZB8FVLI7GN)](https://app.codecov.io/gh/ACCIDDA/acciddasuite) +[![status](https://tinyverse.netlify.app/badge/acciddasuite)](https://CRAN.R-project.org/package=acciddasuite) + + + # acciddasuite acciddasuite website @@ -48,6 +54,20 @@ fcast <- example_data |> ) #> ℹ Using max_delay = 12 from data #> ℹ Truncating from max_delay = 12 to 4. +#> Warning: 1 error encountered for ARIMA +#> [1] +#> ℹ Some rows containing NA values may be removed. This is fine if not +#> unexpected. +#> ℹ Some rows containing NA values may be removed. This is fine if not +#> unexpected. +#> Warning: 1 error encountered for ARIMA +#> [1] +#> +#> 1 error encountered for ARIMA +#> [1] +#> +#> 1 error encountered for ARIMA +#> [1] ``` ``` r diff --git a/man/figures/README-unnamed-chunk-5-1.png b/man/figures/README-unnamed-chunk-5-1.png index d5076a8..e7e7ce9 100644 Binary files a/man/figures/README-unnamed-chunk-5-1.png and b/man/figures/README-unnamed-chunk-5-1.png differ