From 2ce0d5008d0338abdadf827e1bdf9f1553fbe0e0 Mon Sep 17 00:00:00 2001 From: Daniel Sjoberg Date: Fri, 1 Dec 2023 09:57:24 -0800 Subject: [PATCH] GH Action workflow updates (#1574) * updates * more updates * Update test-coverage.yaml * Update pull_request_template.md * updates * updates --- ...t_template.md => PULL_REQUEST_TEMPLATE.md} | 12 +-- .../R-CMD-check-historic-R-versions.yaml | 94 ------------------- .github/workflows/R-CMD-check.yaml | 36 +++---- .github/workflows/close.yaml | 20 ---- .github/workflows/continuous-benchmarks.txt | 52 ---------- .github/workflows/pkgdown.yaml | 8 +- .github/workflows/pr-commands.yaml | 22 +++-- .github/workflows/test-coverage.yaml | 80 ++++++++++------ _archive/README.Rmd | 3 +- codecov.yml | 14 +++ 10 files changed, 98 insertions(+), 243 deletions(-) rename .github/{pull_request_template.md => PULL_REQUEST_TEMPLATE.md} (58%) delete mode 100644 .github/workflows/R-CMD-check-historic-R-versions.yaml delete mode 100644 .github/workflows/close.yaml delete mode 100644 .github/workflows/continuous-benchmarks.txt create mode 100644 codecov.yml diff --git a/.github/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 58% rename from .github/pull_request_template.md rename to .github/PULL_REQUEST_TEMPLATE.md index 3688a6414e..2fa240b1e5 100644 --- a/.github/pull_request_template.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -8,20 +8,16 @@ Reviewer Checklist (if item does not apply, mark is as complete) -- [ ] Ensure all package dependencies are installed by running `renv::install()` -- [ ] PR branch has pulled the most recent updates from master branch. Ensure the pull request branch and your local version match and both have the latest updates from the master branch. -- [ ] If an update was made to `tbl_summary()`, was the same change implemented for `tbl_svysummary()`? -- [ ] If a new function was added, function included in `_pkgdown.yml` -- [ ] If a bug was fixed, a unit test was added for the bug check +- [ ] Ensure all package dependencies are installed: `renv::install()` +- [ ] PR branch has pulled the most recent updates from master branch: `usethis::pr_merge_main()` +- [ ] If a bug was fixed, a unit test was added. - [ ] Run `pkgdown::build_site()`. Check the R console for errors, and review the rendered website. -- [ ] Code coverage is suitable for any new functions/features. Review coverage with `withr::with_envvar(new = c("NOT_CRAN" = "true"), covr::report())`. Begin in a fresh R session without any packages loaded. -- [ ] R CMD Check runs without errors, warnings, and notes +- [ ] Code coverage is suitable for any new functions/features: `devtools::test_coverage()` - [ ] `usethis::use_spell_check()` runs with no spelling errors in documentation When the branch is ready to be merged into master: - [ ] Update `NEWS.md` with the changes from this pull request under the heading "`# gtsummary (development version)`". If there is an issue associated with the pull request, reference it in parentheses at the end update (see `NEWS.md` for examples). - [ ] Increment the version number using `usethis::use_version(which = "dev")` -- [ ] Run `codemetar::write_codemeta()` - [ ] Run `usethis::use_spell_check()` again - [ ] Approve Pull Request - [ ] Merge the PR. Please use "Squash and merge". diff --git a/.github/workflows/R-CMD-check-historic-R-versions.yaml b/.github/workflows/R-CMD-check-historic-R-versions.yaml deleted file mode 100644 index 71922c60b3..0000000000 --- a/.github/workflows/R-CMD-check-historic-R-versions.yaml +++ /dev/null @@ -1,94 +0,0 @@ -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions -on: - push: - branches: - - main - - master - pull_request: - branches: - - main - - master - -name: R-CMD-historic-R-check - -jobs: - R-CMD-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - - {os: ubuntu-latest, r: 'oldrel-2'} - - {os: ubuntu-latest, r: 'oldrel-3'} - # - {os: ubuntu-latest, r: 'oldrel-4'} - - env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.config.r }} - - - uses: r-lib/actions/setup-pandoc@v2 - - # installing nlopt for R versions less than 3.6 - # this is for the installation of nloptr package required for lme4 - - name: Install nlopt on Linux - if: runner.os == 'Linux' - run: sudo apt-get install pkg-config libnlopt-dev - - - name: Query dependencies - run: | - install.packages('remotes', repos = 'http://cran.rstudio.com') - saveRDS(remotes::dev_package_deps(dependencies = TRUE, repos = 'http://cran.rstudio.com'), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v2 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-2-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-2- - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - while read -r cmd - do - eval sudo $cmd - done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - sudo apt-get update -y - sudo apt-get install -y texlive-fonts-extra - sudo apt-get install -y libcurl4-openssl-dev - - - name: Install dependencies - run: | - remotes::install_cran("curl", repos = 'https://packagemanager.posit.co/cran/latest') # added this because curl install was failing from CRAN, hopeing this uses the binaries available from RSPM - remotes::install_deps(dependencies = TRUE, repos = 'http://cran.rstudio.com') - remotes::install_cran("rcmdcheck", repos = 'http://cran.rstudio.com') - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_REMOTE_: false - _R_CHECK_FORCE_SUGGESTS_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 5c626acd2f..1fe123e906 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,4 +1,4 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# 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 @@ -8,7 +8,7 @@ on: push: branches: [main, master] pull_request: - branches: [main, master] + # branches: [main, master] name: R-CMD-check @@ -22,15 +22,16 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} + # use 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: '4.1'} - # Use older ubuntu to maximise backward compatibility - # - {os: ubuntu-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-1'} - # - {os: ubuntu-latest, r: 'oldrel-2'} + - {os: ubuntu-latest, r: 'oldrel-2'} # - {os: ubuntu-latest, r: 'oldrel-3'} # - {os: ubuntu-latest, r: 'oldrel-4'} @@ -39,7 +40,7 @@ jobs: R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-pandoc@v2 @@ -51,24 +52,9 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: rcmdcheck - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - sudo apt-get update -y - sudo apt-get install -y texlive-fonts-extra + extra-packages: any::rcmdcheck + needs: check - uses: r-lib/actions/check-r-package@v2 - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true diff --git a/.github/workflows/close.yaml b/.github/workflows/close.yaml deleted file mode 100644 index 0ab93f0d91..0000000000 --- a/.github/workflows/close.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: 'Close stale issues and PRs' -on: - schedule: - - cron: '0 0 * * *' - -jobs: - stale: - runs-on: ubuntu-latest - steps: - - uses: actions/stale@v3 - with: - days-before-stale: 365 - stale-issue-label: 'stale issue' - stale-pr-label: 'stale pull request' - stale-issue-message: 'This issue has been automatically closed due to inactivity.' - stale-pr-message: 'This pull request has been automatically closed due to inactivity.' - days-before-close: 14 - exempt-assignees: 'ddsjoberg,larmarange,emilyvertosick,jalavery,karissawhiting,larmarange,michaelcurry1123,shannonpileggi,zabore' - exempt-issue-labels: 'waiting,hackathon,help wanted' - exempt-all-milestones: true diff --git a/.github/workflows/continuous-benchmarks.txt b/.github/workflows/continuous-benchmarks.txt deleted file mode 100644 index 7aa1919797..0000000000 --- a/.github/workflows/continuous-benchmarks.txt +++ /dev/null @@ -1,52 +0,0 @@ -# on: -# push: -# pull_request: -# -# name: Benchmark -# -# jobs: -# build: -# runs-on: macOS-latest -# steps: -# - name: Checkout repo -# uses: actions/checkout@master -# -# - name: Setup R -# uses: r-lib/actions/setup-r@master -# -# - name: Query dependencies -# run: | -# install.packages('remotes') -# saveRDS(remotes::dev_package_deps(dependencies = c("Depends", "Imports")), ".github/bench_depends.Rds", version = 2) -# writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") -# shell: Rscript {0} -# -# - name: Cache R packages -# uses: actions/cache@v1 -# with: -# path: ${{ env.R_LIBS_USER }} -# key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/bench_depends.Rds') }} -# restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- -# -# - name: Install dependencies -# run: | -# install.packages(c('devtools', 'microbenchmark', 'here', 'gert', 'usethis', 'lubridate', 'readr', 'ggplot2', 'rmarkdown', 'knitr')) -# remotes::install_deps(dependencies = c("Depends", "Imports")) # don't need suggests to run most fns -# shell: Rscript {0} -# -# - name: Install Pandoc -# uses: r-lib/actions/setup-pandoc@9598b8eeb6d88de7d76d580d84443542bbfdffce -# with: -# pandoc-version: 2.11.1.1 -# -# - name: Build RMD REPORT -# run: | -# Rscript -e 'rmarkdown::render(input = here::here("benchmark/README.Rmd"), output_file = here::here("benchmark/README.md"), clean = TRUE, output_format = "md_document")' -# -# - name: Commit files -# run: | -# git config --global user.email "ghau@example.com" -# git config --global user.name "GitHub Actions User" -# git add --all -# git commit -am "continous benchmark autocommit" -# git push diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 0b2602168b..d629ecbda7 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -4,7 +4,7 @@ on: push: branches: [main, master] pull_request: - branches: [main, master] + # branches: [main, master] release: types: [published] workflow_dispatch: @@ -19,8 +19,10 @@ jobs: group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/setup-pandoc@v2 @@ -39,7 +41,7 @@ jobs: - name: Deploy to GitHub pages 🚀 if: github.event_name != 'pull_request' - uses: JamesIves/github-pages-deploy-action@4.1.4 + uses: JamesIves/github-pages-deploy-action@v4.4.1 with: clean: false branch: gh-pages diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index 98ca228bce..71f335b3ea 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -1,4 +1,4 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# 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 on: issue_comment: @@ -8,13 +8,13 @@ name: Commands jobs: document: - if: startsWith(github.event.comment.body, '/document') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} name: document runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/pr-fetch@v2 with: @@ -26,10 +26,12 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: roxygen2 + extra-packages: any::roxygen2 + needs: pr-document - name: Document - run: Rscript -e 'roxygen2::roxygenise()' + run: roxygen2::roxygenise() + shell: Rscript {0} - name: commit run: | @@ -43,13 +45,13 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} style: - if: startsWith(github.event.comment.body, '/style') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} name: style runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: r-lib/actions/pr-fetch@v2 with: @@ -58,10 +60,12 @@ jobs: - uses: r-lib/actions/setup-r@v2 - name: Install dependencies - run: Rscript -e 'install.packages("styler")' + run: install.packages("styler") + shell: Rscript {0} - name: Style - run: Rscript -e 'styler::style_pkg()' + run: styler::style_pkg() + shell: Rscript {0} - name: commit run: | diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 4b01af7586..6a1bcbbeee 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,30 +1,50 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples -# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -name: test-coverage - -jobs: - test-coverage: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: covr - - - name: Test coverage - run: covr::codecov() - shell: Rscript {0} +# # 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 +# on: +# push: +# branches: [main, master] +# pull_request: +# branches: [main, master] +# +# name: test-coverage +# +# jobs: +# test-coverage: +# runs-on: ubuntu-latest +# env: +# GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} +# +# steps: +# - uses: actions/checkout@v3 +# +# - uses: r-lib/actions/setup-r@v2 +# with: +# use-public-rspm: true +# +# - uses: r-lib/actions/setup-r-dependencies@v2 +# with: +# extra-packages: any::covr +# needs: coverage +# +# - name: Test coverage +# run: | +# covr::codecov( +# quiet = FALSE, +# clean = FALSE, +# install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") +# ) +# shell: Rscript {0} +# +# - name: Show testthat output +# if: always() +# run: | +# ## -------------------------------------------------------------------- +# find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true +# shell: bash +# +# - name: Upload test results +# if: failure() +# uses: actions/upload-artifact@v3 +# with: +# name: coverage-test-failures +# path: ${{ runner.temp }}/package diff --git a/_archive/README.Rmd b/_archive/README.Rmd index d9e8896bd8..253450b350 100644 --- a/_archive/README.Rmd +++ b/_archive/README.Rmd @@ -15,8 +15,7 @@ knitr::opts_chunk$set( ``` -[![R-CMD-check](https://github.com/ddsjoberg/gtsummary/workflows/R-CMD-check/badge.svg)](https://github.com/ddsjoberg/gtsummary/actions) -[![CRAN status](https://www.r-pkg.org/badges/version/gtsummary)](https://cran.r-project.org/package=gtsummary) +[![R-CMD-check](https://github.com/ddsjoberg/gtsummary/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ddsjoberg/gtsummary/actions/workflows/R-CMD-check.yaml)[![CRAN status](https://www.r-pkg.org/badges/version/gtsummary)](https://cran.r-project.org/package=gtsummary) [![Codecov test coverage](https://codecov.io/gh/ddsjoberg/gtsummary/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ddsjoberg/gtsummary?branch=main) [![](https://cranlogs.r-pkg.org/badges/gtsummary)](https://cran.r-project.org/package=gtsummary) [![DOI:10.32614/RJ-2021-053](https://zenodo.org/badge/DOI/10.32614/RJ-2021-053.svg)](https://doi.org/10.32614/RJ-2021-053) diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000000..04c5585990 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,14 @@ +comment: false + +coverage: + status: + project: + default: + target: auto + threshold: 1% + informational: true + patch: + default: + target: auto + threshold: 1% + informational: true