Skip to content

Commit

Permalink
feat: add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ALanguillaume committed Jan 4, 2023
1 parent 4b30f8e commit ed31481
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 13 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
^README\.Rmd$
^cran-comments\.md$
^dev$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
49 changes: 49 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ cat_mariobox_yaml <- function(path_pipo) {
<!-- badges: start -->
[![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)
<!-- badges: end -->

[DISCLAIMER] This is a Work In Progress, please use at your own risk.
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<!-- badges: end -->

\[DISCLAIMER\] This is a Work In Progress, please use at your own risk.
Expand Down Expand Up @@ -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()`
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -279,7 +280,7 @@ can deploy using this file.

``` r
build_plumber_file(pkg = path_pipo)
Loading pipoac8920906d46
Loading pipo1d75618a38d99
plumber.R file created
```

Expand All @@ -293,7 +294,7 @@ This will produce the following file:
#* @get /health
health
get_health
#* @get /hey
get_hey
5 changes: 5 additions & 0 deletions dev/dev_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit ed31481

Please sign in to comment.