Skip to content

Commit 4d7cf5e

Browse files
committed
Add workflows
1 parent 7979258 commit 4d7cf5e

File tree

4 files changed

+194
-6
lines changed

4 files changed

+194
-6
lines changed

.github/workflows/npm-publish.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: GridDB node-api create package on release to npm
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
publish-npm:
9+
10+
runs-on: ubuntu-latest
11+
12+
env:
13+
CENTOS_VERSION: 7
14+
GRIDDB_DOCKER_SERVER: griddb/griddb
15+
GRIDDB_NOTIFICATION_ADDRESS: "239.0.0.1"
16+
GRIDDB_NOTIFICATION_PORT: "31999"
17+
GRIDDB_CLUSTER_NAME: "dockerGridDB"
18+
GRIDDB_USERNAME: "admin"
19+
GRIDDB_PASSWORD: "admin"
20+
DOCKER_CONTAINER_NAME_CENTOS: "griddbCentosDocker"
21+
steps:
22+
- uses: actions/checkout@v3
23+
- name: Start GridDB server
24+
run: |
25+
docker pull ${GRIDDB_DOCKER_SERVER}
26+
docker run -d --network="host" ${GRIDDB_DOCKER_SERVER}
27+
28+
- name: Pull and run docker image centos7
29+
run: . .github/workflows/prepublish-npm.sh && pull_run_docker
30+
31+
- name: Install dependencies "C API , Node"
32+
run: . .github/workflows/prepublish-npm.sh && install_dependency
33+
34+
- name: Build GridDB node-api
35+
run: . .github/workflows/prepublish-npm.sh && build_node_api
36+
37+
- name: Run sample on CentOS 7
38+
run: . .github/workflows/prepublish-npm.sh && run_sample_centos7
39+
40+
- uses: actions/setup-node@v3
41+
with:
42+
node-version: 16
43+
registry-url: https://registry.npmjs.org/
44+
- name: Run sample on Ubuntu 20.04
45+
run: . .github/workflows/prepublish-npm.sh && run_sample_ubuntu
46+
47+
- name: Rename file from README-NPM to README
48+
run: mv README-NPM.md README.md # README file for npm publish
49+
50+
- name: Publish package to NPM
51+
run: npm publish
52+
env:
53+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.github/workflows/prepublish-npm.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/sh -xe
2+
3+
pull_run_docker() {
4+
# Pull and run image centos docker
5+
docker pull centos:centos${CENTOS_VERSION}
6+
docker run --network="host" --name ${DOCKER_CONTAINER_NAME_CENTOS} -ti -d -v `pwd`:/node-api -w/node-api centos:centos${CENTOS_VERSION}
7+
}
8+
9+
# Install dependency, support for griddb node-api
10+
install_dependency() {
11+
# Install C API latest version on https://build.opensuse.org/ site
12+
docker exec ${DOCKER_CONTAINER_NAME_CENTOS} /bin/bash -xec "set -eux \
13+
&& yum update -y \
14+
&& yum install -y curl python3 python3-devel centos-release-scl \
15+
&& yum install -y devtoolset-7 --nogpgcheck \
16+
&& yum install -y devtoolset-7-gcc-c++ --nogpgcheck \
17+
&& cd /etc/yum.repos.d/ \
18+
&& curl https://download.opensuse.org/repositories/home:/knonomura/CentOS_7/home:knonomura.repo -o /etc/yum.repos.d/home:knonomura.repo \
19+
&& yum install -y griddb-c-client \
20+
&& yum clean all"
21+
22+
# Install node version 16.x
23+
docker exec ${DOCKER_CONTAINER_NAME_CENTOS} /bin/bash -xec "set -eux \
24+
&& curl -sL https://rpm.nodesource.com/setup_16.x | bash - \
25+
&& yum install -y nodejs --nogpgcheck \
26+
&& npm --version \
27+
&& yum clean all"
28+
}
29+
30+
build_node_api() {
31+
# Build GridDB node-api
32+
docker exec ${DOCKER_CONTAINER_NAME_CENTOS} /bin/bash -xec "source /opt/rh/devtoolset-7/enable && npm install && gcc --version && g++ --version"
33+
}
34+
35+
run_sample_centos7() {
36+
# Run sample on CentOS 7
37+
docker exec ${DOCKER_CONTAINER_NAME_CENTOS} /bin/bash -xec "export NODE_PATH=/node-api && \
38+
node sample/sample1.js ${GRIDDB_NOTIFICATION_ADDRESS} ${GRIDDB_NOTIFICATION_PORT} ${GRIDDB_CLUSTER_NAME} ${GRIDDB_USERNAME} ${GRIDDB_PASSWORD}"
39+
}
40+
41+
# Run sample Node-api on OS ubuntu 20.04
42+
run_sample_ubuntu() {
43+
# Install C API
44+
echo 'deb http://download.opensuse.org/repositories/home:/knonomura/xUbuntu_18.04/ /' | sudo tee /etc/apt/sources.list.d/home:knonomura.list
45+
curl -fsSL https://download.opensuse.org/repositories/home:knonomura/xUbuntu_18.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_knonomura.gpg > /dev/null
46+
sudo apt update -y
47+
sudo apt install griddb-c-client -y
48+
# Run sample
49+
export NODE_PATH=`pwd`
50+
node sample/sample1.js ${GRIDDB_NOTIFICATION_ADDRESS} ${GRIDDB_NOTIFICATION_PORT} ${GRIDDB_CLUSTER_NAME} ${GRIDDB_USERNAME} ${GRIDDB_PASSWORD}
51+
}

