Skip to content

chore(Github Action|CI): add Github Action for testing #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/ci-dgraph-js-http.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

name: ci-dgraph-js-http-tests

on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- master

jobs:
build:

runs-on: ubuntu-20.04

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 19.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install Dependencies
run: bash ./scripts/install_dgraph.sh
- name: run tests
run: |
npm ci --legacy-peer-deps
bash ./scripts/build.sh
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

5 changes: 4 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e
set -x

source scripts/functions.sh
source ./scripts/functions.sh

init
startZero
Expand All @@ -12,6 +12,9 @@ start
sleep 10 # Dgraph need some time to create Groot user

npm run build

curl http://localhost:8080/health

npm test

quit 0
12 changes: 4 additions & 8 deletions scripts/functions.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/bin/bash

sleepTime=5
if [[ "$TRAVIS" == true ]]; then
sleepTime=30
fi

function quit {
echo "Shutting down Dgraph alpha and zero."
Expand All @@ -24,22 +21,21 @@ function quit {

function start {
echo -e "Starting Dgraph alpha."
head -c 1024 /dev/random > data/acl-secret.txt
dgraph alpha -p data/p -w data/w --lru_mb 4096 --acl_secret_file data/acl-secret.txt > data/alpha.log 2>&1 &
head -c 1024 /dev/random > ./scripts/data/acl-secret.txt
dgraph alpha -p ./scripts/data/p -w ./scripts/data/w --bindall --my localhost:7080 --acl "access-ttl=1h; refresh-ttl=1d; secret-file=./scripts/data/acl-secret.txt"> ./scripts/data/alpha.log 2>&1 &
# Wait for membership sync to happen.
sleep $sleepTime
return 0
}

function startZero {
echo -e "Starting Dgraph zero.\n"
dgraph zero -w data/wz > data/zero.log 2>&1 &
dgraph zero --my localhost:5080 --bindall -w ./scripts/data/wz> ./scripts/data/zero.log 2>&1 &
# To ensure Dgraph doesn't start before Dgraph zero.
# It takes time for zero to start on travis mac.
sleep $sleepTime
}

function init {
echo -e "Initializing.\n"
mkdir data
mkdir ./scripts/data
}