Skip to content

Commit c371de4

Browse files
authored
Merge pull request #542 from lidofinance/feat/v3-vote-ci
ci: add runners for core and dg tests
2 parents 88bf692 + 5611fcf commit c371de4

File tree

6 files changed

+59
-24
lines changed

6 files changed

+59
-24
lines changed

.github/workflows/core_tests.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
- "feat/rc2"
1010
- "feat/rc1"
1111
- "feat/next-vote"
12+
- "feat/v3-vote"
13+
- "feat/v3-vote-ci"
1214
schedule:
1315
- cron: "0 0 * * TUE"
1416

@@ -19,11 +21,10 @@ jobs:
1921
timeout-minutes: 120
2022

2123
services:
22-
2324
tests-runner:
24-
image: ghcr.io/lidofinance/scripts:v20
25+
image: ghcr.io/lidofinance/scripts:v21
2526
ports:
26-
- 8546:8546
27+
- 8545:8545
2728
volumes:
2829
- ${{ github.workspace }}:/root/scripts
2930
options: >-
@@ -36,23 +37,36 @@ jobs:
3637
- name: Run init script
3738
run: docker exec -e CORE_BRANCH tests-runner bash -c 'make init'
3839
env:
39-
CORE_BRANCH: master
40+
CORE_BRANCH: develop
4041

4142
- name: Run node
42-
run: docker exec -e ETH_RPC_URL --detach tests-runner bash -c 'NODE_PORT=8546 make node'
43+
run: docker exec -e ETH_RPC_URL --detach tests-runner bash -c 'NODE_PORT=8545 make node'
4344
env:
4445
ETH_RPC_URL: ${{ secrets.ETH_RPC_URL }}
4546

4647
- name: Check that the fork is ready
4748
shell: bash
48-
run: timeout 30 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' 127.0.0.1 8546
49+
run: |
50+
echo "Waiting for fork node on 127.0.0.1:8545..."
51+
sleep 10
52+
for i in {1..30}; do
53+
if (echo > /dev/tcp/127.0.0.1/8545) >/dev/null 2>&1; then
54+
echo "Fork is ready ✅"
55+
exit 0
56+
fi
57+
echo "Not ready yet... ($i/30)"
58+
sleep 1
59+
done
60+
echo "❌ Fork was not ready after 30 seconds" >&2
61+
exit 1
4962
5063
- name: Prepare test environment with Brownie
51-
run: docker exec -e GITHUB_TOKEN -e ETH_RPC_URL tests-runner bash -c 'make ci-prepare-environment'
64+
run: docker exec -e GITHUB_TOKEN -e ETH_RPC_URL -e ETHERSCAN_TOKEN tests-runner bash -c 'make ci-prepare-environment'
5265
env:
5366
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
ETHERSCAN_TOKEN: ${{ secrets.ETHERSCAN_TOKEN }}
5468

5569
- name: Run core tests
5670
run: docker exec -e CORE_TESTS_TARGET_RPC_URL tests-runner bash -c 'make test-core'
5771
env:
58-
CORE_TESTS_TARGET_RPC_URL: http://127.0.0.1:8546
72+
CORE_TESTS_TARGET_RPC_URL: http://127.0.0.1:8545

.github/workflows/dual_governance_regression.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
- "feat/rc2"
1414
- "feat/rc1"
1515
- "feat/next-vote"
16+
- "feat/v3-vote-ci"
1617
workflow_dispatch:
1718

1819
jobs:
@@ -26,15 +27,14 @@ jobs:
2627
cancel-in-progress: true
2728

2829
env:
29-
NODE_VERSION: '20'
30-
PYTHON_VERSION: '3.10'
31-
POETRY_VERSION: '1.8.2'
32-
HARDHAT_NODE_URL: 'http://127.0.0.1:8545'
33-
ANVIL_NODE_URL: 'http://127.0.0.1:8555'
30+
NODE_VERSION: "20"
31+
PYTHON_VERSION: "3.10"
32+
POETRY_VERSION: "1.8.2"
33+
HARDHAT_NODE_URL: "http://127.0.0.1:8545"
34+
ANVIL_NODE_URL: "http://127.0.0.1:8555"
3435
CURL_PARAMS: '-X POST -H "Content-Type: application/json" -d "{\"jsonrpc\":\"2.0\",\"method\":\"eth_blockNumber\",\"params\":[],\"id\":1}"'
3536

3637
steps:
37-
3838
################################################################
3939
# Clone repositories`
4040
################################################################
@@ -50,7 +50,7 @@ jobs:
5050
uses: actions/checkout@v4
5151
with:
5252
repository: lidofinance/dual-governance
53-
ref: feature/escrow-mainnet-deploy
53+
ref: feature/report-simulation
5454
path: dual-governance
5555
persist-credentials: false
5656
token: ${{ secrets.GITHUB_TOKEN }}
@@ -63,7 +63,7 @@ jobs:
6363
uses: actions/setup-node@v4
6464
with:
6565
node-version: ${{ env.NODE_VERSION }}
66-
cache: 'yarn'
66+
cache: "yarn"
6767
cache-dependency-path: scripts/yarn.lock
6868

