Skip to content
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

Features/gh actions - Adds a build, start, test on schedule (every day) + on push to dev #272

Open
wants to merge 50 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d210bc7
testing actions
phillamy May 30, 2022
c22d514
testing again
phillamy May 30, 2022
b138684
unattended setup fix
phillamy May 30, 2022
99e3fa6
clean cmd line
phillamy May 30, 2022
142957f
chmod 0755
phillamy May 30, 2022
f75851c
path fix
phillamy May 30, 2022
802b71e
config with LN
phillamy May 30, 2022
5e49f4e
dist dir creation
phillamy May 30, 2022
b07037c
run test from everywhere + remove interactive exec
phillamy May 30, 2022
fe57acd
Merge remote-tracking branch 'upstream/dev' into features/github-actions
phillamy May 30, 2022
7309b88
remove interactive mode
phillamy May 30, 2022
1c64f67
Fix for no TTY in GH action
phillamy May 30, 2022
6fbd3c3
added return code so process returns
phillamy May 30, 2022
892556c
Added -it to callback
phillamy May 30, 2022
445600b
removed TTY for mine.sh
phillamy May 30, 2022
7620a2b
return return code
phillamy May 30, 2022
014d2d2
trying wo subrocess
phillamy May 30, 2022
cdac592
testing with pid in wait
phillamy May 30, 2022
f432eb5
subprocess
phillamy May 31, 2022
1378da8
more tests
phillamy May 31, 2022
56f5a99
Dump logs
phillamy May 31, 2022
661a213
testing race
phillamy May 31, 2022
b945d39
remove race to mine
phillamy May 31, 2022
180520c
remote -it to docker exec
phillamy May 31, 2022
a1c7a88
Removed sleep to avoid race cond
phillamy May 31, 2022
35991d2
Test error to get Docker logs
phillamy May 31, 2022
b75d21b
test CN ready with crash
phillamy May 31, 2022
fae9258
Remove forced crash
phillamy May 31, 2022
86c6546
Adding wathpub32 tests
phillamy May 31, 2022
2027a35
Fixe source paths
phillamy May 31, 2022
43b3acc
removed docker -it
phillamy May 31, 2022
7cdbe03
removed exec -it
phillamy Jun 1, 2022
2815054
added return code
phillamy Jun 1, 2022
5b34d59
added test cases
phillamy Jun 1, 2022
63b2b90
Display return code on exit
phillamy Jun 1, 2022
332eff6
Merge remote-tracking branch 'upstream/dev' into features/gh-actions
phillamy Jun 15, 2022
99be7dc
added gatekeeper tests
phillamy Jun 15, 2022
e2460bb
Build every day
phillamy Jun 16, 2022
4ee1ce4
build dev every day
phillamy Jun 16, 2022
6784958
use default branch
phillamy Jun 28, 2022
7b888ff
trigger on push
phillamy Jun 28, 2022
fc8a0cf
removed ls dir
phillamy Jun 28, 2022
81d24b7
fixed syntax err
phillamy Jun 28, 2022
159de67
Merge remote-tracking branch 'upstream/dev' into features/gh-actions
phillamy Jul 3, 2022
046c546
new branch
phillamy Jul 3, 2022
33d59b5
Added tests.sh
phillamy Jul 3, 2022
6f830ea
removed watch tests from tests.sh
phillamy Jul 7, 2022
a6ff4a3
Run on dev branch on features**
phillamy Jul 7, 2022
adc8ec1
Run schedule on dev branch and push on dev
phillamy Jul 7, 2022
62efbfa
Removed features branch trigger
phillamy Jul 9, 2022
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
Binary file added .github/ci-config/client.7z
Binary file not shown.
Binary file added .github/ci-config/config.7z
Binary file not shown.
4 changes: 4 additions & 0 deletions .github/ci-config/copy-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

