-
Notifications
You must be signed in to change notification settings - Fork 2
172 lines (146 loc) · 5.24 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Build and Test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
token: ${{ github.token }}
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Checkout Miden Node v0.7.2
uses: actions/checkout@v3
with:
repository: 0xPolygonMiden/miden-node
path: miden-node
ref: v0.7.2
token: ${{ github.token }}
- name: Clone Miden Node (fallback)
if: ${{ failure() }}
run: |
git clone --depth 1 --branch v0.7.2 https://github.com/0xPolygonMiden/miden-node.git miden-node
- name: Create Miden Node Config Files
run: |
# Create node config file
cat > miden-node.toml << EOF
# Node configuration
[node]
# Node data directory
data_dir = "./data"
# RPC configuration
[rpc]
# RPC server address
address = "0.0.0.0:57291"
# Block producer configuration
[block_producer]
# Enable block production
enabled = true
# Block production interval in milliseconds
interval = 10000
# Store configuration
[store]
# Store type (sqlite or postgres)
type = "sqlite"
# Store connection string
connection = "./data/miden.db"
EOF
# Create genesis config file
cat > genesis.toml << EOF
# Genesis configuration
[genesis]
# Genesis timestamp
timestamp = 0
# Genesis chain ID
chain_id = 1
# Genesis block number
block_number = 0
EOF
- name: Build Miden Node Docker Image
run: |
cd miden-node
# Build the Docker image using the commands from the Makefile
CREATED=$(date) && \
VERSION=$(cat bin/node/Cargo.toml | grep -m 1 '^version' | cut -d '"' -f 2) && \
COMMIT=$(git rev-parse HEAD) && \
docker build --build-arg CREATED="$CREATED" \
--build-arg VERSION="$VERSION" \
--build-arg COMMIT="$COMMIT" \
-f bin/node/Dockerfile \
-t miden-node-image .
- name: Initialize and Start Miden Node
run: |
# Create a directory for node data
mkdir -p data
# Create a Docker container for initialization
docker run --name miden-node-init \
-v "$(pwd):/workspace" \
-w /workspace \
miden-node-image \
miden-node init --config-path miden-node.toml --genesis-path genesis.toml
# Create genesis data
docker run --name miden-node-genesis \
-v "$(pwd):/workspace" \
-w /workspace \
miden-node-image \
miden-node make-genesis --inputs-path genesis.toml --output-path genesis.dat --force
# Clean up initialization containers
docker rm miden-node-init miden-node-genesis
# Start the node
docker run --name miden-node \
-p 57291:57291 \
-v "$(pwd):/workspace" \
-w /workspace \
-d miden-node-image \
miden-node start --config miden-node.toml node
# Wait for the node to start
echo "Waiting for Miden node to start..."
sleep 30
# Check if the node is running
if ! docker ps | grep miden-node > /dev/null; then
echo "Miden node failed to start"
docker logs miden-node || true
exit 1
else
echo "Miden node started successfully"
docker logs miden-node
fi
- name: Build Project
run: cargo build --verbose
- name: Run tests
run: |
# Set environment variables to connect to the Docker container
export MIDEN_NODE_URL=http://localhost:57291
# Run your specific tests
cargo test --package pm-accounts --test test_oracle --verbose -- --nocapture
cargo test --package pm-accounts --test test_publisher --verbose -- --nocapture
- name: Show Node Logs
if: always()
run: |
docker logs miden-node || true
- name: Stop Miden Node
if: always()
run: |
docker stop miden-node || true
docker rm miden-node || true