Skip to content

Commit

Permalink
R echo client tests (#17629)
Browse files Browse the repository at this point in the history
* add r echo api client sample

* add r workflow

* fix

* add env

* set r version

* install curl

* install dep

* fix

* comment out installation
  • Loading branch information
wing328 authored Jan 18, 2024
1 parent eab34c9 commit d810d7c
Show file tree
Hide file tree
Showing 69 changed files with 8,498 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/samples-r.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Samples R

on:
push:
paths:
- 'samples/client/echo_api/r/**'
pull_request:
paths:
- 'samples/client/echo_api/r/**'

jobs:
build:
name: Build R
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sample:
- 'samples/client/echo_api/r/'
steps:
- uses: actions/checkout@v4
- name: Setup node.js
uses: actions/setup-node@v4
- name: Run echo server
run: |
git clone https://github.com/wing328/http-echo-server -b openapi-generator-test-server
(cd http-echo-server && npm install && npm start &)
- uses: r-lib/actions/setup-r@v2
with:
r-version: 3.6.1
- uses: r-lib/actions/setup-r-dependencies@v2
working-directory: ${{ matrix.sample }}
with:
cache-version: 2
- name: Install curl
run: sudo apt-get install -y r-cran-curl
- name: build and test
working-directory: ${{ matrix.sample }}
run: |
# export _R_CHECK_FORCE_SUGGESTS_=false
/bin/bash build_and_test.bash
shell: bash
6 changes: 6 additions & 0 deletions bin/configs/r-echo-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
generatorName: r
outputDir: samples/client/echo_api/r
inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
templateDir: modules/openapi-generator/src/main/resources/r
additionalProperties:
hideGenerationTimestamp: "true"
20 changes: 20 additions & 0 deletions samples/client/echo_api/r/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
^.*\.Rproj$ # Designates the directory as an RStudio Project
^\.Rproj\.user$ # Used by RStudio for temporary files
^README\.Rmd$ # An Rmd file used to generate README.md
^LICENSE\.md$ # Full text of the license
^cran-comments\.md$ # Comments for CRAN submission
^data-raw$ # Code used to create data included in the package
^pkgdown$ # Resources used for the package website
^_pkgdown\.yml$ # Configuration info for the package website
^\.github$ # Contributing guidelines, CoC, issue templates, etc.
^\.Rhistory$
^\.gitignore$
^\.openapi-generator-ignore$
^\.travis\.yml$
^\.lintr$
^\.github$
^\.openapi-generator$
^docs$
^git_push\.sh$
^openapi\.Rcheck$
^\.\.Rcheck$
33 changes: 33 additions & 0 deletions samples/client/echo_api/r/.github/workflows/r-client.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is automatically generated by openapi-generator (https://openapi-generator.tech)
#
# Based on https://github.com/r-lib/actions/tree/v2/examples
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ubuntu-latest
env:
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck, any::roxygen2, any::lintr, local::.
needs: check, roxygen2, lint
- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
- name: Roxygenize
run: |
roxygen2::roxygenize('.', roclets = c('rd', 'collate', 'namespace'))
shell: Rscript {0}
- uses: r-lib/actions/check-r-package@v2
35 changes: 35 additions & 0 deletions samples/client/echo_api/r/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ref: https://github.com/github/gitignore/blob/master/R.gitignore

# History files
.Rhistory
.Rapp.history

# Session Data files
.RData

# Example code in package build process
*-Ex.R

# Output files from R CMD build
/*.tar.gz

# Output files from R CMD check
/*.Rcheck/

# RStudio files
.Rproj.user/

# produced vignettes
vignettes/*.html
vignettes/*.pdf

# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth

# knitr and R markdown default cache directories
/*_cache/
/cache/

# Temporary files created by R markdown
*.utf8.md
*.knit.md
7 changes: 7 additions & 0 deletions samples/client/echo_api/r/.lintr
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
linters: linters_with_defaults(
line_length_linter(160),
object_name_linter = NULL,
cyclocomp_linter = NULL
)
exclusions: list(
)
23 changes: 23 additions & 0 deletions samples/client/echo_api/r/.openapi-generator-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator

# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs

# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux

# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux

# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
46 changes: 46 additions & 0 deletions samples/client/echo_api/r/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.Rbuildignore
.github/workflows/r-client.yaml
.gitignore
.lintr
.travis.yml
DESCRIPTION
NAMESPACE
R/api_client.R
R/api_response.R
R/auth_api.R
R/bird.R
R/body_api.R
R/category.R
R/data_query.R
R/default_value.R
R/form_api.R
R/header_api.R
R/number_properties_only.R
R/path_api.R
R/pet.R
R/query.R
R/query_api.R
R/string_enum_ref.R
R/tag.R
R/test_query_style_deep_object_explode_true_object_all_of_query_object_parameter.R
R/test_query_style_form_explode_true_array_string_query_object_parameter.R
README.md
docs/AuthApi.md
docs/Bird.md
docs/BodyApi.md
docs/Category.md
docs/DataQuery.md
docs/DefaultValue.md
docs/FormApi.md
docs/HeaderApi.md
docs/NumberPropertiesOnly.md
docs/PathApi.md
docs/Pet.md
docs/Query.md
docs/QueryApi.md
docs/StringEnumRef.md
docs/Tag.md
docs/TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter.md
docs/TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter.md
git_push.sh
tests/testthat.R
1 change: 1 addition & 0 deletions samples/client/echo_api/r/.openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.3.0-SNAPSHOT
18 changes: 18 additions & 0 deletions samples/client/echo_api/r/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ref: https://docs.travis-ci.com/user/languages/r/
language: r
cache:
directories:
- /home/travis/R/Library
r_packages:
- jsonlite
- httr
- testthat
# uncomment below to install deps with devtools
#install:
#- R -e 'devtools::install_deps(dep = T)'
script:
- R CMD build .
- R CMD check *tar.gz
- R CMD INSTALL *tar.gz
after_failure:
- cat ${TRAVIS_BUILD_DIR}/namsor.Rcheck/tests/testthat.Rout.fail
15 changes: 15 additions & 0 deletions samples/client/echo_api/r/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Package: openapi
Title: R Package Client for Echo Server API
Version: 1.0.0
Author: person("OpenAPI Generator community", email = "[email protected]", role = c("aut", "cre"))
Maintainer: OpenAPI Generator community <[email protected]>
Description: Echo Server API
URL: https://github.com/GIT_USER_ID/GIT_REPO_ID
BugReports: https://github.com/GIT_USER_ID/GIT_REPO_ID/issues
Depends: R (>= 3.3)
Encoding: UTF-8
License: Apache 2.0
LazyData: true
Suggests: testthat
Imports: jsonlite, httr, R6, base64enc, stringr
RoxygenNote: 7.2.1
34 changes: 34 additions & 0 deletions samples/client/echo_api/r/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by openapi-generator: https://openapi-generator.tech
# Do not edit by hand

import(R6)
import(jsonlite)
import(httr)
import(base64enc)
import(stringr)


# Core
export(ApiClient)
export(ApiResponse)

# Models
export(Bird)
export(Category)
export(DataQuery)
export(DefaultValue)
export(NumberPropertiesOnly)
export(Pet)
export(Query)
export(StringEnumRef)
export(Tag)
export(TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter)
export(TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter)

# APIs
export(AuthApi)
export(BodyApi)
export(FormApi)
export(HeaderApi)
export(PathApi)
export(QueryApi)
Loading

0 comments on commit d810d7c

Please sign in to comment.