Skip to content

Commit

Permalink
Merge pull request #135 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: framework refactor for zkbas
  • Loading branch information
unclezoro authored Sep 2, 2022
2 parents 4e81686 + 10168a9 commit 92201e8
Show file tree
Hide file tree
Showing 649 changed files with 24,957 additions and 43,323 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# ./bin
build
52 changes: 52 additions & 0 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build Test

on:
push:
branches:
- master
- develop

pull_request:
branches:
- master
- develop

jobs:
unit-test:
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2

- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test Build
run: |
export GOPATH=$(go env GOPATH)
go install github.com/zeromicro/go-zero/tools/[email protected]
make build
38 changes: 38 additions & 0 deletions .github/workflows/deploy-on-qa1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy zkbas on qa1

on:
push:
branches:
- qa1

jobs:
deploy:
runs-on: self-hosted
permissions:
issues: write
pull-requests: write
steps:
- name: Deploy new zkbas on qa1
run: |
echo 'fetch zkbas repo'
export BRANCH=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
cd ~
rm -rf ./zkbas
git clone --branch qa1 https://github.com/bnb-chain/zkbas.git
cd ./zkbas
sudo scp -r ./deploy-qa.sh "qa1:/tmp/"
sudo ssh qa1 "sudo bash -x /tmp/deploy-qa.sh qa1;exit"
echo "end deploy on qa1"
- name: Notification via slack
run: |
export SLACK_WEBHOOK_URL=`sudo cat /home/ec2-user/actions-runner/slack-config.json | jq -r '.slack'`
export JOB_STATUS=${{ job.status }}
sudo scp -r qa1:/root/zkbas-deploy/zkbas-contract/info/addresses.json ~/addresses.json
export ZkBas=`sudo cat ~/addresses.json | jq -r '.zkbasProxy'`
export AssetGov=`sudo cat ~/addresses.json | jq -r '.assetGovernance'`
curl -X POST $SLACK_WEBHOOK_URL --header 'Content-Type: application/json' \
--data-raw '{ "author": "@'$GITHUB_ACTOR'", "status": "'$JOB_STATUS'", "ref": "'$GITHUB_REF'", "event": "'$GITHUB_EVENT_NAME'", "url": "'$GITHUB_SERVER_URL'/'$GITHUB_REPOSITORY'/commit/'$GITHUB_SHA'/checks", "ZkbasContract": "'$ZkBas'", "AssetGovContract": "'$AssetGov'" }'
38 changes: 38 additions & 0 deletions .github/workflows/deploy-on-qa2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy zkbas on qa2

on:
push:
branches:
- qa2

jobs:
deploy:
runs-on: self-hosted
permissions:
issues: write
pull-requests: write
steps:
- name: Deploy new zkbas on qa2
run: |
echo 'fetch zkbas repo'
export BRANCH=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
cd ~
rm -rf ./zkbas
git clone --branch qa2 https://github.com/bnb-chain/zkbas.git
cd ./zkbas
sudo scp -r ./deploy-qa.sh "qa2:/tmp/"
sudo ssh qa2 "sudo bash -x /tmp/deploy-qa.sh qa2;exit"
echo "end deploy on qa2"
- name: Notification via slack
run: |
export SLACK_WEBHOOK_URL=`sudo cat /home/ec2-user/actions-runner/slack-config.json | jq -r '.slack'`
export JOB_STATUS=${{ job.status }}
sudo scp -r qa2:/root/zkbas-deploy/zkbas-contract/info/addresses.json ~/addresses.json
export ZkBas=`sudo cat ~/addresses.json | jq -r '.zkbasProxy'`
export AssetGov=`sudo cat ~/addresses.json | jq -r '.assetGovernance'`
curl -X POST $SLACK_WEBHOOK_URL --header 'Content-Type: application/json' \
--data-raw '{ "author": "@'$GITHUB_ACTOR'", "status": "'$JOB_STATUS'", "ref": "'$GITHUB_REF'", "event": "'$GITHUB_EVENT_NAME'", "url": "'$GITHUB_SERVER_URL'/'$GITHUB_REPOSITORY'/commit/'$GITHUB_SHA'/checks", "ZkbasContract": "'$ZkBas'", "AssetGovContract": "'$AssetGov'" }'
38 changes: 38 additions & 0 deletions .github/workflows/deploy-on-qa3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy zkbas on qa3

