Skip to content

Commit

Permalink
ci: set up nightly devnet sync on github (#3595)
Browse files Browse the repository at this point in the history
  • Loading branch information
air1one authored Mar 11, 2020
1 parent 77c9a88 commit 9b6f101
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/sync-script/sync-script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
# Sync script, just waits till the node running on localhost is synced

starttime=$(date +%s)
synced=0

while test $synced != 1
do
tail output.log # the node must redirect its output to output.log
currtime=$(date +%s)
difftime=`expr $currtime - $starttime`
echo "still not synced after $difftime seconds..."
if [ $difftime -gt 18000 ] ; then exit 1 ; fi # exit with error after 5 hours
sleep 6
synced=$(curl http://127.0.0.1:4003/api/v2/node/status -m 2 | grep "\"synced\":true" | wc -l)
done
65 changes: 65 additions & 0 deletions .github/workflows/devnet-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Devnet sync

on:
schedule:
- cron: '0 1 * * *'

jobs:
devnet-sync:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:10.8
env:
POSTGRES_USER: ark
POSTGRES_PASSWORD: password
POSTGRES_DB: ark_unitnet
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

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

steps:
- uses: actions/checkout@v2
with:
ref: 2.6
- name: Cache node modules
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-node-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Update system
run: sudo apt-get update -y
- name: Install xsel & postgresql-client
run: sudo apt-get install -q xsel postgresql-client
- name: Install and build packages
run: yarn setup
- name: Create .core/database directory
run: mkdir -p $HOME/.core/database
- name: Make sync script executable
run: chmod +x .github/sync-script/sync-script.sh
- name: devnet sync
run: packages/core/bin/run relay:run --network=devnet > output.log 2> errors.log & .github/sync-script/sync-script.sh
env:
CORE_DB_DATABASE: ark_unitnet
CORE_DB_USERNAME: ark
POSTGRES_USER: ark
POSTGRES_PASSWORD: password
POSTGRES_DB: ark_unitnet
CORE_PATH_CONFIG: packages/core/bin/config/devnet
CORE_PATH_DATA: packages/core/bin/config/devnet
- name: Last 1000 lines of node output
if: always()
run: tail -n 1000 output.log
- name: Errors (if any)
if: always()
run: echo "" >> errors.log && tail -n 1000 errors.log

0 comments on commit 9b6f101

Please sign in to comment.