Skip to content

Commit 1d6a9d2

Browse files
authored
add utiliz directory and other fixes (#75)
* add utiliz directory * ensure that utiliz is created on setup * fix simple directories * add helper too * improve pathing * minor fixes throughout * improvements throughout * workflows * fix workflow * fix workflow * improve start script
1 parent 3126607 commit 1d6a9d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2098
-566
lines changed

.github/workflows/docker-image.yml

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,56 @@ on:
77
branches: [ "main" ]
88

99
jobs:
10-
1110
build:
12-
1311
runs-on: ubuntu-latest
12+
timeout-minutes: 3
1413

1514
steps:
16-
- uses: actions/checkout@v3
17-
- name: Build the Docker image
18-
run: docker build . --file Dockerfile --tag testnet-docker-image:$(date +%s)
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
20+
21+
- name: Log in to Docker Hub (if credentials available)
22+
if: github.event_name != 'pull_request'
23+
uses: docker/login-action@v3
24+
with:
25+
username: ${{ secrets.DOCKER_USERNAME }}
26+
password: ${{ secrets.DOCKER_PASSWORD }}
27+
continue-on-error: true
28+
29+
- name: Extract metadata
30+
id: meta
31+
shell: bash
32+
run: |
33+
set -euo pipefail
34+
echo "tag=$(date +%s)" >> $GITHUB_OUTPUT
35+
echo "sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
36+
37+
- name: Build Docker image
38+
uses: docker/build-push-action@v5
39+
with:
40+
context: .
41+
file: ./Dockerfile
42+
tags: |
43+
testnet-docker-image:${{ steps.meta.outputs.tag }}
44+
testnet-docker-image:${{ steps.meta.outputs.sha }}
45+
cache-from: type=gha
46+
cache-to: type=gha,mode=max
47+
push: false
48+
load: true
49+
50+
- name: Test Docker image
51+
shell: bash
52+
run: |
53+
set -euo pipefail
54+
docker images | grep testnet-docker-image
55+
echo "Docker image built successfully"
56+
57+
- name: Cleanup
58+
if: always()
59+
shell: bash
60+
run: |
61+
set -euo pipefail
62+
docker system prune -f || true

.github/workflows/test-start-node.yml

Lines changed: 98 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,118 @@ on:
99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
12+
timeout-minutes: 3
1213

1314
steps:
14-
- uses: actions/checkout@v3
15+
- name: Checkout code
16+
uses: actions/checkout@v4
1517

16-
- name: Set up Docker
17-
uses: docker/setup-buildx-action@v1
18+
- name: Set up Docker Buildx
19+
uses: docker/setup-buildx-action@v3
1820

19-
- name: Install Docker Compose
21+
- name: Verify Docker Compose
22+
shell: bash
2023
run: |
21-
sudo apt-get update
22-
sudo apt-get install -y docker-compose
24+
set -euo pipefail
25+
if docker compose version >/dev/null 2>&1; then
26+
echo "Using Docker Compose plugin"
27+
docker compose version
28+
elif command -v docker-compose >/dev/null 2>&1; then
29+
echo "Using docker-compose standalone"
30+
docker-compose --version
31+
else
32+
echo "Error: Docker Compose not available"
33+
exit 1
34+
fi
2335
24-
- name: Start Preprod node, wait 30s then stop node
36+
- name: Test Preprod node
2537
shell: bash
38+
timeout-minutes: 10
2639
run: |
27-
printf "1\n" | /bin/bash ./start-node.sh 2>&1 | tee script_output.txt &
40+
set -euo pipefail
41+
printf "2\n1\n" | ./start-node.sh 2>&1 | tee preprod_output.txt &
42+
START_PID=$!
2843
sleep 30
29-
/bin/bash ./stop-nodes.sh
44+
if ! kill -0 $START_PID 2>/dev/null; then
45+
echo "Error: start-node.sh process died unexpectedly"
46+
exit 1
47+
fi
48+
./stop-nodes.sh
49+
wait $START_PID || true
50+
if [ -f preprod_output.txt ]; then
51+
echo "=== Preprod Node Output ==="
52+
cat preprod_output.txt
53+
fi
54+
55+
- name: Cleanup after Preprod
56+
if: always()
57+
shell: bash
58+
run: |
59+
set -euo pipefail
60+
./stop-nodes.sh || true
61+
docker ps -a --filter "name=node-" --format "{{.Names}}" | xargs -r docker rm -f || true
3062
31-
- name: Start Preview node, wait 30s then stop node
63+
- name: Test Preview node
3264
shell: bash
65+
timeout-minutes: 3
3366
run: |
34-
printf "2\n" | /bin/bash ./start-node.sh 2>&1 | tee script_output.txt &
67+
set -euo pipefail
68+
printf "3\n1\n" | ./start-node.sh 2>&1 | tee preview_output.txt &
69+
START_PID=$!
3570
sleep 30
36-
/bin/bash ./stop-nodes.sh
71+
if ! kill -0 $START_PID 2>/dev/null; then
72+
echo "Error: start-node.sh process died unexpectedly"
73+
exit 1
74+
fi
75+
./stop-nodes.sh
76+
wait $START_PID || true
77+
if [ -f preview_output.txt ]; then
78+
echo "=== Preview Node Output ==="
79+
cat preview_output.txt
80+
fi
3781
38-
- name: Start SanchoNet node, wait 30s then stop node
82+
- name: Cleanup after Preview
83+
if: always()
3984
shell: bash
4085
run: |
41-
printf "3\n" | /bin/bash ./start-node.sh 2>&1 | tee script_output.txt &
86+
set -euo pipefail
87+
./stop-nodes.sh || true
88+
docker ps -a --filter "name=node-" --format "{{.Names}}" | xargs -r docker rm -f || true
89+
90+
- name: Test SanchoNet node
91+
shell: bash
92+
timeout-minutes: 3
93+
run: |
94+
set -euo pipefail
95+
printf "4\n1\n" | ./start-node.sh 2>&1 | tee sancho_output.txt &
96+
START_PID=$!
4297
sleep 30
43-
/bin/bash ./stop-nodes.sh
98+
if ! kill -0 $START_PID 2>/dev/null; then
99+
echo "Error: start-node.sh process died unexpectedly"
100+
exit 1
101+
fi
102+
./stop-nodes.sh
103+
wait $START_PID || true
104+
if [ -f sancho_output.txt ]; then
105+
echo "=== SanchoNet Node Output ==="
106+
cat sancho_output.txt
107+
fi
108+
109+
- name: Final cleanup
110+
if: always()
111+
shell: bash
112+
run: |
113+
set -euo pipefail
114+
./stop-nodes.sh || true
115+
docker ps -a --filter "name=node-" --format "{{.Names}}" | xargs -r docker rm -f || true
116+
docker system prune -f || true
117+
118+
- name: Upload logs on failure
119+
if: failure()
120+
uses: actions/upload-artifact@v4
121+
with:
122+
name: node-logs
123+
path: |
124+
*_output.txt
125+
script_output.txt
126+
retention-days: 7

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ services:
1818
- ./keys:/keys
1919
- ./txs:/txs
2020
- ./dumps:/dumps
21+
- ./utilities:/utilities
2122
logging:
2223
driver: "json-file"
2324
options:

scripts/cc/authorize-hot-key.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#!/bin/bash
22

3-
# Define directory paths
4-
keys_dir="./keys"
5-
txs_dir="./txs/cc"
3+
# Get the script's directory and project root
4+
script_dir=$(dirname "$0")
5+
project_root=$(cd "$script_dir/../.." && pwd)
6+
7+
# Define directory paths relative to project root
8+
keys_dir="$project_root/keys"
9+
txs_dir="$project_root/txs/cc"
610
tx_path_stub="$txs_dir/auth-hot"
711
tx_cert_path="$tx_path_stub.cert"
812
tx_unsigned_path="$tx_path_stub.unsigned"
913
tx_signed_path="$tx_path_stub.signed"
1014

11-
# Get the script's directory
12-
script_dir=$(dirname "$0")
13-
1415
# Get the container name from the get-container script
1516
container_name="$("$script_dir/../helper/get-container.sh")"
1617

scripts/cc/generate-cc-keys.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/bin/bash
22

3-
# Define directories
4-
keys_dir="./keys"
5-
6-
# Get the script's directory
3+
# Get the script's directory and project root
74
script_dir=$(dirname "$0")
5+
project_root=$(cd "$script_dir/../.." && pwd)
6+
7+
# Define directory paths relative to project root
8+
keys_dir="$project_root/keys"
89

910
# Get the container name from the get-container script
1011
container_name="$("$script_dir/../helper/get-container.sh")"

scripts/cc/generate-new-hot-key.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/bin/bash
22

3-
# Define directories
4-
keys_dir="./keys"
5-
6-
# Get the script's directory
3+
# Get the script's directory and project root
74
script_dir=$(dirname "$0")
5+
project_root=$(cd "$script_dir/../.." && pwd)
6+
7+
# Define directory paths relative to project root
8+
keys_dir="$project_root/keys"
89

910
# Get the container name from the get-container script
1011
container_name="$("$script_dir/../helper/get-container.sh")"

scripts/cc/resign-cold-key.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#!/bin/bash
22

3-
# Define directory paths
4-
keys_dir="./keys"
5-
txs_dir="./txs/cc"
3+
# Get the script's directory and project root
4+
script_dir=$(dirname "$0")
5+
project_root=$(cd "$script_dir/../.." && pwd)
6+
7+
# Define directory paths relative to project root
8+
keys_dir="$project_root/keys"
9+
txs_dir="$project_root/txs/cc"
610
tx_path_stub="$txs_dir/resign-cold"
711
tx_cert_path="$tx_path_stub.cert"
812
tx_unsigned_path="$tx_path_stub.unsigned"
913
tx_signed_path="$tx_path_stub.signed"
1014

11-
12-
# Get the script's directory
13-
script_dir=$(dirname "$0")
14-
1515
# Get the container name from the get-container script
1616
container_name="$("$script_dir/../helper/get-container.sh")"
1717

scripts/cc/vote.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ GA_TX_INDEX="0"
88

99
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1010

11-
# Define directory paths
12-
keys_dir="./keys"
13-
txs_dir="./txs/cc"
11+
# Get the script's directory and project root
12+
script_dir=$(dirname "$0")
13+
project_root=$(cd "$script_dir/../.." && pwd)
14+
15+
# Define directory paths relative to project root
16+
keys_dir="$project_root/keys"
17+
txs_dir="$project_root/txs/cc"
1418
tx_path_stub="$txs_dir/cc-vote"
1519
tx_cert_path="$tx_path_stub.cert"
1620
tx_unsigned_path="$tx_path_stub.unsigned"
1721
tx_signed_path="$tx_path_stub.signed"
1822

19-
# Get the script's directory
20-
script_dir=$(dirname "$0")
21-
2223
# Get the container name from the get-container script
2324
container_name="$("$script_dir/../helper/get-container.sh")"
2425

scripts/drep/create-and-register-multisig.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/bin/bash
22

3-
# Define directories
4-
keys_dir="./keys"
5-
txs_dir="./txs/multi-sig"
6-
7-
# Get the script's directory
3+
# Get the script's directory and project root
84
script_dir=$(dirname "$0")
5+
project_root=$(cd "$script_dir/../.." && pwd)
6+
7+
# Define directory paths relative to project root
8+
keys_dir="$project_root/keys"
9+
txs_dir="$project_root/txs/multi-sig"
910

1011
# Get the container name from the get-container script
1112
container_name="$("$script_dir/../helper/get-container.sh")"

0 commit comments

Comments
 (0)