Skip to content

Commit c270c7f

Browse files
committed
update CI
1 parent 7bca70d commit c270c7f

File tree

6 files changed

+56
-9
lines changed

6 files changed

+56
-9
lines changed

.github/workflows/check-standard.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ jobs:
4545
needs: check
4646

4747
- uses: r-lib/actions/check-r-package@v2
48+
with:
49+
upload-snapshots: true
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
branches: [main, master]
8+
9+
name: test-coverage
10+
11+
jobs:
12+
test-coverage:
13+
runs-on: ubuntu-latest
14+
env:
15+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- uses: r-lib/actions/setup-r@v2
21+
with:
22+
use-public-rspm: true
23+
24+
- uses: r-lib/actions/setup-r-dependencies@v2
25+
with:
26+
extra-packages: any::covr
27+
needs: coverage
28+
29+
- name: Test coverage
30+
run: covr::codecov(quiet = FALSE)
31+
shell: Rscript {0}

README.Rmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ knitr::opts_chunk$set(
1919
[![CRAN status](https://www.r-pkg.org/badges/version/nanonext?color=112d4e)](https://CRAN.R-project.org/package=nanonext)
2020
[![nanonext status badge](https://shikokuchuo.r-universe.dev/badges/nanonext?color=3f72af)](https://shikokuchuo.r-universe.dev)
2121
[![R-CMD-check](https://github.com/shikokuchuo/nanonext/workflows/R-CMD-check/badge.svg)](https://github.com/shikokuchuo/nanonext/actions)
22+
[![Codecov test coverage](https://codecov.io/gh/shikokuchuo/nanonext/branch/main/graph/badge.svg)](https://app.codecov.io/gh/shikokuchuo/nanonext)
2223
<!-- badges: end -->
2324

2425
R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a socket library providing high-performance scalability protocols, implementing a cross-platform standard for messaging and communications. Serves as a concurrency framework for building distributed applications, utilising 'Aio' objects which automatically resolve upon completion of asynchronous operations.

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ status](https://www.r-pkg.org/badges/version/nanonext?color=112d4e)](https://CRA
1010
[![nanonext status
1111
badge](https://shikokuchuo.r-universe.dev/badges/nanonext?color=3f72af)](https://shikokuchuo.r-universe.dev)
1212
[![R-CMD-check](https://github.com/shikokuchuo/nanonext/workflows/R-CMD-check/badge.svg)](https://github.com/shikokuchuo/nanonext/actions)
13+
[![Codecov test
14+
coverage](https://codecov.io/gh/shikokuchuo/nanonext/branch/main/graph/badge.svg)](https://app.codecov.io/gh/shikokuchuo/nanonext)
1315
<!-- badges: end -->
1416

1517
R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is a
@@ -377,7 +379,7 @@ aio
377379
#> < recvAio >
378380
#> - $data for message data
379381
aio$data |> str()
380-
#> num [1:100000000] -0.154 -0.281 -1.865 0.332 2.625 ...
382+
#> num [1:100000000] -0.597 -0.351 -0.984 1.93 1.393 ...
381383
```
382384

383385
As `call_aio()` is blocking and will wait for completion, an alternative
@@ -514,11 +516,11 @@ ncurl("http://httpbin.org/headers")
514516
#> [1] 7b 0a 20 20 22 68 65 61 64 65 72 73 22 3a 20 7b 0a 20 20 20 20 22 48 6f 73
515517
#> [26] 74 22 3a 20 22 68 74 74 70 62 69 6e 2e 6f 72 67 22 2c 20 0a 20 20 20 20 22
516518
#> [51] 58 2d 41 6d 7a 6e 2d 54 72 61 63 65 2d 49 64 22 3a 20 22 52 6f 6f 74 3d 31
517-
#> [76] 2d 36 32 36 33 32 39 65 32 2d 34 61 64 37 64 36 33 62 35 64 33 62 30 65 63
518-
#> [101] 62 31 38 63 66 38 32 31 38 22 0a 20 20 7d 0a 7d 0a
519+
#> [76] 2d 36 32 36 35 31 34 37 38 2d 31 38 64 62 65 31 36 38 34 32 62 63 62 36 62
520+
#> [101] 63 33 30 36 61 37 61 63 33 22 0a 20 20 7d 0a 7d 0a
519521
#>
520522
#> $data
521-
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-626329e2-4ad7d63b5d3b0ecb18cf8218\"\n }\n}\n"
523+
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-62651478-18dbe16842bcb6bc306a7ac3\"\n }\n}\n"
522524
```
523525

524526
For advanced use, supports additional HTTP methods such as POST or PUT.
@@ -533,7 +535,7 @@ res
533535
#> - $raw for raw message
534536

535537
call_aio(res)$data
536-
#> [1] "{\n \"args\": {}, \n \"data\": \"{\\\"key\\\": \\\"value\\\"}\", \n \"files\": {}, \n \"form\": {}, \n \"headers\": {\n \"Authorization\": \"Bearer APIKEY\", \n \"Content-Length\": \"16\", \n \"Content-Type\": \"application/json\", \n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-626329e3-3ad612de0091f2db61bb42eb\"\n }, \n \"json\": {\n \"key\": \"value\"\n }, \n \"origin\": \"78.145.225.121\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
538+
#> [1] "{\n \"args\": {}, \n \"data\": \"{\\\"key\\\": \\\"value\\\"}\", \n \"files\": {}, \n \"form\": {}, \n \"headers\": {\n \"Authorization\": \"Bearer APIKEY\", \n \"Content-Length\": \"16\", \n \"Content-Type\": \"application/json\", \n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-62651478-224f907c244b4b5053cfdac3\"\n }, \n \"json\": {\n \"key\": \"value\"\n }, \n \"origin\": \"78.145.225.121\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
537539
```
538540

539541
In this respect, it may be used as a performant and lightweight method

src/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ SEXP nano_encode(SEXP object) {
5858
memcpy(RAW(out), LOGICAL(object), sz);
5959
break;
6060
case CPLXSXP:
61-
sz = xlen * sizeof(double) * 2;
61+
sz = xlen * (sizeof(double) + sizeof(double));
6262
out = Rf_allocVector(RAWSXP, sz);
6363
memcpy(RAW(out), COMPLEX(object), sz);
6464
break;
@@ -130,7 +130,7 @@ SEXP nano_decode(unsigned char *buf, const size_t sz, const int mod, const int k
130130
} else {
131131
switch (mod) {
132132
case 3:
133-
data = Rf_allocVector(CPLXSXP, sz / (sizeof(double) * 2));
133+
data = Rf_allocVector(CPLXSXP, sz / (sizeof(double) + sizeof(double)));
134134
memcpy(COMPLEX(data), buf, sz);
135135
break;
136136
case 4:

tests/tests.R

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ nanotestwn(n$send(data.frame(), block = FALSE, echo = FALSE))
3838
nanotestwn(n1$recv(block = FALSE))
3939
nanotestwn(n1$send("test", mode = "raw", block = 500, echo = FALSE))
4040
nanotestwn(n$recv("character", block = 500))
41+
nanotestwn(n1$send(c(1L, 0L, 0L), mode = "raw"))
42+
nanotestwn(n$recv("integer", keep.raw = FALSE))
4143
saio <- n$send_aio(data.frame(), timeout = 500)
4244
nanotest(identical(is_aio(saio), TRUE))
4345
nanotest(identical(is_nano(saio), FALSE))
@@ -87,8 +89,17 @@ nanotest(ctx$protocol == "req")
8789
nanotest(setopt(ctx, "ms", "send-timeout", 1000) == 0L)
8890
nanotestwn(send_aio(ctx, data.frame(), timeout = 500))
8991
nanotestwn(recv_aio(ctx1, timeout = 500, keep.raw = FALSE))
90-
nanotestwn(send(ctx, "context test", mode ="raw", block = 500, echo = FALSE))
91-
nanotestwn(recv(ctx1, mode = "character", block = 100))
92+
nanotestwn(send(ctx, "context test", mode ="raw", block = 300, echo = FALSE))
93+
nanotestwn(recv(ctx1, mode = "character", block = 300))
94+
nanotestwn(send(ctx, data.frame(), block = 400))
95+
msg <- recv_aio(ctx1, mode = "serial", timeout = 400, keep.raw = FALSE)
96+
nanotest(is.logical(unresolved(msg)))
97+
nanotestn(call_aio(msg)$data)
98+
nanotest(unresolved(msg) == FALSE)
99+
nanotestwn(send(ctx, c(TRUE, FALSE, TRUE), block = 500))
100+
msg <- recv_aio(ctx1, mode = "logical", timeout = 500)
101+
nanotestn(call_aio(msg)$raw)
102+
nanotestwn(request(ctx, data.frame(), recv_mode = "complex", timeout = 100))
92103
nanotest(close(ctx) == 0L)
93104
nanotestw(close(ctx) > 0L)
94105
nanotest(ctx$state == "closed")

0 commit comments

Comments
 (0)