-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: set up nightly devnet sync on github (#3595)
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |