diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ab660e5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: Test + +on: + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x, 12.x, 14.x, 16.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install + run: npm install + - name: Test + run: | + npm run test:coverage --if-present + npm run lint --if-present + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.npmignore b/.npmignore index e283996..f83089d 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,6 @@ .npmignore .gitignore -.eslintrc +.eslintrc.js .git/ .lock-* node_modules/ @@ -14,4 +14,4 @@ cli/ coverage/ img/ mrd/ -*.tpl \ No newline at end of file +.github/ diff --git a/README.md b/README.md index 2ef5475..797e85f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -Ya Rfc (Remote Function Execution) is a [rpc](https://en.wikipedia.org/wiki/Remote_procedure_call) library for Node js. +# ya-rfc [![npm version](https://badge.fury.io/js/ya-rfc.svg)](http://badge.fury.io/js/ya-rfc) [![license](https://img.shields.io/npm/l/ya-rfc.svg)](http://badge.fury.io/js/ya-rfc) [![test](https://github.com/nicocoul/ya-rfc/actions/workflows/test.yml/badge.svg)](https://github.com/nicocoul/ya-rfc/actions/workflows/test.yml) [![Coverage](https://coveralls.io/repos/github/nicocoul/ya-rfc/badge.svg?branch=main)](https://coveralls.io/github/nicocoul/ya-rfc?branch=main) [![Activity](https://img.shields.io/github/commit-activity/m/nicocoul/ya-rfc)](https://github.com/badges/shields/pulse) +Ya Rfc (Remote Function Call) is a [rpc](https://en.wikipedia.org/wiki/Remote_procedure_call) library for Node js. Integrates well with [ya-pubsub](https://www.npmjs.com/package/ya-pubsub). diff --git a/README.md.tpl b/README.md.tpl deleted file mode 100644 index c91a968..0000000 --- a/README.md.tpl +++ /dev/null @@ -1,29 +0,0 @@ -Ya Rfc (Remote Function Execution) is a [rpc](https://en.wikipedia.org/wiki/Remote_procedure_call) library for Node js. - -Integrates well with [ya-pubsub](https://www.npmjs.com/package/ya-pubsub). - -### Key Features -* asynchronous -* embeddable -* designed for micro-services - -### Execution Flow -![basic execution flow](https://github.com/nicocoul/ya-rfc/blob/dev/img/basicExecFlow.png) - -### Basic Example -Given a module accessible by the RFC server -```javascript -{{{examples.procedures}}} -``` -function 'count' can be executed remotely over tcp -```javascript -{{{examples.tcp}}} -``` -or over websockets -```javascript -{{{examples.ws}}} -``` - -## Versioning - -Yaps-node uses [Semantic Versioning](http://semver.org/) for predictable versioning. diff --git a/cli/README.md.tpl b/cli/README.md.tpl new file mode 100644 index 0000000..1992d88 --- /dev/null +++ b/cli/README.md.tpl @@ -0,0 +1,30 @@ +# ya-rfc [![npm version](https://badge.fury.io/js/ya-rfc.svg)](http://badge.fury.io/js/ya-rfc) [![license](https://img.shields.io/npm/l/ya-rfc.svg)](http://badge.fury.io/js/ya-rfc) [![test](https://github.com/nicocoul/ya-rfc/actions/workflows/test.yml/badge.svg)](https://github.com/nicocoul/ya-rfc/actions/workflows/test.yml) [![Coverage](https://coveralls.io/repos/github/nicocoul/ya-rfc/badge.svg?branch=main)](https://coveralls.io/github/nicocoul/ya-rfc?branch=main) [![Activity](https://img.shields.io/github/commit-activity/m/nicocoul/ya-rfc)](https://github.com/badges/shields/pulse) +Ya Rfc (Remote Function Call) is a [rpc](https://en.wikipedia.org/wiki/Remote_procedure_call) library for Node js. + +Integrates well with [ya-pubsub](https://www.npmjs.com/package/ya-pubsub). + +### Key Features +* asynchronous +* embeddable +* designed for micro-services + +### Execution Flow +![basic execution flow](https://github.com/nicocoul/ya-rfc/blob/dev/img/basicExecFlow.png) + +### Basic Example +Given a module accessible by the RFC server +```javascript +{{{examples.procedures}}} +``` +function 'count' can be executed remotely over tcp +```javascript +{{{examples.tcp}}} +``` +or over websockets +```javascript +{{{examples.ws}}} +``` + +## Versioning + +Yaps-node uses [Semantic Versioning](http://semver.org/) for predictable versioning. diff --git a/cli/render-readme.js b/cli/render-readme.js index 800ef1d..7d8afbd 100644 --- a/cli/render-readme.js +++ b/cli/render-readme.js @@ -33,6 +33,6 @@ fs.readdirSync(mrdPath).forEach(entry => { convert(path.join(mrdPath, entry), path.join(imgPath, `${path.parse(entry).name}.png`)) }) -const template = fs.readFileSync(path.join(__dirname, '..', 'README.md.tpl'), { encoding: 'utf8' }) +const template = fs.readFileSync(path.join(__dirname, 'README.md.tpl'), { encoding: 'utf8' }) const result = mustache.render(template, { examples }) fs.writeFileSync(path.join(__dirname, '..', 'README.md'), result, { encoding: 'utf8' }) diff --git a/package.json b/package.json index 5f4109d..6996b66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ya-rfc", - "version": "0.1.8", + "version": "0.1.9", "description": "", "main": "index.js", "author": "Nicolas Coulon (https://github.com/nicocoul)", diff --git a/tests/brokers/rpc.test.js b/tests/brokers/rpc.test.js index 7ec0c52..2a82d30 100644 --- a/tests/brokers/rpc.test.js +++ b/tests/brokers/rpc.test.js @@ -7,7 +7,7 @@ const rpcBroker = require('../../lib/brokers/rpc') const rpcServer = require('../../lib/clients/rpc-server') function newRpcServer (channel) { - return rpcServer.create(channel, path.join(__dirname, 'fixtures', 'rpc-module')) + return rpcServer.create(channel, path.join(__dirname, '..', 'fixtures', 'rpc-module')) } describe('Rpc broker', () => { diff --git a/tests/clients/fixtures/rpc-module.js b/tests/clients/fixtures/rpc-module.js deleted file mode 100644 index 795102b..0000000 --- a/tests/clients/fixtures/rpc-module.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' -module.exports = { - funcWithResult: (a) => a, - funcWithProgress: (onProgress) => { - console.log('on', onProgress) - onProgress('done') - }, - functWithoutResult: () => { }, - functThatThrows: () => { throw new Error('some error') }, - asyncFunc: (a) => (new Promise(resolve => resolve(a))) -} diff --git a/tests/clients/rpc-server.test.js b/tests/clients/rpc-server.test.js index 8120497..adb0f14 100644 --- a/tests/clients/rpc-server.test.js +++ b/tests/clients/rpc-server.test.js @@ -5,7 +5,7 @@ const { COMMANDS } = yac.constants const rpc = require('../../lib/clients/rpc-server') const logger = yac.logger(__filename) -const modulePath = path.join(__dirname, 'fixtures', 'rpc-module') +const modulePath = path.join(__dirname, '..', 'fixtures', 'rpc-module') describe('Rcp server', () => { test('executes a function that returns a value', async () => { diff --git a/tests/clients/rpc-worker.test.js b/tests/clients/rpc-worker.test.js index 231b286..37953ac 100644 --- a/tests/clients/rpc-worker.test.js +++ b/tests/clients/rpc-worker.test.js @@ -4,7 +4,7 @@ const path = require('path') function createWorker () { const result = fork(path.join(__dirname, '..', '..', 'lib', 'clients', 'rpc-worker.js')) - result.send({ modulePath: path.join(__dirname, 'fixtures', 'rpc-module') }) + result.send({ modulePath: path.join(__dirname, '..', 'fixtures', 'rpc-module') }) return result } diff --git a/tests/e2e/fixtures/rpc-module.js b/tests/e2e/fixtures/rpc-module.js deleted file mode 100644 index 795102b..0000000 --- a/tests/e2e/fixtures/rpc-module.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' -module.exports = { - funcWithResult: (a) => a, - funcWithProgress: (onProgress) => { - console.log('on', onProgress) - onProgress('done') - }, - functWithoutResult: () => { }, - functThatThrows: () => { throw new Error('some error') }, - asyncFunc: (a) => (new Promise(resolve => resolve(a))) -} diff --git a/tests/e2e/rpc-tcp.test.js b/tests/e2e/rpc-tcp.test.js index 66b1a7a..5c66c0d 100644 --- a/tests/e2e/rpc-tcp.test.js +++ b/tests/e2e/rpc-tcp.test.js @@ -12,7 +12,7 @@ const netChannel = yac.channels.net function newServer (port) { const channel = netChannel('localhost', port) - return rpcServer.create(channel, path.join(__dirname, 'fixtures', 'rpc-module')) + return rpcServer.create(channel, path.join(__dirname, '..', 'fixtures', 'rpc-module')) } function newClient (port) { diff --git a/tests/brokers/fixtures/rpc-module.js b/tests/fixtures/rpc-module.js similarity index 100% rename from tests/brokers/fixtures/rpc-module.js rename to tests/fixtures/rpc-module.js