Skip to content

Commit

Permalink
feat: add GitHub workflow to check test and release automatically (#857)
Browse files Browse the repository at this point in the history
* chore: add integration test workflow

* add build and test in workflow

* optimize workflow cache

* skip error file

* feat: add release workflow

* fix release workflow

* disable window to debug

* test release name

* fix release tag

* fix release tag

* add macos

* fix macos

* fix make test

* remove windows, zip before upload

* remove build in integration ci

* update integration

* update release

* fix integration test

* debug

* remove debug

* clean up

* adjust release strategy

* fix multiple cmds

* fix paramhub

* get app_pub back

* remove app_pub_test

* add lint

* fix lint

* fix pub
  • Loading branch information
owen-reorg authored and forcodedancing committed May 19, 2022
1 parent 80c9821 commit 43c6784
Show file tree
Hide file tree
Showing 30 changed files with 234 additions and 71 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: integration-ci

on: ["push", "pull_request", "workflow_dispatch"]

jobs:
integration-test:
runs-on: ubuntu-latest
env:
GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v3
with:
go-version: 1.16
- name: Checkout
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: sudo apt-get update -y && sudo apt-get install -y expect
- run: git config --global url."https://${{ secrets.GH_ACCESS_TOKEN }}@github.com".insteadOf "https://github.com"
- run: go env -w GOPRIVATE="github.com/bnb-chain/*"
# used to debug workflow
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- run: make integration_test
- run: make test
157 changes: 157 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: Release

on:
push:
# Publish `v1.2.3` tags as releases.
tags:
- v*

jobs:
build:
name: Build Release
strategy:
matrix:
go-version: [1.16.x]
os: [ubuntu-18.04, macos-11, windows-2019]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- 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-
- run: go env -w GOPRIVATE="github.com/bnb-chain/*"
- run: git config --global url."https://${{ secrets.GH_ACCESS_TOKEN }}@github.com".insteadOf "https://github.com"

# ==============================
# Linux/Macos/Windows Build
# ==============================

# used to debug workflow
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

- name: Build Binary for ${{matrix.os}}
run: make build

# ==============================
# Upload artifacts
# ==============================

- name: Upload Linux Build
uses: actions/upload-artifact@v2
if: matrix.os == 'ubuntu-18.04'
with:
name: linux
path: ./build

- name: Upload MacOS Build
uses: actions/upload-artifact@v2
if: matrix.os == 'macos-11'
with:
name: macos
path: ./build

- name: Upload Windows Build
uses: actions/upload-artifact@v2
if: matrix.os == 'windows-2019'
with:
name: windows
path: ./build

release:
name: Release
needs: build
runs-on: ubuntu-18.04
steps:
- name: Checkout Code
uses: actions/checkout@v2

# ==============================
# Download artifacts
# ==============================

- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: linux
path: ./linux

- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: macos
path: ./macos

- name: Download Artifacts
uses: actions/download-artifact@v2
with:
name: windows
path: ./windows

- run: zip -r linux.zip linux
- run: zip -r macos.zip macos
- run: zip -r windows.zip windows

- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: false
prerelease: false

# Check downloaded files
- run: ls

- name: Upload Release Asset - Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./linux.zip
asset_name: bnb-chain-node-binary-linux-${{ github.ref_name }}.zip
asset_content_type: application/octet-stream

- name: Upload Release Asset - MacOS
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./macos.zip
asset_name: bnb-chain-node-binary-macos-${{ github.ref_name }}.zip
asset_content_type: application/octet-stream

- name: Upload Release Asset - Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./windows.zip
asset_name: bnb-chain-node-binary-windows-${{ github.ref_name }}.zip
asset_content_type: application/octet-stream
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ define buildwindows
endef


build: get_tools
build:
ifeq ($(OS),Windows_NT)
$(call buildwindows)
else
Expand Down Expand Up @@ -155,7 +155,7 @@ get_tools:
@echo "--> Installing tools"
./scripts/get_tools.sh

test:
test: get_tools
make set_with_deadlock
make test_unit
make test_race
Expand Down
5 changes: 4 additions & 1 deletion app/app_paramhub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"testing"
"time"

"github.com/bnb-chain/node/common/upgrade"

"github.com/stretchr/testify/assert"

"github.com/tendermint/go-amino"
Expand Down Expand Up @@ -50,7 +52,7 @@ var (
logger = log.NewTMLogger(os.Stdout)
genAccs, addrs, pubKeys, privKeys = mock.CreateGenAccounts(4,
sdk.Coins{sdk.NewCoin("BNB", 500000e8), sdk.NewCoin("BTC-000", 200e8)})
testScParams = `[{"type": "params/StakeParamSet","value": {"unbonding_time": "604800000000000","max_validators": 11,"bond_denom": "BNB","min_self_delegation": "5000000000000","min_delegation_change": "100000000","reward_distribution_batch_size":"200"}},{"type": "params/SlashParamSet","value": {"max_evidence_age": "259200000000000","signed_blocks_window": "0","min_signed_per_window": "0","double_sign_unbond_duration": "9223372036854775807","downtime_unbond_duration": "172800000000000","too_low_del_unbond_duration": "86400000000000","slash_fraction_double_sign": "0","slash_fraction_downtime": "0","double_sign_slash_amount": "1000000000000","downtime_slash_amount": "5000000000","submitter_reward": "100000000000","downtime_slash_fee": "1000000000"}},{"type": "params/OracleParamSet","value": {"ConsensusNeeded": "70000000"}},{"type": "params/IbcParamSet","value": {"relayer_fee": "1000000"}}]`
testScParams = `[{"type": "params/StakeParamSet","value": {"unbonding_time": "604800000000000","max_validators": 11,"bond_denom": "BNB","min_self_delegation": "5000000000000","min_delegation_change": "100000000","reward_distribution_batch_size":"1000"}},{"type": "params/SlashParamSet","value": {"max_evidence_age": "259200000000000","signed_blocks_window": "0","min_signed_per_window": "0","double_sign_unbond_duration": "9223372036854775807","downtime_unbond_duration": "172800000000000","too_low_del_unbond_duration": "86400000000000","slash_fraction_double_sign": "0","slash_fraction_downtime": "0","double_sign_slash_amount": "1000000000000","downtime_slash_amount": "5000000000","submitter_reward": "100000000000","downtime_slash_fee": "1000000000"}},{"type": "params/OracleParamSet","value": {"ConsensusNeeded": "70000000"}},{"type": "params/IbcParamSet","value": {"relayer_fee": "1000000"}}]`
testClient *TestClient
testApp *BinanceChain
)
Expand Down Expand Up @@ -251,6 +253,7 @@ func TestSubmitCSCParamUpdatesFail(t *testing.T) {
}

func TestSCParamUpdatesSuccess(t *testing.T) {
upgrade.Mgr.AddUpgradeHeight(upgrade.BEP128, -1)
valAddr, ctx, accounts := setupTest()
sideValAddr := accounts[0].GetAddress().Bytes()
tNow := time.Now()
Expand Down
2 changes: 1 addition & 1 deletion app/pub/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func PublishEvent(
ToPublishEventCh <-chan *sub.ToPublishEvent) {
for toPublish := range ToPublishEventCh {
eventData := toPublish.EventData
Logger.Debug("publisher queue status", "size", len(ToPublishCh))
//Logger.Debug("publisher queue status", "size", len(ToPublishCh))
if cfg.PublishStaking {
var msgNum int
var validators []*Validator
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ require (
github.com/linkedin/goavro v0.0.0-20180427201934-fa8f6a30176c
github.com/mitchellh/go-homedir v1.1.0
github.com/natefinch/lumberjack v2.0.0+incompatible
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.8.1
github.com/prometheus/client_golang v1.1.0
github.com/sasha-s/go-deadlock v0.2.1-0.20180822072021-d68e2bc52ae3 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/viper v1.4.0
github.com/stretchr/testify v1.4.0
Expand Down
7 changes: 6 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BR
github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8=
github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
github.com/btcsuite/btcd v0.0.0-20190629003639-c26ffa870fd8/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
github.com/btcsuite/btcd v0.20.0-beta h1:PamBMopnHxO2nEIsU89ibVVnqnXR2yFTgGNc+PdG68o=
github.com/btcsuite/btcd v0.20.0-beta h1:DnZGUjFbRkpytojHWwy6nfUSA7vFrzWXDLpFNzt74ZA=
github.com/btcsuite/btcd v0.20.0-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
Expand Down Expand Up @@ -413,6 +413,8 @@ github.com/otiai10/primes v0.0.0-20180210170552-f6d2a1ba97c4/go.mod h1:UmSP7QeU3
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.4.0 h1:u3Z1r+oOXJIkxqw34zVhyPgjBsm6X2wn21NWs/HfSeg=
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
Expand Down Expand Up @@ -450,6 +452,8 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
github.com/rs/cors v1.6.0 h1:G9tHG9lebljV9mfp9SNPDL36nCDxmo3zTlAf1YgvzmI=
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sasha-s/go-deadlock v0.2.1-0.20180822072021-d68e2bc52ae3 h1:PFrDl/KPigLkWkRl/AqIztEvC/iSnwKmTCy9qbqgevw=
github.com/sasha-s/go-deadlock v0.2.1-0.20180822072021-d68e2bc52ae3/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smola/gocompat v0.2.0/go.mod h1:1B0MlxbmoZNo3h8guHp8HztB3BSYR5itql9qtVc0ypY=
github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPHbB5mVY2iO9KV3pTt/QbIkGaO8gQ2WrDbP4=
Expand Down Expand Up @@ -582,6 +586,7 @@ golang.org/x/tools v0.0.0-20181130052023-1c3d964395ce/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
Expand Down
3 changes: 2 additions & 1 deletion integration_test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -ex

cd ./build
if [ $? -ne 0 ]; then
echo "path build does not exists"
Expand Down Expand Up @@ -65,7 +67,6 @@ function check_operation() {


secret=$(prepare_node)

result=$(expect ./recover.exp "${secret}" "alice" true)
check_operation "Recover Key" "${result}" "${keys_operation_words}"

Expand Down
2 changes: 1 addition & 1 deletion networks/demo/HTLT-cross-chain.exp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/HTLT-single-chain.exp
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/add_key.exp
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ set timeout 30
send "12345678\r"
expect "Repeat*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/cancel.exp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/claim.exp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/deposit.exp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/issue.exp
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/issue_mini.exp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/list.exp
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/list_mini.exp
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/mint.exp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/multi_send.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ set timeout 30
spawn ./bnbcli token multi-send --home $home --from $from --chain-id=$chain_id --transfers $tx --memo $memo
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/order.exp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ set timeout 30
}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/propose_list.exp
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ set timeout 30
spawn ./bnbcli gov submit-list-proposal --chain-id ${chain_id} --from ${from} --deposit ${deposit} --base-asset-symbol ${base_asset} --quote-asset-symbol ${quote_asset} --init-price ${init_price} --title ${title} --description ${description} --home ${home} --expire-time ${expire_time} --voting-period ${voting_period}
expect "Password*"
send "12345678\r"
interact
expect eof
2 changes: 1 addition & 1 deletion networks/demo/recover.exp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ set timeout 30
send "12345678\r"
expect "Enter*"
send "${secret}\r"
interact
expect eof
Loading

0 comments on commit 43c6784

Please sign in to comment.