mkdir ./dist; chmod u=rwx,go=rx dist
cp ./.github/ci-config/*.7z ./dist
65 changes: 65 additions & 0 deletions .github/workflows/build-cn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build Cyphernode every day & on push on branch dev
on:
push:
branches:
- dev
schedule:
- cron: "0 0 * * *"

jobs:
Build-Cyphernode:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."

- if: ${{ github.event_name == 'push' }}
name: Check out repository code
uses: actions/checkout@v3

- if: ${{ github.event_name == 'schedule' }}
name: Check out repository dev
uses: actions/checkout@v3
with:
ref: 'dev'

- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."

- name: Run build script
run: ./build.sh
shell: bash

- name: Copy default config
run: ./.github/ci-config/copy-config.sh
shell: bash

- name: Run Cyphernode Setup
run: env CFG_PASSWORD="qq" ./dist/setup.sh -irc <<< 'y\n'
shell: bash

- name: Start Cyphernode
run: ./dist/start.sh
shell: bash

- name: Run test
shell: 'script -q -e -c "bash {0}"'
run: |
./api_auth_docker/tests/test-gatekeeper.sh
./proxy_docker/app/tests/test-watches.sh
./proxy_docker/app/tests/test-watchpub32.sh
./proxy_docker/app/tests/test-manage-missed.sh
./proxy_docker/app/tests/test-derive.sh
./proxy_docker/app/tests/test-batching.sh
./proxy_docker/app/tests/tests.sh

- name: Stop Cyphernode
run: ./dist/stop.sh
shell: bash

- name: Dump docker logs on failure
if: failure()
uses: jwalton/gh-docker-logs@v1

- run: echo "🍏 This job's status is ${{ job.status }}."
18 changes: 10 additions & 8 deletions dist/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,15 @@ configure() {

if [[ $CFG_PASSWORD ]]; then
pw_env=" -e CFG_PASSWORD=$CFG_PASSWORD"
fi

echo "\nDetermining the speed of your machine..."
local speedseconds=$(bash -c ' : {1..500000} ; echo $SECONDS')
if [[ $speedseconds > 2 ]]; then
clear && echo "This may take a while, since it seems we're running on a slow machine."
interactive=''
else
clear && echo "Fast machine..."
echo "\nDetermining the speed of your machine..."
local speedseconds=$(bash -c ' : {1..500000} ; echo $SECONDS')
if [[ $speedseconds > 2 ]]; then
clear && echo "This may take a while, since it seems we're running on a slow machine."
else
clear && echo "Fast machine..."
fi
fi

# before starting a new cyphernodeconf, kill all the others
Expand Down Expand Up @@ -213,7 +214,8 @@ configure() {
-e LIGHTNING_VERSION=$LIGHTNING_VERSION \
-e CONF_VERSION=$CONF_VERSION \
-e SETUP_VERSION=$SETUP_VERSION \
--log-driver=none$pw_env \
$pw_env \
--log-driver=none \
--network none \
--rm$interactive cyphernode/cyphernodeconf:$CONF_VERSION $user node index.js$recreate
if [[ -f $cyphernodeconf_filepath/exitStatus.sh ]]; then
Expand Down
2 changes: 1 addition & 1 deletion proxy_docker/app/tests/mine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mine() {
local nbblocks=${1:-1}

echo ; echo "About to mine ${nbblocks} block(s)..."
docker exec -t $(docker ps -q -f "name=cyphernode.bitcoin") bitcoin-cli -rpcwallet=spending01.dat -generate ${nbblocks}
docker exec $(docker ps -q -f "name=cyphernode.bitcoin") bitcoin-cli -rpcwallet=spending01.dat -generate ${nbblocks}
}

case "${0}" in *mine.sh) mine $@;; esac
11 changes: 8 additions & 3 deletions proxy_docker/app/tests/test-batching.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

. ./colors.sh
DIR="$( dirname -- "${BASH_SOURCE[0]}"; )";
. $DIR/colors.sh

# This needs to be run in regtest
# You need jq installed for these tests to run correctly
Expand Down Expand Up @@ -62,7 +63,7 @@ stop_test_container() {
}

exec_in_test_container() {
docker exec -it tests-batching "$@"
docker exec tests-batching "$@"
}


Expand Down Expand Up @@ -398,6 +399,7 @@ start_callback_server() {
}

TRACING=3
returncode=0

stop_test_container
start_test_container
Expand All @@ -409,10 +411,13 @@ trace 1 "\n\n[test-batching] ${BCyan}Installing needed packages...${Color_Off}\n
exec_in_test_container apk add --update curl

testbatching
returncode=$?

trace 1 "\n\n[test-batching] ${BCyan}Tearing down...${Color_Off}\n"
wait

stop_test_container

trace 1 "\n\n[test-batching] ${BCyan}See ya!${Color_Off}\n"
trace 1 "\n\n[test-batching] ${BCyan}See ya! returncode=[${returncode}]${Color_Off}\n"

exit ${returncode}
8 changes: 5 additions & 3 deletions proxy_docker/app/tests/test-derive.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

. ./colors.sh
DIR="$( dirname -- "${BASH_SOURCE[0]}"; )";
. $DIR/colors.sh

# You need jq installed for these tests to run correctly
# You need to configure cyphernode with a default xpub for these tests to work.
Expand Down Expand Up @@ -150,13 +151,14 @@ start_test_container
trace 1 "\n\n[test-derive] ${BCyan}Installing needed packages...${Color_Off}\n"
exec_in_test_container apk add --update curl

returncode=$(tests_derive)
tests_derive
returncode=$?

trace 1 "\n\n[test-derive] ${BCyan}Tearing down...${Color_Off}\n"
wait

stop_test_container

trace 1 "\n\n[test-derive] ${BCyan}See ya!${Color_Off}\n"
trace 1 "\n\n[test-derive] ${BCyan}See ya! returncode=[${returncode}]${Color_Off}\n"

exit ${returncode}
21 changes: 16 additions & 5 deletions proxy_docker/app/tests/test-manage-missed.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

. ./colors.sh
. ./mine.sh
DIR="$( dirname -- "${BASH_SOURCE[0]}"; )";
. $DIR/colors.sh
. $DIR/mine.sh

# This needs to be run in regtest
# You need jq installed for these tests to run correctly
Expand Down Expand Up @@ -35,7 +36,7 @@ stop_test_container() {
}

exec_in_test_container() {
docker exec -it tests-manage-missed $@
docker exec tests-manage-missed $@
}

wait_for_proxy() {
Expand Down Expand Up @@ -78,7 +79,7 @@ test_manage_missed_0_conf() {
docker restart $(docker ps -q -f "name=proxy[^c]")

trace 3 "[test_manage_missed_0_conf] Sending coins to watched address while proxy is down..."
docker exec -it $(docker ps -q -f "name=cyphernode.bitcoin") bitcoin-cli -rpcwallet=spending01.dat sendtoaddress ${address} 0.0001
docker exec $(docker ps -q -f "name=cyphernode.bitcoin") bitcoin-cli -rpcwallet=spending01.dat sendtoaddress ${address} 0.0001
# txid1=$(exec_in_test_container curl -d '{"address":"'${address}'","amount":0.0001}' proxy:8888/spend | jq -r ".txid")

wait_for_proxy
Expand Down Expand Up @@ -115,7 +116,7 @@ test_manage_missed_1_conf() {
trace 3 "[test_manage_missed_1_conf] response=${response}"

trace 3 "[test_manage_missed_1_conf] Sending coins to watched address while proxy is up..."
docker exec -it $(docker ps -q -f "name=cyphernode.bitcoin") bitcoin-cli -rpcwallet=spending01.dat sendtoaddress ${address} 0.0001
docker exec $(docker ps -q -f "name=cyphernode.bitcoin") bitcoin-cli -rpcwallet=spending01.dat sendtoaddress ${address} 0.0001
# txid1=$(exec_in_test_container curl -d '{"address":"'${address}'","amount":0.0001}' proxy:8888/spend | jq -r ".txid")

trace 3 "[test_manage_missed_1_conf] Sleeping for 20 seconds to let the 0-conf callbacks to happen..."
Expand Down Expand Up @@ -145,6 +146,7 @@ wait_for_callbacks() {
}

TRACING=3
returncode=0

stop_test_container
start_test_container
Expand All @@ -162,9 +164,18 @@ trace 2 "url4=${url4}"
exec_in_test_container apk add --update curl

test_manage_missed_0_conf
returncode=$?

[ "${returncode}" -ne "0" ] && exit ${returncode}

test_manage_missed_1_conf
returncode=$?

trace 3 "Waiting for the callbacks to happen..."
wait

stop_test_container

trace 1 "\n\n[test_manage_missed] ${BCyan}See ya! returncode=[${returncode}]${Color_Off}\n"

exit ${returncode}
30 changes: 21 additions & 9 deletions proxy_docker/app/tests/test-watches.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

. ./colors.sh
. ./mine.sh
DIR="$( dirname -- "${BASH_SOURCE[0]}"; )";
. $DIR/colors.sh
. $DIR/mine.sh

# This needs to be run in regtest
# You need jq installed for these tests to run correctly
Expand All @@ -24,7 +25,8 @@ trace() {
}

start_test_container() {
docker run -d --rm -t --name tests-watches --network=cyphernodenet alpine
trace 1 $DIR
docker run -d --rm -t --name tests-watches --network=cyphernodenet -v cyphernode_container_monitor:/container_monitor:ro alpine
}

stop_test_container() {
Expand All @@ -38,7 +40,7 @@ stop_test_container() {
}

exec_in_test_container() {
docker exec -it tests-watches "$@"
docker exec tests-watches "$@"
}

test_watches() {
Expand Down Expand Up @@ -176,7 +178,7 @@ test_watches() {
trace 2 "\n\n[test_watches] ${BCyan}10. Send coins to address1...${Color_Off}\n"
start_callback_server 1111
# Let's use the bitcoin node directly to better simulate an external spend
txid=$(docker exec -it $(docker ps -q -f "name=cyphernode.bitcoin") bitcoin-cli -rpcwallet=spending01.dat sendtoaddress ${address1} 0.0001 | tr -d "\r\n")
txid=$(docker exec $(docker ps -q -f "name=cyphernode.bitcoin") bitcoin-cli -rpcwallet=spending01.dat sendtoaddress ${address1} 0.0001 | tr -d "\r\n")
# txid=$(exec_in_test_container curl -d '{"address":"'${address1}'","amount":0.001}' proxy:8888/spend | jq -r ".txid")
trace 3 "[test_watches] txid=${txid}"
trace 3 "[test_watches] Waiting for 0-conf callback on address1..."
Expand All @@ -202,6 +204,7 @@ test_watches() {

# 14. Generate a block (triggers 1-conf webhook)
trace 3 "[test_manage_missed_1_conf] Mine a new block..."

mine

# 15. Wait for 1-conf webhook
Expand All @@ -214,6 +217,7 @@ test_watches() {

# 17. Generate 2 blocks (triggers 3-conf webhook)
trace 3 "[test_watches] Mine 2 new blocks..."

mine 2

# 18. Wait for 3-conf webhook
Expand Down Expand Up @@ -241,26 +245,34 @@ test_watches() {
}

start_callback_server() {
trace 1 "[start_callback_server] ${BCyan}Let's start the callback servers!...${Color_Off}"

local port=${1:-1111}

trace 1 "[start_callback_server] ${BCyan}Start the callback server [port=${port}]!...${Color_Off}"

docker exec -t tests-watches sh -c "nc -vlp${port} -e sh -c 'echo -en \"HTTP/1.1 200 OK\\\\r\\\\n\\\\r\\\\n\" ; echo -en \"\\033[40m\\033[0;37m\" >&2 ; date >&2 ; timeout 1 tee /dev/tty | cat ; echo -e \"\033[0m\" >&2'" &

trace 1 "[start_callback_server] ${BCyan}server started on [port=${port}] with PID [$!] ${Color_Off}"
}

TRACING=3
returncode=0

stop_test_container
start_test_container

trace 1 "\n\n[test_watches] ${BCyan}Installing needed packages...${Color_Off}\n"
exec_in_test_container apk add --update curl


test_watches
returncode=$?

trace 1 "\n\n[test_watches] ${BCyan}Tearing down...${Color_Off}\n"
wait

stop_test_container

trace 1 "\n\n[test_watches] ${BCyan}See ya!${Color_Off}\n"
wait

trace 1 "\n\n[test_watches] ${BCyan}See ya! returncode=[${returncode}]${Color_Off}\n"

exit ${returncode}
Loading