From ed314817645c1db107b9171201216e4c89f261d6 Mon Sep 17 00:00:00 2001 From: ALanguillaume Date: Wed, 4 Jan 2023 16:21:05 +0100 Subject: [PATCH] feat: add github actions --- .Rbuildignore | 1 + .github/.gitignore | 1 + .github/workflows/R-CMD-check.yaml | 49 ++++++++++++++++++++++++++++++ README.Rmd | 1 + README.md | 27 ++++++++-------- dev/dev_history.R | 5 +++ 6 files changed, 71 insertions(+), 13 deletions(-) create mode 100644 .github/.gitignore create mode 100644 .github/workflows/R-CMD-check.yaml diff --git a/.Rbuildignore b/.Rbuildignore index 628e0b4..51e7ce3 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -4,3 +4,4 @@ ^README\.Rmd$ ^cran-comments\.md$ ^dev$ +^\.github$ diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..a3ac618 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,49 @@ +# 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: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true diff --git a/README.Rmd b/README.Rmd index 4d4df03..60ae483 100644 --- a/README.Rmd +++ b/README.Rmd @@ -29,6 +29,7 @@ cat_mariobox_yaml <- function(path_pipo) { [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![CRAN status](https://www.r-pkg.org/badges/version/mariobox)](https://CRAN.R-project.org/package=mariobox) +[![R-CMD-check](https://github.com/ThinkR-open/mariobox/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ThinkR-open/mariobox/actions/workflows/R-CMD-check.yaml) [DISCLAIMER] This is a Work In Progress, please use at your own risk. diff --git a/README.md b/README.md index 16d2fb3..ff59c81 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![CRAN status](https://www.r-pkg.org/badges/version/mariobox)](https://CRAN.R-project.org/package=mariobox) +[![R-CMD-check](https://github.com/ThinkR-open/mariobox/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ThinkR-open/mariobox/actions/workflows/R-CMD-check.yaml) \[DISCLAIMER\] This is a Work In Progress, please use at your own risk. @@ -44,8 +45,8 @@ create_mariobox( open = FALSE ) ── Creating dir ──────────────────────────────────────────────────────────────── - ✔ Creating '/var/folders/5z/rm2h62lj45d332kfpj28c8zm0000gn/T/RtmpP86EN6/pipoac8920906d46/' - ✔ Setting active project to '/private/var/folders/5z/rm2h62lj45d332kfpj28c8zm0000gn/T/RtmpP86EN6/pipoac8920906d46' + ✔ Creating '/tmp/RtmpjFWgLO/pipo1d75618a38d99/' + ✔ Setting active project to '/tmp/RtmpjFWgLO/pipo1d75618a38d99' ✔ Creating 'R/' ✔ Writing a sentinel file '.here' • Build robust paths within your project via `here::here()` @@ -55,14 +56,14 @@ create_mariobox( ── Copying package skeleton ──────────────────────────────────────────────────── ✔ Copied app skeleton ── Done ──────────────────────────────────────────────────────────────────────── - A new mariobox named pipoac8920906d46 was created at /private/var/folders/5z/rm2h62lj45d332kfpj28c8zm0000gn/T/RtmpP86EN6/pipoac8920906d46 . + A new mariobox named pipo1d75618a38d99 was created at /tmp/RtmpjFWgLO/pipo1d75618a38d99 . ``` By default, you’ll find the following structure: ``` r fs::dir_tree(path_pipo) - /var/folders/5z/rm2h62lj45d332kfpj28c8zm0000gn/T//RtmpP86EN6/pipoac8920906d46 + /tmp/RtmpjFWgLO/pipo1d75618a38d99 ├── DESCRIPTION ├── NAMESPACE ├── R @@ -95,7 +96,7 @@ then do a little bit of its magic and parse this YAML to build the health_get: methods: GET path: /health - handler: health + handler: get_health ### Add/Remove endpoints @@ -148,7 +149,7 @@ add_get( ``` r fs::dir_tree(path_pipo) - /var/folders/5z/rm2h62lj45d332kfpj28c8zm0000gn/T//RtmpP86EN6/pipoac8920906d46 + /tmp/RtmpjFWgLO/pipo1d75618a38d99 ├── DESCRIPTION ├── NAMESPACE ├── R @@ -179,7 +180,7 @@ The YALML is automatically updated: health_get: methods: GET path: /health - handler: health + handler: get_health allo_get: methods: GET path: /allo @@ -200,7 +201,7 @@ remove_endpoint( ``` r fs::dir_tree(path_pipo) - /var/folders/5z/rm2h62lj45d332kfpj28c8zm0000gn/T//RtmpP86EN6/pipoac8920906d46 + /tmp/RtmpjFWgLO/pipo1d75618a38d99 ├── DESCRIPTION ├── NAMESPACE ├── R @@ -230,7 +231,7 @@ The YALML is automatically updated: health_get: methods: GET path: /health - handler: health + handler: get_health hey_get: methods: GET path: /hey @@ -256,8 +257,8 @@ your function. This format might seem weird, but the idea is to separate the concerns in the following format: -- METHOD_NAME() will handle the http elements (login, headers..) -- METHOD_NAME_f() will be a standard function returning data. +- METHOD_NAME() will handle the http elements (login, headers..) +- METHOD_NAME_f() will be a standard function returning data. That way, you can handle the data manipulation function just like a plain standard one, test it, interact with it, etc, without having to @@ -279,7 +280,7 @@ can deploy using this file. ``` r build_plumber_file(pkg = path_pipo) - ℹ Loading pipoac8920906d46 + ℹ Loading pipo1d75618a38d99 ✔ plumber.R file created ``` @@ -293,7 +294,7 @@ This will produce the following file: #* @get /health - health + get_health #* @get /hey get_hey diff --git a/dev/dev_history.R b/dev/dev_history.R index f120bbd..ac423d1 100644 --- a/dev/dev_history.R +++ b/dev/dev_history.R @@ -41,3 +41,8 @@ devtools::test( .use_r_with_test("create_mariobox") .use_r_with_test("utils") .use_r_with_test("manage_endpoints") + + +## CI + +usethis::use_github_action_check_standard()