diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 6c71eb9b..62b0eff0 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -63,11 +63,9 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes - # Exists since R 4.3.0 but `false` by default - _R_CHECK_LENGTH_COLON_: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 diff --git a/.github/workflows/dependency-change.yaml b/.github/workflows/dependency-change.yaml index 1250c8a5..ef26e664 100644 --- a/.github/workflows/dependency-change.yaml +++ b/.github/workflows/dependency-change.yaml @@ -52,6 +52,12 @@ jobs: message("Dependencies have changed! Analyzing...") + if (nrow(deps_added) > 0) { + nudge <- "Reach out on slack (`#code-review` or `#help` channels) to double check if there are base R alternatives to the new dependencies.\n" + } else { + nudge <- "" + } + msg <- glue::glue( .sep = "\n", "This pull request:", @@ -60,7 +66,8 @@ jobs: "- Removes {nrow(deps_removed)} existing dependencies (direct and indirect)", "- Removes {length(unique(deps_removed$sysreqs))} existing system dependencies", "", - "(Note that results may be inacurrate if you branched from an outdated version of the target branch.)" + nudge, + "(Note that results may be inaccurate if you branched from an outdated version of the target branch.)" ) message("Posting results as a pull request comment.") diff --git a/.github/workflows/lint-changed-files.yaml b/.github/workflows/lint-changed-files.yaml index 2029b9dd..cf5c34b6 100644 --- a/.github/workflows/lint-changed-files.yaml +++ b/.github/workflows/lint-changed-files.yaml @@ -4,6 +4,11 @@ on: workflow_dispatch: pull_request: branches: [main, master] + paths: + - '**.R' + - '**.Rmd' + - '**/.lintr' + - '**/.lintr.R' name: lint-changed-files @@ -17,7 +22,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 with: @@ -29,6 +34,7 @@ jobs: any::gh any::lintr any::purrr + any::cyclocomp epiverse-trace/etdev needs: check diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index c09f1b0c..fc978437 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -54,7 +54,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 @@ -71,9 +71,14 @@ jobs: run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} + - name: Check website links + uses: untitaker/hyperlink@0.1.32 + with: + args: docs/ + - name: Deploy to GitHub pages 🚀 if: github.event_name != 'merge_group' && github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@4.1.4 + uses: JamesIves/github-pages-deploy-action@v4.6.1 with: # We clean on releases because we want to remove old vignettes, # figures, etc. that have been deleted from the `main` branch. diff --git a/.github/workflows/render_readme.yml b/.github/workflows/render_readme.yml index 54956a51..10f5eaad 100644 --- a/.github/workflows/render_readme.yml +++ b/.github/workflows/render_readme.yml @@ -1,26 +1,55 @@ -# Name of the workflow +# Reproduce locally by running: +# ```r +# pak::pak(c("any::rmarkdown", "any::usethis", ".")) +# writeLines( +# knitr::knit_expand( +# "README.Rmd", +# packagename = read.dcf("DESCRIPTION", "Package"), +# gh_repo = usethis:::github_remote_list()$repo_spec +# ), +# "README_expanded.Rmd" +# ) +# rmarkdown::render( +# "README_expanded.Rmd", +# output_file = "README.md", +# output_dir = "." +# ) +# unlink("README_expanded.Rmd") +# ``` name: render-readme # Controls when the action will run. Triggers include: -# +# # - button trigger from github action page # - on changes to readme.Rmd on: workflow_dispatch: push: + branches: + # This may seem like a no-op but it prevents triggering on tags + # We use '**' rather '*' to accomodate names like 'dev/branch-1' + - '**' paths: - 'README.Rmd' + - '.github/workflows/render_readme.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: render-readme: - runs-on: macos-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repos - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup R uses: r-lib/actions/setup-r@v2 @@ -29,25 +58,29 @@ jobs: - name: Setup pandoc uses: r-lib/actions/setup-pandoc@v2 - + - name: Install dependencies uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: any::rmarkdown, local::. - + - name: Compile the readme run: | writeLines( knitr::knit_expand( - "README.Rmd", - packagename = read.dcf("DESCRIPTION", "Package"), + "README.Rmd", + packagename = read.dcf("DESCRIPTION", "Package"), gh_repo = Sys.getenv("GITHUB_REPOSITORY") - ), + ), "README_expanded.Rmd" ) - rmarkdown::render("README_expanded.Rmd", output_file = "README.md", output_dir = ".") + rmarkdown::render( + "README_expanded.Rmd", + output_file = "README.md", + output_dir = "." + ) shell: Rscript {0} - + - name: Commit files run: | git config --local user.email "action@github.com" @@ -59,4 +92,5 @@ jobs: git add man/figures/ fi git diff-index --quiet HEAD || git commit -m "Automatic readme update" + git pull --rebase origin ${{ github.ref.name }} git push origin || echo "No changes to push" diff --git a/.github/workflows/update-citation-cff.yaml b/.github/workflows/update-citation-cff.yaml index 9926f8d7..82b118a0 100644 --- a/.github/workflows/update-citation-cff.yaml +++ b/.github/workflows/update-citation-cff.yaml @@ -6,9 +6,7 @@ on: push: branches: - # This may seem like a no-op but it prevents triggering on tags. - # We use '**' rather '*' to accomodate names like 'dev/branch-1' - - '**' + - main paths: - DESCRIPTION - inst/CITATION @@ -16,13 +14,9 @@ on: workflow_dispatch: name: Update CITATION.cff - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - permissions: contents: write + pull-requests: write jobs: update-citation-cff: @@ -30,7 +24,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 - uses: r-lib/actions/setup-r-dependencies@v2 with: @@ -53,12 +47,13 @@ jobs: cff_write(keys = mykeys) shell: Rscript {0} + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + commit-message: Update `CITATION.cff` + title: Update `CITATION.cff` + body: | + This pull request updates the citation file, ensuring all authors are credited and there are no discrepancies. - - name: Commit results - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add CITATION.cff - git commit -m 'Update CITATION.cff' || echo "No changes to commit" - git pull --rebase origin ${{ github.ref.name }} - git push origin || echo "No changes to commit" + Please verify the changes before merging. + branch: update-citation-cff diff --git a/.github/workflows/update-copyright-year.yml b/.github/workflows/update-copyright-year.yml new file mode 100644 index 00000000..b4633b3c --- /dev/null +++ b/.github/workflows/update-copyright-year.yml @@ -0,0 +1,37 @@ +name: Update copyright year(s) in license file + +on: + workflow_dispatch: + schedule: + - cron: '0 3 1 1 *' + +permissions: + contents: write + pull-requests: write + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: FantasticFiasco/action-update-license-year@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + path: | + LICENSE.md + prBody: > + This PR updates the copyright license for this new year! If you're reading this while you're celebrating, enjoy! Don't worry about this one :blush: + + ![Happy new year!](https://media.giphy.com/media/HyDfNCZlTn5iU/giphy.gif?cid=ecf05e4777yl7dbo1xfha6bx1z5lrl13uq7biv6rs9dqsyoh&ep=v1_gifs_search&rid=giphy.gif&ct=g) + - uses: FantasticFiasco/action-update-license-year@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + path: | + LICENSE + prBody: > + This PR updates the copyright license for this new year! If you're reading this while you're celebrating, enjoy! Don't worry about this one :blush: + + ![Happy new year!](https://media.giphy.com/media/HyDfNCZlTn5iU/giphy.gif?cid=ecf05e4777yl7dbo1xfha6bx1z5lrl13uq7biv6rs9dqsyoh&ep=v1_gifs_search&rid=giphy.gif&ct=g) + transform: (?<=YEAR:\s)(?\d{4})?-?(\d{4})? diff --git a/DESCRIPTION b/DESCRIPTION index 430220ec..823e0315 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,13 +2,13 @@ Package: finalsize Title: Calculate the Final Size of an Epidemic Version: 0.2.1.9000 Authors@R: c( - person("Pratik", "Gupte", , "pratik.gupte@lshtm.ac.uk", role = c("aut", "cre", "cph"), + person("Pratik", "Gupte", , "pratik.gupte@lshtm.ac.uk", role = c("aut", "cph"), comment = c(ORCID = "0000-0001-5294-7819")), person("Edwin", "Van Leeuwen", , "edwin.vanleeuwen@ukhsa.gov.uk", role = c("aut", "cph"), comment = c(ORCID = "0000-0002-2383-5305")), person("Adam", "Kucharski", , "adam.kucharski@lshtm.ac.uk", role = c("aut", "cph"), comment = c(ORCID = "0000-0001-8814-9421")), - person("Rosalind", "Eggo", , "r.eggo@lshtm.ac.uk", role = "ctb", + person("Rosalind", "Eggo", , "r.eggo@lshtm.ac.uk", role = c("ctb", "cre"), comment = c(ORCID = "0000-0002-0362-6717")), person("Hugo", "Gruson", , "hugo.gruson@data.org", role = "ctb", comment = c(ORCID = "0000-0002-4094-1476")), @@ -61,4 +61,4 @@ Encoding: UTF-8 Language: en-GB LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 diff --git a/LICENSE b/LICENSE index 2b87508f..12fd7cf0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ -YEAR: 2022 +YEAR: 2024 COPYRIGHT HOLDER: finalsize authors diff --git a/LICENSE.md b/LICENSE.md index bcfdf037..5ffba23d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # MIT License -Copyright (c) 2022 finalsize authors +Copyright (c) 2024 finalsize authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/NEWS.md b/NEWS.md index 9e9f81ca..38c3b272 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,17 @@ # finalsize (development version) +Maintainer is changing to @rozeggo (#212). + +1. Updated all GitHub Actions workflows in line with {epiverse-trace/packagetemplate} (#212). + +2. Updated DESCRIPTION and license files with new maintainer and new copyright year (#212). + +3. Added `R/dev-utils.R` for extra release issue bullet points, and added `tools/check.env` for global environment checks (#212). + +4. Corrected internal article links in vignettes (#212). + +5. Added continuous benchmarking workflows using {touchstone} following the pattern of {epiforecasts/EpiNow2} (#212). + # finalsize 0.2.1 This patch adds: diff --git a/R/dev-utils.R b/R/dev-utils.R new file mode 100644 index 00000000..b97ea346 --- /dev/null +++ b/R/dev-utils.R @@ -0,0 +1,8 @@ +# This unexported function adds a custom item to `usethis::use_release_issue()` +release_bullets <- function() { + c( + "Run `goodpractice::gp()`", + "Review [WORDLIST](https://docs.cran.dev/spelling#wordlist)", + "Check if `# nolint` comments are still needed with recent lintr releases" + ) +} diff --git a/README.md b/README.md index d9a45cbe..d2d808e2 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ citation("finalsize") #> To cite package 'finalsize' in publications use: #> #> Gupte P, Van Leeuwen E, Kucharski A (2024). _finalsize: Calculate the -#> Final Size of an Epidemic_. R package version 0.2.1, +#> Final Size of an Epidemic_. R package version 0.2.1.9000, #> https://epiverse-trace.github.io/finalsize/, #> . #> @@ -194,7 +194,7 @@ citation("finalsize") #> title = {finalsize: Calculate the Final Size of an Epidemic}, #> author = {Pratik Gupte and Edwin {Van Leeuwen} and Adam Kucharski}, #> year = {2024}, -#> note = {R package version 0.2.1, +#> note = {R package version 0.2.1.9000, #> https://epiverse-trace.github.io/finalsize/}, #> url = {https://github.com/epiverse-trace/finalsize}, #> } diff --git a/inst/WORDLIST b/inst/WORDLIST index 9006beef..528e89ce 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -7,6 +7,7 @@ Cppcheck Cpplint Dylanger Eigen +EpiNow Epiverse Github Kwok @@ -41,7 +42,9 @@ doi dt dx eff +epiforecasts episoap +epiverse frac gh github diff --git a/man/finalsize-package.Rd b/man/finalsize-package.Rd index 82f5590f..115109ed 100644 --- a/man/finalsize-package.Rd +++ b/man/finalsize-package.Rd @@ -18,17 +18,17 @@ Useful links: } \author{ -\strong{Maintainer}: Pratik Gupte \email{pratik.gupte@lshtm.ac.uk} (\href{https://orcid.org/0000-0001-5294-7819}{ORCID}) [copyright holder] +\strong{Maintainer}: Rosalind Eggo \email{r.eggo@lshtm.ac.uk} (\href{https://orcid.org/0000-0002-0362-6717}{ORCID}) [contributor] Authors: \itemize{ + \item Pratik Gupte \email{pratik.gupte@lshtm.ac.uk} (\href{https://orcid.org/0000-0001-5294-7819}{ORCID}) [copyright holder] \item Edwin Van Leeuwen \email{edwin.vanleeuwen@ukhsa.gov.uk} (\href{https://orcid.org/0000-0002-2383-5305}{ORCID}) [copyright holder] \item Adam Kucharski \email{adam.kucharski@lshtm.ac.uk} (\href{https://orcid.org/0000-0001-8814-9421}{ORCID}) [copyright holder] } Other contributors: \itemize{ - \item Rosalind Eggo \email{r.eggo@lshtm.ac.uk} (\href{https://orcid.org/0000-0002-0362-6717}{ORCID}) [contributor] \item Hugo Gruson \email{hugo.gruson@data.org} (\href{https://orcid.org/0000-0002-4094-1476}{ORCID}) [contributor] \item Thibaut Jombart \email{thibaut@data.org} (\href{https://orcid.org/0000-0003-3796-2097}{ORCID}) [contributor] \item Andree Valle-Campos \email{andree.valle-campos@lshtm.ac.uk} (\href{https://orcid.org/0000-0002-7779-481X}{ORCID}) [contributor] diff --git a/tests/testthat/test-dev-utils.R b/tests/testthat/test-dev-utils.R new file mode 100644 index 00000000..2f513753 --- /dev/null +++ b/tests/testthat/test-dev-utils.R @@ -0,0 +1,3 @@ +test_that("release_bullets() returns what usethis expects", { + expect_type(release_bullets(), "character") +}) diff --git a/tools/check.env b/tools/check.env index 181ad6bb..b2794202 100644 --- a/tools/check.env +++ b/tools/check.env @@ -5,7 +5,14 @@ _R_CHECK_PKG_SIZES_=false _R_CHECK_RD_XREFS_=false # Do not report if package requires GNU make -_R_CHECK_CRAN_INCOMING_NOTE_GNU_MAKE_=false +# https://github.com/epiverse-trace/packagetemplate/issues/119 +# https://github.com/r-lib/rcmdcheck/pull/219 +_R_CHECK_CRAN_INCOMING_NOTE_GNU_MAKE_=true # Do not check non-ASCII strings in datasets _R_CHECK_PACKAGE_DATASETS_SUPPRESS_NOTES_=true + +# Exists since R 4.3.0 but `false` by default. +# https://bugs.r-project.org/show_bug.cgi?id=18419 +# Warn when using : with an element of length more than one +_R_CHECK_LENGTH_COLON_=true diff --git a/touchstone/script.R b/touchstone/script.R index 19b5158c..cc15dc1f 100644 --- a/touchstone/script.R +++ b/touchstone/script.R @@ -70,5 +70,5 @@ touchstone::benchmark_run( n = 100 ) -# generate benchmark +# create artifacts used downstream in the GitHub Action touchstone::benchmark_analyze() diff --git a/vignettes/demographic_turnover.Rmd b/vignettes/demographic_turnover.Rmd index 2dab1b8a..d778bdb2 100644 --- a/vignettes/demographic_turnover.Rmd +++ b/vignettes/demographic_turnover.Rmd @@ -19,7 +19,7 @@ editor_options: If population immunity accumulates during an epidemic, then the peak of the epidemic is the point at which there is a sufficient reduction in susceptibility to bring the effective reproduction number $R$ below the critical value of 1. However, because infections continue as the epidemic declines, more immunity can accumulate, and hence $R$ can be substantially below 1 at the end of the epidemic. ::: {.alert .alert-warning} -**New to _finalsize_?** We'd recommend the ["Get started"](finalsize.html) and ["Modelling uncertainty in R₀"](uncertainty_params.Rmd) vignettes first! +**New to _finalsize_?** We'd recommend the ["Get started"](finalsize.html) and ["Modelling uncertainty in R₀"](uncertainty_params.html) vignettes first! ::: ::: {.alert .alert-primary} diff --git a/vignettes/finalsize.Rmd b/vignettes/finalsize.Rmd index 73943cbf..6637a77e 100644 --- a/vignettes/finalsize.Rmd +++ b/vignettes/finalsize.Rmd @@ -84,7 +84,7 @@ contact_matrix <- matrix(1.0) / uk_pop ::: {.alert .alert-secondary} Social contacts are well known to be non-uniform, with age being a strong influence on how many contacts a person has and, moreover, on the ages of their contacts. A relatively simple example is that of children of school-going age, who typically have more social contacts than the elderly, and most of whose social contacts are with other schoolchildren. -The ["Modelling heterogeneous contacts"](varying_contacts.Rmd) vignette explores how this can be incorporated into final epidemic size calculations using _finalsize_. +The ["Modelling heterogeneous contacts"](varying_contacts.html) vignette explores how this can be incorporated into final epidemic size calculations using _finalsize_. ::: ## Modelling population susceptibility diff --git a/vignettes/uncertainty_params.Rmd b/vignettes/uncertainty_params.Rmd index ccaf9f27..224ef591 100644 --- a/vignettes/uncertainty_params.Rmd +++ b/vignettes/uncertainty_params.Rmd @@ -19,7 +19,7 @@ editor_options: Epidemic final size calculations are sensitive to input data such as the $R_0$ of the infection. Such values can often be uncertain in the early stages of an outbreak. This uncertainty can be included in final size calculations by running `final_size()` for values drawn from a distribution, and summarising the outcomes. ::: {.alert .alert-warning} -**New to _finalsize_?** It may help to read the ["Get started"](finalsize.html), ["Modelling heterogeneous contacts"](varying_contacts.html), or ["Modelling heterogeneous susceptibility"](varying_susceptibility.Rmd) vignettes first! +**New to _finalsize_?** It may help to read the ["Get started"](finalsize.html), ["Modelling heterogeneous contacts"](varying_contacts.html), or ["Modelling heterogeneous susceptibility"](varying_susceptibility.html) vignettes first! ::: ::: {.alert .alert-primary}