From 3f71fa5b38af52e586fae4b67b1893159116f3d8 Mon Sep 17 00:00:00 2001 From: Robin Lovelace Date: Fri, 30 Oct 2020 16:04:30 +0000 Subject: [PATCH] Add updated actions with usethis::use_tidy_github_actions() (do not override standard check) --- .Rbuildignore | 1 + .github/workflows/pkgdown.yaml | 48 ++++++++++++++++++++++++ .github/workflows/pr-commands.yaml | 55 ++++++++++++++++++++++++++++ .github/workflows/test-coverage.yaml | 48 ++++++++++++++++++++++++ DESCRIPTION | 3 +- README.Rmd | 1 + README.md | 22 +++++------ codecov.yml | 14 +++++++ 8 files changed, 180 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/pkgdown.yaml create mode 100644 .github/workflows/pr-commands.yaml create mode 100644 .github/workflows/test-coverage.yaml create mode 100644 codecov.yml diff --git a/.Rbuildignore b/.Rbuildignore index 5174dbf..17a4d71 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -12,3 +12,4 @@ ^tic\.R$ ^README\.Rmd$ ^\.httr-oauth$ +^codecov\.yml$ diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 0000000..3c908d3 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,48 @@ +on: + push: + branches: + - main + - master + +name: pkgdown + +jobs: + pkgdown: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/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@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE) + install.packages("pkgdown", type = "binary") + shell: Rscript {0} + + - name: Install package + run: R CMD INSTALL . + + - name: Deploy package + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml new file mode 100644 index 0000000..e5edf9f --- /dev/null +++ b/.github/workflows/pr-commands.yaml @@ -0,0 +1,55 @@ +on: + issue_comment: + types: [created] +name: Commands +jobs: + document: + if: startsWith(github.event.comment.body, '/document') + name: document + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/pr-fetch@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@v1 + - name: Install dependencies + run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)' + - name: Document + run: Rscript -e 'roxygen2::roxygenise()' + - name: commit + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + git add man/\* NAMESPACE + git commit -m 'Document' + - uses: r-lib/actions/pr-push@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + style: + if: startsWith(github.event.comment.body, '/style') + name: style + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: r-lib/actions/pr-fetch@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: r-lib/actions/setup-r@v1 + - name: Install dependencies + run: Rscript -e 'install.packages("styler")' + - name: Style + run: Rscript -e 'styler::style_pkg()' + - name: commit + run: | + git config --local user.email "actions@github.com" + git config --local user.name "GitHub Actions" + git add \*.R + git commit -m 'Style' + - uses: r-lib/actions/pr-push@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml new file mode 100644 index 0000000..5910c1a --- /dev/null +++ b/.github/workflows/test-coverage.yaml @@ -0,0 +1,48 @@ +on: + push: + branches: + - main + - master + pull_request: + branches: + - main + - master + +name: test-coverage + +jobs: + test-coverage: + runs-on: macOS-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/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@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install dependencies + run: | + install.packages(c("remotes")) + remotes::install_deps(dependencies = TRUE) + remotes::install_cran("covr") + shell: Rscript {0} + + - name: Test coverage + run: covr::codecov() + shell: Rscript {0} diff --git a/DESCRIPTION b/DESCRIPTION index 35dbd57..ded3cf4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -40,5 +40,6 @@ Suggests: knitr, rmarkdown, ceramic, - bookdown + bookdown, + covr VignetteBuilder: knitr diff --git a/README.Rmd b/README.Rmd index 48e68fa..5e196e7 100644 --- a/README.Rmd +++ b/README.Rmd @@ -17,6 +17,7 @@ knitr::opts_chunk$set( [![R-CMD-check](https://github.com/itsleeds/slopes/workflows/R-CMD-check/badge.svg)](https://github.com/itsleeds/slopes/actions) +[![Codecov test coverage](https://codecov.io/gh/itsleeds/slopes/branch/master/graph/badge.svg)](https://codecov.io/gh/itsleeds/slopes?branch=master) The goal of slopes is to enable fast, accurate and user friendly calculation longitudinal steepness of linear features such as roads and rivers, based on commonly available input datasets such as road geometries and digital elevation model (DEM) datasets. diff --git a/README.md b/README.md index 99853d0..7a0732f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ [![R-CMD-check](https://github.com/itsleeds/slopes/workflows/R-CMD-check/badge.svg)](https://github.com/itsleeds/slopes/actions) +[![Codecov test +coverage](https://codecov.io/gh/itsleeds/slopes/branch/master/graph/badge.svg)](https://codecov.io/gh/itsleeds/slopes?branch=master) The goal of slopes is to enable fast, accurate and user friendly @@ -181,15 +183,15 @@ res #> # A tibble: 2 x 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> -#> 1 slope_raster 37.9ms 39.7ms 25.2 32.7MB 7.57 -#> 2 slope_terra 60.6ms 62.4ms 15.2 29.1MB 5.05 +#> 1 slope_raster 47.3ms 49.3ms 20.0 32.7MB 5.01 +#> 2 slope_terra 74ms 78.1ms 11.8 29.1MB 2.37 ``` That is approximately ``` r round(res$`itr/sec` * nrow(r)) -#> [1] 6834 4106 +#> [1] 5426 3206 ``` routes per second using the `raster` and `terra` (the default if @@ -218,10 +220,10 @@ res #> # A tibble: 4 x 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> -#> 1 bilinear1 38.7ms 39.7ms 25.1 32.7MB 8.35 -#> 2 bilinear2 61.4ms 62.4ms 15.9 29MB 5.29 -#> 3 simple1 30.4ms 32.1ms 31.3 29MB 7.22 -#> 4 simple2 60ms 61.5ms 16.2 29MB 5.40 +#> 1 bilinear1 47.9ms 52.3ms 19.3 32.7MB 4.81 +#> 2 bilinear2 75ms 84.4ms 12.0 29MB 2.41 +#> 3 simple1 32ms 38ms 26.4 29MB 7.93 +#> 4 simple2 74.9ms 80.8ms 12.4 29MB 2.06 ``` The equivalent benchmark with the `raster` package is as follows: @@ -240,8 +242,6 @@ res #> # A tibble: 2 x 6 #> expression min median `itr/sec` mem_alloc `gc/sec` #> -#> 1 bilinear 38.4ms 40.2ms 24.9 32.7MB 4.53 -#> 2 simple 30.6ms 31ms 31.8 29MB 7.34 +#> 1 bilinear 49.8ms 53.2ms 18.8 32.7MB 2.36 +#> 2 simple 38.1ms 41ms 24.3 29MB 4.85 ``` - - 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