Skip to content

Commit

Permalink
test(e2e): module generation + fix BUF cache permission issue (#239)
Browse files Browse the repository at this point in the history
* test: ICS with custom module generation

* fix workflow (ref spawn ../)

* move spawn bin into path

* try `/.cache/buf` directly

* rm the x

* try a mount instead? (like cw optimizer)

* tmp cache buf v2

* /module

* set BUF_CACHE_DIR

* rm comment

* `--ibc-module` e2e

* remove chmod req. from docs
  • Loading branch information
Reecepbcups authored Oct 12, 2024
1 parent 95a3100 commit a10b085
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/reusable-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ on:
type: string
required: true
description: 'The command which runs the chain via the shell'
spawn-extra-cmd:
type: string
required: false
description: 'Extra command to run after the chain is created'

env:
GO_VERSION: 1.22.3
Expand Down Expand Up @@ -62,19 +66,31 @@ jobs:
uses: actions/download-artifact@master
with:
name: spawn
path: /home/runner/go/bin

- name: Spawn Permission
run: chmod +x ./spawn && ls -l
- name: Spawn Permission # put into path
run: chmod +x /home/runner/go/bin/spawn && ls -l

# === Chain Creation & Validation ===
- name: Spawn Gen - '${{inputs.id}}'
run: ${{ inputs.spawn-create-cmd }}
run: |
git config --global --add url."[email protected]:".insteadOf "https://github.com/"
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
${{ inputs.spawn-create-cmd }}
pwd
- name: Spawn Extra Generation
if : ${{ inputs.spawn-extra-cmd }}
run: ${{ inputs.spawn-extra-cmd }}

- name: Build and Run '${{inputs.id}}'
run: |
cd mychain
${{ inputs.start-chain-cmd }}
# Runs the unit test after the chain is started in the background
# This way the work is parallelized
- name: Unit Test - '${{inputs.id}}'
run: |
cd mychain
Expand All @@ -95,4 +111,4 @@ jobs:
done
lsof -i tcp:26657 | awk 'NR!=1 {print $2}' | xargs kill || true
exit 1
exit 1
26 changes: 22 additions & 4 deletions .github/workflows/spawn-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,39 @@ jobs:
uses: ./.github/workflows/reusable-e2e.yaml
with:
id: Proof of Stake
spawn-create-cmd: ./spawn new mychain --consensus=proof-of-stake --bypass-prompt --bech32=prefix --bin=appd --no-git --org=rollchains-org --denom=uroll --debug --log-level=debug
spawn-create-cmd: spawn new mychain --consensus=proof-of-stake --bypass-prompt --bech32=prefix --bin=appd --no-git --org=rollchains-org --denom=uroll --debug --log-level=debug
start-chain-cmd: HOME_DIR="~/.simapp" CHAIN_ID="localchain-1" BLOCK_TIME="2000ms" CLEAN=true sh scripts/test_node.sh &

proof-of-authority:
needs: build-spawn
uses: ./.github/workflows/reusable-e2e.yaml
with:
id: Proof of Authority
spawn-create-cmd: ./spawn new mychain --consensus=proof-of-authority --bypass-prompt --bech32=cosmos --bin=appd --no-git --org=rollchains-org --denom=uroll --debug --log-level=debug
spawn-create-cmd: spawn new mychain --consensus=proof-of-authority --bypass-prompt --bech32=cosmos --bin=appd --no-git --org=rollchains-org --denom=uroll --debug --log-level=debug
start-chain-cmd: HOME_DIR="~/.simapp" CHAIN_ID="localchain-1" BLOCK_TIME="2000ms" CLEAN=true sh scripts/test_node.sh &

normal-ics:
needs: build-spawn
uses: ./.github/workflows/reusable-e2e.yaml
with:
id: ICS - Cosmos Hub
spawn-create-cmd: ./spawn new mychain --consensus=ics --bin=appd --bypass-prompt --bech32=roll --no-git --org=rollchains-org --denom=uroll --debug --log-level=debug
start-chain-cmd: HOME_DIR="~/.icsnetwork" CHAIN_ID="localchain-2" CLEAN=true BLOCK_TIME="2000ms" sh scripts/test_ics_node.sh &
spawn-create-cmd: spawn new mychain --consensus=ics --bin=appd --bypass-prompt --bech32=roll --no-git --org=rollchains-org --denom=uroll --debug --log-level=debug
start-chain-cmd: HOME_DIR="~/.icsnetwork" CHAIN_ID="localchain-2" CLEAN=true BLOCK_TIME="2000ms" sh scripts/test_ics_node.sh &

ics-with-user-modules:
needs: build-spawn
uses: ./.github/workflows/reusable-e2e.yaml
with:
id: ICS - Module
spawn-create-cmd: spawn new mychain --consensus=ics --bin=appd --bypass-prompt --bech32=roll --disabled=explorer --org=rollchains-org --denom=uroll --debug --log-level=debug
spawn-extra-cmd: cd mychain && spawn module new aaaaaa && make proto-gen
start-chain-cmd: HOME_DIR="~/.icsnetwork" CHAIN_ID="localchain-2" CLEAN=true BLOCK_TIME="2000ms" sh scripts/test_ics_node.sh &

poa-with-ibc-module:
needs: build-spawn
uses: ./.github/workflows/reusable-e2e.yaml
with:
id: POA - IBC Module
spawn-create-cmd: spawn new mychain --consensus=poa --bin=appd --bypass-prompt --bech32=roll --disabled=explorer --org=rollchains-org --denom=upoa --debug --log-level=debug
spawn-extra-cmd: cd mychain && spawn module new aaaaaa --ibc-module && make proto-gen
start-chain-cmd: HOME_DIR="~/.simapp" CHAIN_ID="localchain-10" CLEAN=true BLOCK_TIME="2000ms" sh scripts/test_node.sh &
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,8 @@ spawn module new nameservice

# proto-gen proto files to go
#
# If you get a /.cache permission error, run:
# sudo chmod -R 777 $(pwd)/.cache
# sudo chown -R $USER $(pwd)/.cache
#
# If you get a cannot find module error
# go clean -modcache
#

make proto-gen
```

Expand Down
3 changes: 1 addition & 2 deletions simapp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ CURRENT_GID := $(shell id -g)

protoVer=0.13.2
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
# $(CURDIR)/.cache:/.cache:rw is macOS specific due to buf saving to a read-only directory
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace:rw -v $(CURDIR)/.cache:/.cache:rw --user ${CURRENT_UID}:${CURRENT_GID} --workdir /workspace $(protoImageName)
protoImage=$(DOCKER) run -e BUF_CACHE_DIR=/tmp/buf --rm -v $(CURDIR):/workspace:rw --user ${CURRENT_UID}:${CURRENT_GID} --workdir /workspace $(protoImageName)

proto-all: proto-format proto-lint proto-gen format

Expand Down

0 comments on commit a10b085

Please sign in to comment.