Skip to content

Commit

Permalink
fix: fix issue with script optimize-cosmwasm.sh
Browse files Browse the repository at this point in the history
* change variable PROJECTS from bash array to simple space separated list of project name

* ci: fix cargo install using --locked

* ci: get running archway container name

* ci: run build script directly instead of make target
  • Loading branch information
DeepakBomjan committed Sep 4, 2023
1 parent 8c604c7 commit 605586b
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-publish-cosmwasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
run: |
rustup component add rustfmt --toolchain 1.69.0-x86_64-unknown-linux-gnu
rustup component add clippy --toolchain 1.69.0-x86_64-unknown-linux-gnu
make optimize-cosmwasm
bash ./scripts/optimize-cosmwasm.sh
- name: Check WASM Size
run: |
Expand Down
44 changes: 13 additions & 31 deletions .github/workflows/deploy-cosmwasm-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Cosmwasm Contracts Test Deployment
on:
push:
branches:
- main
- fix/use-complete-packet-data-for-write-ack
- "**"
# pull_request:
# branches:
# - main
# paths:
- contracts/cosmwasm-vm/**
- libraries/common/rust/**
- .github/workflows/deploy-cosmwasm-contracts.yml
# - contracts/cosmwasm-vm/**
# - libraries/common/rust/**
# - .github/workflows/deploy-cosmwasm-contracts.yml
# - scripts/optimize-cosmwasm.sh
jobs:
Build:
name: Build & Deploy Cosmasm Contracts
Expand All @@ -23,12 +23,8 @@ jobs:

- name: Start local Archway Blockchain
run: |
cd contracts/cosmwasm-vm/archway
sed -i 's/latest/v0.4.0/' docker-compose.yaml
docker compose -f docker-compose.yaml up -d
# git clean submodule directory
git checkout .
git clean -fdx
cp ./scripts/archway/docker_compose_archway.yaml .
docker compose -f docker_compose_archway.yaml up -d
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
Expand All @@ -45,28 +41,14 @@ jobs:
run: |
rustup component add rustfmt --toolchain 1.69.0-x86_64-unknown-linux-gnu
rustup component add clippy --toolchain 1.69.0-x86_64-unknown-linux-gnu
make optimize-cosmwasm
- name: Check WASM Size
run: |
max_size=800
echo "Check if size of wasm file exceeds $max_size kilobytes..."
for file in artifacts/*.wasm
do
size=$(du -k "$file" | awk '{print $1}')
if [[ $size -gt $max_size ]]; then
echo "Error: $file : $size KB has exceeded maximum contract size limit of 800KB."
exit 1
fi
echo "$file : $size KB"
done
echo "The size of all contracts is well within the 800 KB limit."
sudo chmod -R 777 artifacts
sudo chmod -R 777 scripts
# Build cosmwasm builder image
bash ./scripts/optimize-cosmwasm.sh
- name: Deploy WASM
run: |
container=$(docker ps --format '{{.Names}}')
rm -rf artifacts/archway/cw_common.wasm
cp -r {artifacts,scripts/deploy_cosmwasm.sh} contracts/cosmwasm-vm/archway/contracts
docker ps -a
docker exec $container chmod +x /contracts/deploy_cosmwasm.sh
docker exec $container /contracts/deploy_cosmwasm.sh
docker exec $container chmod +x /opt/deploy_cosmwasm.sh
docker exec $container /opt/deploy_cosmwasm.sh
18 changes: 18 additions & 0 deletions scripts/archway/docker_compose_archway.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3"

services:
node:
container_name: archway-node-1
image: archwaynetwork/archwayd:v0.4.0
build:
context: .
entrypoint:
- sh
- /opt/archway/localnet.sh
ports:
- 9090:9090
- 26657:26657
volumes:
- ${PWD}/scripts:/opt:z
- ${PWD}/artifacts/archway:/contracts:z
working_dir: /opt
37 changes: 37 additions & 0 deletions scripts/archway/localnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh

# this script instantiates localnet required genesis files

set -e

echo clearing $HOME/.archway
rm -rf $HOME/.archway
echo initting new chain
# init config files
archwayd init archwayd-id --chain-id localnet

# create accounts
archwayd keys add fd --keyring-backend=test

addr=$(archwayd keys show fd -a --keyring-backend=test)
val_addr=$(archwayd keys show fd --keyring-backend=test --bech val -a)

# give the accounts some money
archwayd add-genesis-account "$addr" 1000000000000stake --keyring-backend=test

# save configs for the daemon
archwayd gentx fd 10000000stake --chain-id localnet --keyring-backend=test

# input genTx to the genesis file
archwayd collect-gentxs
# verify genesis file is fine
archwayd validate-genesis
echo changing network settings
sed -i 's/127.0.0.1/0.0.0.0/g' $HOME/.archway/config/config.toml

echo test account address: "$addr"
echo test account private key: "$(yes | archwayd keys export fd --unsafe --unarmored-hex --keyring-backend=test)"
echo account for --from flag "fd"

echo starting network...
archwayd start
4 changes: 2 additions & 2 deletions scripts/optimize-cosmwasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cargo fmt --all
cargo clean

rustup target add wasm32-unknown-unknown
cargo install cosmwasm-check
cargo install cosmwasm-check --locked


RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude test-utils --release --lib --target wasm32-unknown-unknown
Expand Down Expand Up @@ -89,4 +89,4 @@ exit 1
fi
echo "$file : $size KB"
done
echo "The size of all contracts is well within the $MAX_WASM_SIZE KB limit."
echo "The size of all contracts is well within the $MAX_WASM_SIZE KB limit."

0 comments on commit 605586b

Please sign in to comment.