on:
push:
branches:
- qa3

jobs:
deploy:
runs-on: self-hosted
permissions:
issues: write
pull-requests: write
steps:
- name: Deploy new zkbas on qa3
run: |
echo 'fetch zkbas repo'
export BRANCH=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
cd ~
rm -rf ./zkbas
git clone --branch qa3 https://github.com/bnb-chain/zkbas.git
cd ./zkbas
sudo scp -r ./deploy-qa.sh "qa3:/tmp/"
sudo ssh qa3 "sudo bash -x /tmp/deploy-qa.sh qa3;exit"
echo "end deploy on qa3"
- name: Notification via slack
run: |
export SLACK_WEBHOOK_URL=`sudo cat /home/ec2-user/actions-runner/slack-config.json | jq -r '.slack'`
export JOB_STATUS=${{ job.status }}
sudo scp -r qa3:/root/zkbas-deploy/zkbas-contract/info/addresses.json ~/addresses.json
export ZkBas=`sudo cat ~/addresses.json | jq -r '.zkbasProxy'`
export AssetGov=`sudo cat ~/addresses.json | jq -r '.assetGovernance'`
curl -X POST $SLACK_WEBHOOK_URL --header 'Content-Type: application/json' \
--data-raw '{ "author": "@'$GITHUB_ACTOR'", "status": "'$JOB_STATUS'", "ref": "'$GITHUB_REF'", "event": "'$GITHUB_EVENT_NAME'", "url": "'$GITHUB_SERVER_URL'/'$GITHUB_REPOSITORY'/commit/'$GITHUB_SHA'/checks", "ZkbasContract": "'$ZkBas'", "AssetGovContract": "'$AssetGov'" }'
70 changes: 61 additions & 9 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
name: Integration
name: Integration Test on Runner

on:
push:
branches:
- develop
- master
pull_request:
branches:
- master
- develop
env:
L1_ENDPOINT: https://data-seed-prebsc-1-s1.binance.org:8545
L2_ENDPOINT: http://localhost:8888

