Skip to content

Commit

Permalink
fix,ci(scripts): (1) Add --no-build flag for localnet.sh,
Browse files Browse the repository at this point in the history
(2) CI test the script, and (3) fix version on e2e action
  • Loading branch information
Unique-Divine committed Jul 8, 2023
1 parent 1d73353 commit c3ec279
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 20 deletions.
27 changes: 13 additions & 14 deletions .github/workflows/pytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ jobs:
runs-on: ubuntu-latest
env:
# https://www.notion.so/nibiru/Resources-and-Repo-Configs-b31aa8074a2b419d80b0c946ed5efab0
LCD_ENDPOINT: "http://localhost:1317"
GRPC_ENDPOINT: "localhost:9090"
TENDERMINT_RPC_ENDPOINT: "http://localhost:26657"
USE_LOCALNET: true
WEBSOCKET_ENDPOINT: "ws://localhost:26657/websocket"
CHAIN_ID: "nibiru-localnet-0"
VALIDATOR_MNEMONIC: "guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host"
DEVNET_NUMBER: ${{ secrets.DEVNET_NUMBER }}
steps:
Expand All @@ -54,7 +48,7 @@ jobs:
# 3.8.16 is the highest 3.8 version available on pyenv
# See `grep '3.8' <<< $(pyenv install -l)` to view the available list.

- name: Run python
- name: Run python # sanity check on the installation.
run: python --version && python -c "print('hello')"

# ----------------------------------------------
Expand Down Expand Up @@ -99,13 +93,18 @@ jobs:
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Run chaosnet
uses: NibiruChain/localnet-action@v1.1
id: chaosnet
with:
services: nibiru pricefeeder
ghtoken: ${{ secrets.GITHUB_TOKEN }}
ghactor: ${{ github.actor }}
- name: Run localnet.sh in the background.
run: |
curl -s https://get.nibiru.fi/@v0.21.5! | bash
bash scrips/localnet.sh --no-build &
# - name: Run chaosnet
# uses: NibiruChain/localnet-action@v1.1
# id: chaosnet
# with:
# services: nibiru pricefeeder
# ghtoken: ${{ secrets.GITHUB_TOKEN }}
# ghactor: ${{ github.actor }}

- name: sleep 30 seconds
run: sleep 30
Expand Down
42 changes: 36 additions & 6 deletions scripts/localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,39 @@ echo_success() {
echo "${reset}"
}

echo_info "Building from source..."
if make install; then
echo_success "Successfully built binary"
else
echo_error "Could not build binary. Failed to make install."
exit 1
# Flag parsing: --flag-name (BASH_VAR_NAME)
#
# --no-build ($FLAG_NO_BUILD): toggles whether to build from source. The default
# behavior of the script is to run make install.
FLAG_NO_BUILD=false

build_from_source() {
echo_info "Building from source..."
if make install; then
echo_success "Successfully built binary"
else
echo_error "Could not build binary. Failed to make install."
exit 1
fi
}

echo_info "Parsing flags for the script..."

# Iterate over all arguments to the script
for arg in "$@"
do
if [ "$arg" == "--no-build" ] ; then
FLAG_NO_BUILD=true
fi
done


# Check if FLAG_NO_BUILD was set to true
if ! $FLAG_NO_BUILD ; then
build_from_source
fi


# Set localnet settings
BINARY="nibid"
CHAIN_ID="nibiru-localnet-0"
Expand All @@ -53,11 +78,16 @@ CHAIN_DIR="$HOME/.nibid"
echo "CHAIN_DIR: $CHAIN_DIR"
echo "CHAIN_ID: $CHAIN_ID"


SEDOPTION=""
if [[ "$OSTYPE" == "darwin"* ]]; then
SEDOPTION="''"
fi

# ------------------------------------------------------------------------
echo_info "Successfully finished localnet script setup."
# ------------------------------------------------------------------------

# Stop nibid if it is already running
if pgrep -x "$BINARY" >/dev/null; then
echo_error "Terminating $BINARY..."
Expand Down

0 comments on commit c3ec279

Please sign in to comment.