From 9b6f10183d6827cf2a74de4b7646135b596f0b5a Mon Sep 17 00:00:00 2001 From: air1one <36802613+air1one@users.noreply.github.com> Date: Wed, 11 Mar 2020 18:26:10 +0400 Subject: [PATCH] ci: set up nightly devnet sync on github (#3595) --- .github/sync-script/sync-script.sh | 16 ++++++++ .github/workflows/devnet-sync.yml | 65 ++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .github/sync-script/sync-script.sh create mode 100644 .github/workflows/devnet-sync.yml diff --git a/.github/sync-script/sync-script.sh b/.github/sync-script/sync-script.sh new file mode 100644 index 0000000000..3b31796aa2 --- /dev/null +++ b/.github/sync-script/sync-script.sh @@ -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 \ No newline at end of file diff --git a/.github/workflows/devnet-sync.yml b/.github/workflows/devnet-sync.yml new file mode 100644 index 0000000000..a96b8abb73 --- /dev/null +++ b/.github/workflows/devnet-sync.yml @@ -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