Skip to content

Commit

Permalink
add GitHub workflow for unit testing and npm publish (#17)
Browse files Browse the repository at this point in the history
* enhance ci: add auto unit tests

* remove open

* update test-data.md

* change unit test name

* add auto npm publish
  • Loading branch information
wujjpp authored Jun 10, 2022
1 parent 2e11570 commit cec2574
Show file tree
Hide file tree
Showing 11 changed files with 505 additions and 9 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Startup Nebula
run: |
cd ./.nebula-up
rm -rf ./data ./log
docker-compose up -d
echo "Sleep 20s for waiting nebula cluster"
sleep 20
./check.sh
echo "Create space nebula_node"
./console.sh -e "create space nebula_node(vid_type = FIXED_STRING(30));"
echo "Sleep 10s for space creating"
sleep 10
./console.sh -f /root/init-create.ngql
echo "Sleep 30s for schema creating"
sleep 30
./console.sh -f /root/init-data.ngql
cd ..
- run: npm run build
- run: npm run test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 14
registry-url: https://registry.npmjs.org/
- run: npm run build
- run: cd dist && npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
41 changes: 41 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Unit Test
on: [push]
jobs:
unit-test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x]

steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Startup Nebula
run: |
cd ./.nebula-up
rm -rf ./data ./log
docker-compose up -d
echo "Sleep 20s for waiting nebula cluster"
sleep 20
./check.sh
echo "Create space nebula_node"
./console.sh -e "create space nebula_node(vid_type = FIXED_STRING(30));"
echo "Sleep 10s for space creating"
sleep 10
./console.sh -f /root/init-create.ngql
echo "Sleep 30s for schema creating"
sleep 30
./console.sh -f /root/init-data.ngql
cd ..
- name: Unit Test
run: |
npm install --unsafe-perm
npm run coverage
1 change: 1 addition & 0 deletions .nebula-up/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TZ=UTC
31 changes: 31 additions & 0 deletions .nebula-up/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

retries=0

while :
do
retries=$((retries+1))

echo "#${retries} - Starting checking nebula graphd..."
if curl -sL --fail http://127.0.0.1:19669;
then
echo "Result: Successfully"
exit 0
fi

echo "Result: Failed"

if [ $retries -gt 120 ];
then
echo "Max retry limitation exceeded"
exit 1
fi

docker-compose ps

echo "Sleep 10s"

sleep 10
done

exit 0
10 changes: 10 additions & 0 deletions .nebula-up/console.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Copyright (c) 2021 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License,


# Usage: console.sh or console.sh -e "SHOW HOSTS"

export DOCKER_DEFAULT_PLATFORM=linux/amd64;
docker run --rm -v $PWD:/root --network nebula-up_nebula-net vesoft/nebula-console:v3.0.0 -addr graphd -port 9669 -u root -p nebula "$@"
Loading

0 comments on commit cec2574

Please sign in to comment.