jobs:
deploy:
Expand All @@ -12,19 +20,63 @@ jobs:
issues: write
pull-requests: write
steps:
- name: deploy new zkbas
- name: deploy new zkbas on runner
run: |
cd /tmp
echo 'fetch zkbas repo'
export PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
echo Pull requests $PR_NUMBER
cd ~
sudo rm -rf ./zkbas
git clone --branch github-action https://github.com/bnb-chain/zkbas.git
git clone --branch develop https://github.com/bnb-chain/zkbas.git
cd ./zkbas
git fetch origin pull/$PR_NUMBER/head:local-deploy-tmp
git checkout local-deploy-tmp
git rev-parse HEAD
echo "start deploy new zkbas"
sudo bash -x ./zkbas/deploy-local.sh new
sudo bash ./deployment/tool/generate_api.sh
go mod tidy
docker image prune -f
make docker-image
cp -r /server/test.keyfile ./deployment/
mv ./deployment/test.keyfile ./deployment/.zkbas
blockNr=$(sudo bash ./deployment/tool/tool.sh blockHeight)
sudo bash ./deployment/tool/tool.sh all
sudo bash ./deployment/docker-compose/docker-compose.sh down
sudo bash ./deployment/docker-compose/docker-compose.sh up $blockNr
echo "Waiting 10m for the initialization tx to be verified"
sleep 10m # Waiting for the initialization tx to be verified
echo "end deploy"
- name: run integration test
run: |
echo "start integration test"
cd /tmp
sudo bash -x ./zkbas/local-test.sh
echo "end integration test"
export PATH=$PATH:/usr/local/go/bin:/usr/local/go/bin:/root/go/bin
export ZkBas=$(sudo cat ~/zkbas/deployment/dependency/zkbas-contract/info/addresses.json | jq -r '.zkbasProxy')
export AssetGov=$(sudo cat ~/zkbas/deployment/dependency/zkbas-contract/info/addresses.json | jq -r '.assetGovernance')
export TestLogLevel=2
export L1EndPoint=$L1_ENDPOINT
export L2EndPoint=$L2_ENDPOINT
cd /tmp && sudo rm -rf ./zkbas-integration-test
git clone --branch main https://github.com/bnb-chain/zkbas-integration-test.git
cd ./zkbas-integration-test/tests
echo '1. start TestSetupSuite'
go test -v -run TestSetupSuite -timeout 30m
echo '2. start L1 test'
go test -v -run TestL1Suite -timeout 30m
echo '3. start L2 test'
go test -v -run TestL2Suite -timeout 30m
- name: notification via slack
run: |
export SLACK_WEBHOOK_URL=`sudo cat /home/ec2-user/actions-runner/slack-config.json | jq -r '.slack'`
export JOB_STATUS=${{ job.status }}
export ZkBas=`sudo cat /root/zkbas-deploy/zkbas-contract/info/addresses.json | jq -r '.zkbasProxy'`
export AssetGov=`sudo cat /root/zkbas-deploy/zkbas-contract/info/addresses.json | jq -r '.assetGovernance'`
curl -X POST $SLACK_WEBHOOK_URL --header 'Content-Type: application/json' \
--data-raw '{ "author": "@'$GITHUB_ACTOR'", "status": "'$JOB_STATUS'", "ref": "'$GITHUB_REF'", "event": "'$GITHUB_EVENT_NAME'", "url": "'$GITHUB_SERVER_URL'/'$GITHUB_REPOSITORY'/commit/'$GITHUB_SHA'/checks", "ZkbasContract": "'$ZkBas'", "AssetGovContract": "'$AssetGov'" }'
25 changes: 25 additions & 0 deletions .github/workflows/issue-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Issue Trigger

on:
pull_request:
types: [opened, edited, closed]
issue_comment:
types: [created, edited, deleted]

jobs:
trigger:
runs-on: self-hosted
permissions:
issues: write
pull-requests: write
steps:
- name: update-integration-keyfile
if: contains(github.event.pull_request.body, '/update-integration-keyfile') # check the comment if it contains the keywords
run: |
cd /server
sudo rm -rf ./zkbas
sudo git clone --branch develop https://github.com/bnb-chain/zkbas.git
cd ./zkbas
sudo bash ./deployment/tool/tool.sh prepare new
sudo rm -rf /server/test.keyfile
sudo cp -r ./deployment/.zkbas /server/test.keyfile
52 changes: 52 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Lint

on:
push:
branches:
- master
- develop

pull_request:
branches:
- master
- develop

jobs:
lint:
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2

- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Lint
run: |
export GOPATH=$(go env GOPATH)
go install github.com/zeromicro/go-zero/tools/[email protected]
make api-server
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0
golangci-lint run ./...
53 changes: 53 additions & 0 deletions .github/workflows/unit-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Unit Test

on:
push:
branches:
- master
- develop

pull_request:
branches:
- master
- develop

jobs:
unit-test:
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-18.04]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2

- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Uint Test
env:
ANDROID_HOME: "" # Skip android test
run: |
export GOPATH=$(go env GOPATH)
go install github.com/zeromicro/go-zero/tools/[email protected]
make api-server
make test
Loading

0 comments on commit 92201e8

Please sign in to comment.