README-NPM.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
GridDB Node API
2+
3+
## Overview
4+
5+
[GridDB](https://github.com/griddb/griddb) is Database for IoT with both NoSQL interface and SQL Interface.
6+
7+
GridDB Node API is developed using GridDB C Client and [node-addon-api](https://github.com/nodejs/node-addon-api).
8+
9+
## Operating environment
10+
11+
Building of the library and execution of the sample programs have been checked in the following environment.
12+
13+
OS: CentoS7.9(x64), Ubuntu 18.04(x64), Ubuntu 20.04(x64)
14+
Node.js: v16
15+
gcc/g++: >= 7
16+
GridDB C client: V5.0.0 CE
17+
GridDB server: V5.0.0 CE, CentOS 7.9(x64)
18+
19+
## Preparations
20+
21+
* Install [GridDB Server](https://github.com/griddb/griddb)
22+
* Install [C Client](https://github.com/griddb/c_client).
23+
* (Ubuntu)
24+
```console
25+
$ wget https://github.com/griddb/c_client/releases/download/v5.0.0/griddb-c-client_5.0.0_amd64.deb
26+
$ sudo dpkg -i griddb-c-client_5.0.0_amd64.deb
27+
```
28+
* (CentOS)
29+
```console
30+
$ wget https://github.com/griddb/c_client/releases/download/v5.0.0/griddb-c-client-5.0.0-linux.x86_64.rpm
31+
$ sudo rpm -ivh griddb-c-client-5.0.0-linux.x86_64.rpm
32+
```
33+
## QuickStart
34+
35+
### Install
36+
37+
$ npm install griddb-node-api
38+
39+
### How to run sample
40+
41+
GridDB Server need to be started in advance.
42+
43+
1. The command to run sample
44+
$ cp node_modules/griddb-node-api/sample/sample1.js .
45+
$ node sample1.js <GridDB notification address> <GridDB notification port>
46+
<GridDB cluster name> <GridDB user> <GridDB password>
47+
-->[ 'name01', false, 1, <Buffer 41 42 43 44 45 46 47 48 49 4a> ]
48+
49+
### Install gcc/g++:
50+
1. CentOS 7(x64)
51+
```console
52+
# Install gcc/g++ 7 on centos 7.9
53+
$ sudo yum install centos-release-scl
54+
$ sudo yum install devtoolset-7-gcc-c++
55+
56+
# enable gcc/g++7 on centos 7.9
57+
$ scl enable devtoolset-7 bash
58+
```
59+
2. Ubuntu 18.04/20.04(x64)
60+
```
61+
$ sudo apt-get install gcc g++
62+
```

package.json

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,35 @@
22
"dependencies": {
33
"node-addon-api": "*"
44
},
5-
"scripts": {
6-
"test": "node sample/sample1.js"
7-
},
85
"gypfile": true,
96
"name": "griddb-node-api",
10-
"version": "0.8.5",
11-
"description": "Node API for GridDB",
7+
"version": "0.8.6",
8+
"description": "GridDB Node API is developed using GridDB C Client and node-addon-api.",
9+
"main": "griddb-node-api.js",
10+
"scripts": {
11+
"test": "echo \"Error: no test specified\" && exit 1"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "git+https://github.com/griddb/node-api.git"
16+
},
17+
"keywords": [
18+
"griddb",
19+
"client",
20+
"libgridstore",
21+
"iot"
22+
],
1223
"author": "TOSHIBA Digital Solutions Corporation",
13-
"license": "Apache-2.0"
24+
"license": "Apache-2.0",
25+
"bugs": {
26+
"url": "https://github.com/griddb/node-api/issues"
27+
},
28+
"homepage": "https://github.com/griddb/node-api#readme",
29+
"files": [
30+
"griddb-node-api.js",
31+
"griddb.node",
32+
"package.json",
33+
"sample",
34+
"README.md"
35+
]
1436
}

0 commit comments

Comments
 (0)