From 6ded93962f77efa33b39f8fbc4eb441e93bf23e1 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 21 Aug 2024 13:35:28 -0500 Subject: [PATCH 1/6] Re-document --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0f07fd8..089971e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,4 +33,4 @@ Config/testthat/edition: 3 Config/Needs/website: tidyverse/tidytemplate Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 From 2e3bfde268a1df5856711537f5b8810e72632148 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 21 Aug 2024 13:35:38 -0500 Subject: [PATCH 2/6] use_tidy_description() --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 089971e..cd9caf7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,8 +29,8 @@ Suggests: testthat (>= 3.0.0) VignetteBuilder: knitr -Config/testthat/edition: 3 Config/Needs/website: tidyverse/tidytemplate +Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 From 38a8ed5c7fe61aa75f8269da30428489ffd80883 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 21 Aug 2024 13:38:13 -0500 Subject: [PATCH 3/6] Remove outdated testthat work around --- tests/testthat/helper-flowery.R | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/tests/testthat/helper-flowery.R b/tests/testthat/helper-flowery.R index 593277a..29aff58 100644 --- a/tests/testthat/helper-flowery.R +++ b/tests/testthat/helper-flowery.R @@ -1,15 +1,5 @@ -# Work around for `{{` blocks -# Branching is for compatibility with r-lib/testthat#1492 -if ("enquo0" %in% all.names(body(expect_snapshot))) { - expect_snapshot0 <- function(expr, cran = TRUE) { - inject( - expect_snapshot(!!enquo0(expr), cran = cran) - ) - } -} else { - expect_snapshot0 <- function(expr, cran = TRUE) { - expect_snapshot(!!enquo0(expr), cran = cran) - } +expect_snapshot0 <- function(expr, cran = TRUE) { + inject(expect_snapshot(!!enquo0(expr), cran = cran)) } expect_exhausted <- function(x) { From d56eaf61d535996743641b4d543fa7c47ce68406 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 21 Aug 2024 13:39:04 -0500 Subject: [PATCH 4/6] use_tidy_github_actions() + build_readme() --- .github/workflows/R-CMD-check.yaml | 24 ++++----- .github/workflows/pkgdown.yaml | 4 +- .github/workflows/pr-commands.yaml | 8 ++- .github/workflows/test-coverage.yaml | 61 +++++++++++++++++++++ README.Rmd | 1 + README.md | 79 ++++++++++++++++------------ codecov.yml | 14 +++++ 7 files changed, 143 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/test-coverage.yaml create mode 100644 codecov.yml diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index d8aeb54..064677b 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -10,7 +10,9 @@ on: pull_request: branches: [main, master] -name: R-CMD-check +name: R-CMD-check.yaml + +permissions: read-all jobs: R-CMD-check: @@ -25,17 +27,15 @@ jobs: - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - # Use 3.6 to trigger usage of RTools35 - - {os: windows-latest, r: '3.6'} - # use 4.1 to check with rtools40's older compiler - - {os: windows-latest, r: '4.1'} - - - {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-3'} - - {os: ubuntu-latest, r: 'oldrel-4'} + # use 4.0 or 4.1 to check with rtools40's older compiler + - {os: windows-latest, r: 'oldrel-4'} + + - {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-3'} + - {os: ubuntu-latest, r: 'oldrel-4'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index a7276e8..4bbce75 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -9,7 +9,9 @@ on: types: [published] workflow_dispatch: -name: pkgdown +name: pkgdown.yaml + +permissions: read-all jobs: pkgdown: diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index eea58c5..2edd93f 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -4,7 +4,9 @@ on: issue_comment: types: [created] -name: Commands +name: pr-commands.yaml + +permissions: read-all jobs: document: @@ -13,6 +15,8 @@ jobs: runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - uses: actions/checkout@v4 @@ -50,6 +54,8 @@ jobs: runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..9882260 --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,61 @@ +# 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.yaml + +permissions: read-all + +jobs: + test-coverage: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + + steps: + - uses: actions/checkout@v4 + + - 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, any::xml2 + needs: coverage + + - name: Test coverage + run: | + cov <- covr::package_coverage( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) + covr::to_cobertura(cov) + shell: Rscript {0} + + - uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} + file: ./cobertura.xml + plugin: noop + disable_search: true + token: ${{ secrets.CODECOV_TOKEN }} + + - 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@v4 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package diff --git a/README.Rmd b/README.Rmd index 9180d84..3abf491 100644 --- a/README.Rmd +++ b/README.Rmd @@ -20,6 +20,7 @@ knitr::opts_chunk$set( [![CRAN status](https://www.r-pkg.org/badges/version/coro)](https://cran.r-project.org/package=coro) [![R-CMD-check](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml) +[![Codecov test coverage](https://codecov.io/gh/r-lib/coro/graph/badge.svg)](https://app.codecov.io/gh/r-lib/coro) diff --git a/README.md b/README.md index 85a4273..3e4a2cf 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,9 @@ [![CRAN status](https://www.r-pkg.org/badges/version/coro)](https://cran.r-project.org/package=coro) -[![R build -status](https://github.com/r-lib/coro/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/coro/actions) +[![R-CMD-check](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml) +[![Codecov test +coverage](https://codecov.io/gh/r-lib/coro/graph/badge.svg)](https://app.codecov.io/gh/r-lib/coro) ## Overview @@ -16,27 +17,27 @@ status](https://github.com/r-lib/coro/workflows/R-CMD-check/badge.svg)](https:// coro implements **coroutines** for R, i.e. functions that can be suspended and resumed later on. There are two kinds: - - **Async** functions, which make it straightforward to program - concurrently - - **Generators** for iterating over complex sequences +- **Async** functions, which make it straightforward to program + concurrently +- **Generators** for iterating over complex sequences Supported features: - - Suspending within loops and if/else branches - - Suspending within `tryCatch()` - - `on.exit()` expressions and stack-based cleanup such as provided by - `local_` functions in the [withr](https://github.com/r-lib/withr/) - package - - Step-debugging and `browser()` within coroutines +- Suspending within loops and if/else branches +- Suspending within `tryCatch()` +- `on.exit()` expressions and stack-based cleanup such as provided by + `local_` functions in the [withr](https://github.com/r-lib/withr/) + package +- Step-debugging and `browser()` within coroutines Compatibility with: - - Python iterators from the - [reticulate](https://rstudio.github.io/reticulate/) package - - Async operations from the - [promises](https://github.com/rstudio/promises/) package - - Parallel computations from the - [future](https://github.com/HenrikBengtsson/future) package +- Python iterators from the + [reticulate](https://rstudio.github.io/reticulate/) package +- Async operations from the + [promises](https://github.com/rstudio/promises/) package +- Parallel computations from the + [future](https://github.com/HenrikBengtsson/future) package Attach the package to follow the examples: @@ -105,10 +106,10 @@ my_async <- async(function() { Generators are based on a simple iteration protocol: - - Iterators are functions. - - They can be advanced by calling the function. The new value is - returned. - - An exhausted iterator returns the sentinel symbol `exhausted`. +- Iterators are functions. +- They can be advanced by calling the function. The new value is + returned. +- An exhausted iterator returns the sentinel symbol `exhausted`. The `generator()` function creates a generator factory which returns generator instances: @@ -130,11 +131,13 @@ A generator instance is an iterator function which yields values: ``` r abc #> -#> function() { -#> for (x in letters[1:3]) { -#> yield(x) -#> } +#> function () +#> { +#> for (x in letters[1:3]) { +#> yield(x) +#> } #> } +#> abc() #> [1] "a" @@ -250,11 +253,13 @@ state machine that is running under the hood: ``` r print(generate_abc, internals = TRUE) #> -#> function() { -#> for (x in letters[1:3]) { -#> yield(x) -#> } +#> function () +#> { +#> for (x in letters[1:3]) { +#> yield(x) +#> } #> } +#> #> State machine: #> { #> if (exhausted) { @@ -305,12 +310,12 @@ keeps track of the source references from the original code. ## Acknowledgements - - The [regenerator](https://facebook.github.io/regenerator/) - Javascript package which uses a similar transformation to implement - generators and async functions in older versions of Javascript. +- The [regenerator](https://facebook.github.io/regenerator/) Javascript + package which uses a similar transformation to implement generators + and async functions in older versions of Javascript. - - Gabor Csardi for many interesting discussions about concurrency and - the design of coro. +- Gabor Csardi for many interesting discussions about concurrency and + the design of coro. ## Installation @@ -320,3 +325,9 @@ Install the development version from github with: # install.packages("devtools") devtools::install_github("r-lib/coro", build_vignettes = TRUE) ``` + +## Code of Conduct + +Please note that the coro project is released with a [Contributor Code +of Conduct](https://coro.r-lib.org/CODE_OF_CONDUCT.html). By +contributing to this project, you agree to abide by its terms. diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..04c5585 --- /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 From ba086ae4df84c43f71c3d5334c8a90784a63ee44 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Wed, 21 Aug 2024 13:45:21 -0500 Subject: [PATCH 5/6] Skip generator tests in code coverage --- tests/testthat/helper-flowery.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/helper-flowery.R b/tests/testthat/helper-flowery.R index 29aff58..d6db17b 100644 --- a/tests/testthat/helper-flowery.R +++ b/tests/testthat/helper-flowery.R @@ -1,4 +1,5 @@ expect_snapshot0 <- function(expr, cran = TRUE) { + skip_on_covr() inject(expect_snapshot(!!enquo0(expr), cran = cran)) } From 6a3e44bec836bac6e26b621c873ca66bb792db15 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Wed, 28 Aug 2024 13:02:32 +0200 Subject: [PATCH 6/6] Disable codecov --- .github/workflows/test-coverage.yaml | 61 ---------------------------- README.Rmd | 1 - README.md | 2 - 3 files changed, 64 deletions(-) delete mode 100644 .github/workflows/test-coverage.yaml diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml deleted file mode 100644 index 9882260..0000000 --- a/.github/workflows/test-coverage.yaml +++ /dev/null @@ -1,61 +0,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.yaml - -permissions: read-all - -jobs: - test-coverage: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - - 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, any::xml2 - needs: coverage - - - name: Test coverage - run: | - cov <- covr::package_coverage( - quiet = FALSE, - clean = FALSE, - install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") - ) - covr::to_cobertura(cov) - shell: Rscript {0} - - - uses: codecov/codecov-action@v4 - with: - fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} - file: ./cobertura.xml - plugin: noop - disable_search: true - token: ${{ secrets.CODECOV_TOKEN }} - - - 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@v4 - with: - name: coverage-test-failures - path: ${{ runner.temp }}/package diff --git a/README.Rmd b/README.Rmd index 3abf491..9180d84 100644 --- a/README.Rmd +++ b/README.Rmd @@ -20,7 +20,6 @@ knitr::opts_chunk$set( [![CRAN status](https://www.r-pkg.org/badges/version/coro)](https://cran.r-project.org/package=coro) [![R-CMD-check](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml) -[![Codecov test coverage](https://codecov.io/gh/r-lib/coro/graph/badge.svg)](https://app.codecov.io/gh/r-lib/coro) diff --git a/README.md b/README.md index 3e4a2cf..e802e3b 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,6 @@ [![CRAN status](https://www.r-pkg.org/badges/version/coro)](https://cran.r-project.org/package=coro) [![R-CMD-check](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml) -[![Codecov test -coverage](https://codecov.io/gh/r-lib/coro/graph/badge.svg)](https://app.codecov.io/gh/r-lib/coro) ## Overview