Add test suite for Tradeshield module's tests and removed mockery (#982) #271
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy in devnet | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: deploy-devnet # Group for limiting concurrent runs | |
cancel-in-progress: false # Queue new jobs instead of canceling if one is already running | |
environment: devnet | |
env: | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
NAME: elys | |
COMMIT: ${{ github.sha }} | |
VERSION: | |
BINARY: | |
DBENGINE: pebbledb | |
NAME_WITH_VERSION: | |
steps: | |
- name: Checking repository | |
uses: actions/checkout@v4 | |
- name: Setting variables | |
run: | | |
VER=v${{ github.sha }} | |
echo "VERSION=$VER" >> $GITHUB_ENV | |
echo "BINARY=${NAME}d" >> $GITHUB_ENV | |
echo "NAME_WITH_VERSION=${NAME}-${VER}" >> $GITHUB_ENV | |
- name: Debuging enviroment | |
run: | | |
echo "BRANCH NAME:" $BRANCH_NAME | |
echo "NAME:" $NAME | |
echo "COMMIT:" $COMMIT | |
echo "VERSION": $VERSION | |
echo "BYNARY": $BINARY | |
echo "NAME_WITH_VERSION": $NAME_WITH_VERSION | |
- name: Setuping go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.22" | |
- name: Building elys binary | |
run: | | |
echo Building elysd binary | |
sudo GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -mod=readonly -trimpath -o elysd -ldflags "-X github.com/cosmos/cosmos-sdk/version.Name=${NAME} \ | |
-X github.com/cosmos/cosmos-sdk/version.AppName=${NAME} \ | |
-X github.com/cosmos/cosmos-sdk/version.ServerName=${BINARY} \ | |
-X github.com/cosmos/cosmos-sdk/version.ClientName=${BINARY} \ | |
-X github.com/cosmos/cosmos-sdk/version.Version=${VERSION} \ | |
-X github.com/cosmos/cosmos-sdk/version.Commit=${COMMIT} \ | |
-X github.com/cosmos/cosmos-sdk/types.DBBackend=${DBENGINE} \ | |
-X github.com/elys-network/elys/app.NextVersion=${VERSION} \ | |
-X github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,osusergo,${DBENGINE} \ | |
" -tags "ledger,${DBENGINE}" ./cmd/${BINARY} | |
echo "Version of elysd: $(./elysd version)" | |
- name: Compressing elys binary | |
run: | | |
cp elysd /tmp/elysd | |
sudo apt-get install -y tar | |
tar czvf ${{env.NAME_WITH_VERSION}}.tar.gz elysd | |
mkdir -p ${{env.NAME_WITH_VERSION}} | |
mv ${{env.NAME_WITH_VERSION}}.tar.gz ${{env.NAME_WITH_VERSION}}/${{env.NAME_WITH_VERSION}}.tar.gz | |
- uses: ryand56/r2-upload-action@latest | |
id: bucket | |
name: Uploading binary to bucket | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: ${{env.NAME_WITH_VERSION}} | |
destination-dir: releases | |
- name: Backup Devnet | |
uses: appleboy/ssh-action@v1.0.3 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.SSH_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
script: /bin/bash /home/ubuntu/ci-cd-devnet-backup-and-rollback/backup.sh | |
command_timeout: 60m | |
- name: Creating software upgrade proposal | |
run: | | |
# helper functions | |
extract_txhash() { awk -F 'txhash: ' '/txhash:/{print $2; exit}'; } | |
extract_proposal_id() { awk -F 'key: proposal_id|value: ' '/key: proposal_id/ { getline; gsub(/"/, "", $2); print $2; exit }'; } | |
extract_and_calc_upgrade_height() { awk -F'"latest_block_height":"' '{ split($2,a,"\""); print a[1]+25; exit }'; } | |
extract_checksum() { awk "/elysd-${{ github.ref_name }}-linux-amd64.tar.gz/ {print \$1; exit}"; } | |
# environment variables | |
ELYSD=/tmp/elysd | |
NODE=https://rpc.devnet.elys.network:443 | |
OPTIONS="--node $NODE --chain-id elysdevnet-1 --keyring-backend=test -b=sync --fees=100000uelys --gas=300000 -y" | |
# save private keys to files | |
echo "${{ secrets.PRIVATE_KEY_FUJI }}" > /tmp/private_key_fuji.txt | |
echo "${{ secrets.PRIVATE_KEY_MALLORCA }}" > /tmp/private_key_mallorca.txt | |
echo "${{ secrets.PRIVATE_KEY_BORA }}" > /tmp/private_key_bora.txt | |
# recover keys | |
echo "${{ secrets.PASSPHRASE_FUJI }}" | $ELYSD keys import fuji --keyring-backend test /tmp/private_key_fuji.txt | |
echo "${{ secrets.PASSPHRASE_MALLORCA }}" | $ELYSD keys import mallorca --keyring-backend test /tmp/private_key_mallorca.txt | |
echo "${{ secrets.PASSPHRASE_BORA }}" | $ELYSD keys import bora --keyring-backend test /tmp/private_key_bora.txt | |
# get checksum | |
# checksum=$(cat dist/sha256sum.txt | extract_checksum) | |
# query and upgrade height | |
height=$($ELYSD status --node $NODE | extract_and_calc_upgrade_height) | |
# create proposal | |
txhash=$( | |
$ELYSD software-upgrade-tx \ | |
${{env.VERSION}} \ | |
$height \ | |
10000000uelys \ | |
"Elys Network version ${{env.VERSION}} released. Focuses on enhancements and codebase improvements." \ | |
"{\"binaries\":{\"linux/amd64\":\"https://snapshots.elys.network/releases/${{env.NAME_WITH_VERSION}}.tar.gz\"}}" \ | |
--from=mallorca \ | |
$OPTIONS | extract_txhash | |
) | |
sleep 10 | |
#Tx Hash | |
echo "software upgrade tx hash:" $txhash | |
proposalid=$($ELYSD q tx $txhash --node $NODE | extract_proposal_id) | |
#Proposal Id | |
echo "Proposal Id:" $proposalid | |
# vote on proposal | |
$ELYSD tx gov vote $proposalid yes --from=fuji $OPTIONS | |
$ELYSD tx gov vote $proposalid yes --from=mallorca $OPTIONS | |
$ELYSD tx gov vote $proposalid yes --from=bora $OPTIONS | |
sleep 10 |