Skip to content

Commit

Permalink
add: implement docker e2e ci job (#222)
Browse files Browse the repository at this point in the history
* few docker related updates

* few minor updates in docker

* docker and config file related changes

* add: implement docker e2e ci / parallelize CIs

* chg: ci lint name

* addressed comments

* chg: fix lint

* chg: do not cancel in progress

* chg: ci docker job name

* chg: unify CIs

* build(deps): bump follow-redirects from 1.15.3 to 1.15.4 (#219)

Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.4.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](follow-redirects/follow-redirects@v1.15.3...v1.15.4)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chg: use bor_health in integration tests / merge dependabot PR

* chg: use new bor paths for integration tests

* chg: remove bor related chaindata upload in ci

* chg: remove reduntant npm install

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Pratik Patil <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 18, 2024
1 parent ca14b9b commit f971c88
Show file tree
Hide file tree
Showing 5 changed files with 441 additions and 3,536 deletions.
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
npm install --prefer-offline --no-audit --progress=false
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
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

0 comments on commit f971c88

Please sign in to comment.