6969
- name: Install Poetry
@@ -141,11 +141,17 @@ jobs:
141141
done
142142
working-directory: scripts
143143

144+
- name: Import network config for brownie
145+
shell: bash
146+
run: poetry run brownie networks import network-config.yaml True
147+
working-directory: scripts
148+
144149
- name: Prepare test environment with Brownie
145-
run: poetry run brownie run scripts/ci/prepare_environment --network mainnet-fork
150+
run: poetry run brownie run scripts/ci/prepare_environment --network mfh-1
146151
working-directory: scripts
147152
env:
148153
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154+
ETHERSCAN_TOKEN: ${{ secrets.ETHERSCAN_TOKEN }}
149155

150156
- name: Run regression tests
151157
run: npm run test:regressions -- --load-accounts

Makefile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ define run_2nd_test
44
poetry run $(1)
55
endef
66

7+
# Get the latest block number from the target RPC node to use as FORKING_BLOCK_NUMBER for core tests
8+
__get_rpc_latest_block_number:
9+
@curl -s -X POST $(CORE_TESTS_TARGET_RPC_URL) \
10+
-H "Content-Type: application/json" \
11+
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
12+
| sed -E 's/.*"result":"([^"]+)".*/\1/' \
13+
| xargs printf "%d"
714

815
test:
916
ifdef vote
@@ -22,6 +29,7 @@ CORE_DIR ?= lido-core
2229
CORE_BRANCH ?= master
2330
NODE_PORT ?= 8545
2431
SECONDARY_NETWORK ?= mfh-2
32+
NETWORK_STATE_FILE ?= deployed-mainnet.json
2533

2634
test-1/2:
2735
poetry run brownie test tests/[tc]*.py tests/regression/test_staking_router_stake_distribution.py --durations=20 --network mfh-1
@@ -78,9 +86,12 @@ node3:
7886
npx hardhat node --fork $(ETH_RPC_URL3) --port $(NODE_PORT)
7987

8088
test-core:
89+
LATEST_BLOCK_NUMBER=$$($(MAKE) --no-print-directory __get_rpc_latest_block_number) && \
90+
echo "LATEST_BLOCK_NUMBER: $$LATEST_BLOCK_NUMBER" && \
8191
cd $(CORE_DIR) && \
82-
FORK_RPC_URL=$(CORE_TESTS_TARGET_RPC_URL) \
8392
RPC_URL=$(CORE_TESTS_TARGET_RPC_URL) \
93+
NETWORK_STATE_FILE=$(NETWORK_STATE_FILE) \
94+
FORKING_BLOCK_NUMBER=$$LATEST_BLOCK_NUMBER \
8495
yarn test:integration
8596

8697
slots:
@@ -92,7 +103,7 @@ slots:
92103
@rm -f slots.ts
93104

94105
ci-prepare-environment:
95-
poetry run brownie run scripts/ci/prepare_environment --network $(SECONDARY_NETWORK)
106+
poetry run brownie run scripts/ci/prepare_environment --network mfh-1
96107

97108
enact-fork:
98109
poetry run brownie run $(vote) start_and_execute_vote_on_fork_manual --network=mfh-1

scripts/ci/prepare_environment.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22

33
from typing import Callable, Tuple, List
44

5+
from tests.conftest import Helpers
6+
57
from utils.config import contracts, get_deployer_account
68
from utils.voting import bake_vote_items
79
from utils.dual_governance import process_pending_proposals
810
from utils.evm_script import encode_call_script
911
from utils.import_current_votes import get_vote_script_files, get_upgrade_script_files
1012
from utils.mainnet_fork import pass_and_exec_dao_vote
13+
from utils.test.governance_helpers import execute_vote_and_process_dg_proposals
1114

1215
def main():
1316
process_pending_proposals()
14-
execute_votings_and_process_created_proposals()
17+
# TODO revert after December Aragon
18+
#execute_votings_and_process_created_proposals()
19+
execute_vote_and_process_dg_proposals(Helpers, -1, -1)
1520

1621
def execute_votings_and_process_created_proposals():
1722
votings_in_flight = retrieve_votings_in_flight()

tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,8 @@ def execute_votes(accounts, vote_ids, dao_voting, topup="10 ether"):
129129
dao_voting.vote(vote_id, True, False, {"from": account})
130130

131131
# wait for the vote to end
132-
time_to_end = dao_voting.getVote(vote_id)["startDate"] + get_vote_duration() - chain.time()
133-
if time_to_end > 0:
134-
chain.sleep(time_to_end)
132+
# time_to_end = dao_voting.getVote(vote_id)["startDate"] + get_vote_duration() - chain.time()
133+
chain.sleep(get_vote_duration())
135134
chain.mine()
136135

137136
for vote_id in vote_ids:

utils/test/governance_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def execute_vote(helpers, vote_ids_from_env):
1010
else:
1111
start_and_execute_votes(contracts.voting, helpers)
1212

13-
13+
# TODO revert after December Aragon
1414
#def execute_vote_and_process_dg_proposals(helpers, vote_ids_from_env, dg_proposal_ids_from_env):
1515
# if vote_ids_from_env and dg_proposal_ids_from_env:
1616
# execute_vote(helpers, vote_ids_from_env)

0 commit comments

Comments
 (0)