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

add: implement docker e2e ci job #222

Merged
merged 17 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions .github/e2e-docker-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
defaultStake: 10000
defaultFee: 2000
borChainId: 15001
heimdallChainId: heimdall-15001
contractsBranch: mardizzone/node-16
genesisContractsBranch: master
sprintSize:
- '64'
blockNumber:
- '0'
blockTime:
- '2'
numOfBorValidators: 3
numOfBorSentries: 0
numOfBorArchiveNodes: 0
numOfErigonValidators: 0
numOfErigonSentries: 0
numOfErigonArchiveNodes: 0
ethURL: http://ganache:9545
ethHostUser: ubuntu
devnetType: docker
borDockerBuildContext: 'https://github.com/maticnetwork/bor.git#develop'
heimdallDockerBuildContext: 'https://github.com/maticnetwork/heimdall.git#develop'
sprintSizeBlockNumber:
- '0'
devnetBorFlags: config,config,config
15 changes: 15 additions & 0 deletions .github/integration-tests/bor_health.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

while true
do
peers=$(docker exec bor0 bash -c "bor attach /root/var/lib/bor/data/bor.ipc -exec 'admin.peers'")
block=$(docker exec bor0 bash -c "bor attach /root/var/lib/bor/data/bor.ipc -exec 'eth.blockNumber'")

if [[ -n "$peers" ]] && [[ -n "$block" ]]; then
break
fi
done

echo $peers
echo $block
44 changes: 44 additions & 0 deletions .github/integration-tests/smoke_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -e

balanceInit=$(docker exec bor0 bash -c "bor attach /root/var/lib/bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'")

stateSyncFound="false"
checkpointFound="false"
SECONDS=0
start_time=$SECONDS

while true
do

balance=$(docker exec bor0 bash -c "bor attach /root/var/lib/bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'")

if ! [[ "$balance" =~ ^[0-9]+$ ]]; then
echo "Something is wrong! Can't find the balance of first account in bor network."
exit 1
fi

if (( $balance > $balanceInit )); then
if [ $stateSyncFound != "true" ]; then
stateSyncTime=$(( SECONDS - start_time ))
stateSyncFound="true"
fi
fi

checkpointID=$(curl -sL http://localhost:1317/checkpoints/latest | jq .result.id)

if [ $checkpointID != "null" ]; then
if [ $checkpointFound != "true" ]; then
checkpointTime=$(( SECONDS - start_time ))
checkpointFound="true"
fi
fi

if [ $stateSyncFound == "true" ] && [ $checkpointFound == "true" ]; then
break
fi

done
echo "Both state sync and checkpoint went through. All tests have passed!"
echo "Time taken for state sync: $(printf '%02dm:%02ds\n' $(($stateSyncTime%3600/60)) $(($stateSyncTime%60)))"
echo "Time taken for checkpoint: $(printf '%02dm:%02ds\n' $(($checkpointTime%3600/60)) $(($checkpointTime%60)))"
85 changes: 84 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
working-directory: matic-cli
run: npm run lint:check

integration-tests:
e2e-remote:
permissions:
id-token: write
contents: write
Expand Down Expand Up @@ -134,3 +134,86 @@ jobs:
if: always()
working-directory: matic-cli/aws
run: aws ec2 delete-key-pair --key-name matic-cli-ci-key

e2e-docker:
permissions:
id-token: write
contents: write
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
strategy:
matrix:
os: [ubuntu-20.04] # list of os: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
path: matic-cli

- name: Install dependencies on Linux
if: runner.os == 'Linux'
run: |
sudo apt update
sudo apt install build-essential
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
sudo snap install solc
sudo apt install python2 jq curl
sudo ln -sf /usr/bin/python2 /usr/bin/python

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Bootstrap devnet
run: |
cd matic-cli
Raneet10 marked this conversation as resolved.
Show resolved Hide resolved
npm install --prefer-offline --no-audit --progress=false
Raneet10 marked this conversation as resolved.
Show resolved Hide resolved
mkdir devnet
cd devnet
../bin/matic-cli.js setup devnet -c ../../matic-cli/.github/e2e-docker-config.yml

- name: Launch devnet
run: |
cd matic-cli/devnet
Raneet10 marked this conversation as resolved.
Show resolved Hide resolved
bash docker-ganache-start.sh
bash docker-heimdall-start-all.sh
bash docker-bor-setup.sh
bash docker-bor-start-all.sh
cd -
timeout 2m bash matic-cli/.github/integration-tests/bor_health.sh
cd -
bash ganache-deployment-bor.sh
bash ganache-deployment-sync.sh

- name: Run smoke tests
run: |
echo "Deposit 100 matic for each account to bor network"
cd matic-cli/devnet/code/contracts
npm run truffle exec scripts/deposit.js -- --network development $(jq -r .root.tokens.MaticToken contractAddresses.json) 100000000000000000000
cd -
timeout 60m bash matic-cli/.github/integration-tests/smoke_test.sh

- name: Upload logs
if: always()
uses: actions/upload-artifact@v3
with:
name: logs_${{ github.run_id }}
path: |
matic-cli/devnet/logs

- name: Package code and chain data
if: always()
run: |
cd matic-cli/devnet
docker compose down --remove-orphans
cd -
mkdir -p ${{ github.run_id }}/matic-cli
sudo mv matic-cli/devnet ${{ github.run_id }}/matic-cli
sudo tar czf code.tar.gz ${{ github.run_id }}

- name: Upload code and chain data
if: always()
uses: actions/upload-artifact@v3
with:
name: code_${{ github.run_id }}
path: code.tar.gz
Loading