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/DESCRIPTION b/DESCRIPTION index 0f07fd8..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.2.3 +RoxygenNote: 7.3.2 diff --git a/README.md b/README.md index 85a4273..e802e3b 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ [![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) ## Overview @@ -16,27 +15,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 +104,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 +129,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 +251,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 +308,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 +323,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 diff --git a/tests/testthat/helper-flowery.R b/tests/testthat/helper-flowery.R index 593277a..d6db17b 100644 --- a/tests/testthat/helper-flowery.R +++ b/tests/testthat/helper-flowery.R @@ -1,15 +1,6 @@ -# 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) { + skip_on_covr() + inject(expect_snapshot(!!enquo0(expr), cran = cran)) } expect_exhausted <- function(x) {