Skip to content

Commit

Permalink
fix: e2e run (#737)
Browse files Browse the repository at this point in the history
* fix: ibc query method get consensus state by height should return any type (#727)

* patch: ibc query method get consensus state by height should return any type

* fix: add uniformity

* feat: remove xcall multi submodule (#733)

* fix: remove xcall submodule

* refactor: update test execution script

* fix: update documentation

* feat: save write ack event height (#734)

* feat: save write ack event height

* chore: style fixes

Signed-off-by: Night Owl <[email protected]>

* fix: add test case

---------

Signed-off-by: Night Owl <[email protected]>
Co-authored-by: viveksharmapoudel <[email protected]>
Co-authored-by: Night Owl <[email protected]>

* feat: test multiple packets on same height (#736)

* add(test): multiple packets on same heigt

* rf: simplfy recursion call

* ci: remove cw_common from inside the docker container (#712)

Signed-off-by: Night Owl <[email protected]>

* chore: exclude cosmwasm library and common file from contract deployment (#698)

---------

Signed-off-by: Night Owl <[email protected]>
Co-authored-by: Debendra Oli <[email protected]>
Co-authored-by: Night Owl <[email protected]>
Co-authored-by: DeepakBomjan <[email protected]>

* feat: get relayer version from comment, fix: ami build

* rf: remove unnessary step

* feat: test multiple packets on same height

* fix: use constant version of [email protected] for build

* fix: e2e test setup

* fix: integration test

---------

Signed-off-by: Night Owl <[email protected]>
Co-authored-by: viveksharmapoudel <[email protected]>
Co-authored-by: redlarva <[email protected]>
Co-authored-by: izyak <[email protected]>
Co-authored-by: Night Owl <[email protected]>
Co-authored-by: Night Owl <[email protected]>
Co-authored-by: DeepakBomjan <[email protected]>
Co-authored-by: red__larva <[email protected]>
Co-authored-by: izyak <[email protected]>
  • Loading branch information
9 people authored Nov 2, 2023
1 parent 335a316 commit 1075482
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 111 deletions.
22 changes: 11 additions & 11 deletions .github/packer/builder.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

set -euof
set -euof pipefail

install_deps() {
sudo yum install -y git docker make tar perl-Digest-SHA libicu
Expand All @@ -13,24 +13,22 @@ configure_docker() {

build_goloop_images() {
git clone https://github.com/icon-project/goloop.git
cd goloop
make goloop-image
make goloop-icon-image
make goloop-image -C goloop
make goloop-icon-image -C goloop
docker tag goloop iconloop/goloop-icon
rm -rf ../goloop
}

pull_archway_images() {
docker pull archwaynetwork/archwayd:sha-8f53ac8
}

configure_relayer() {
mv /tmp/Dockerfile .
cat > build.sh <<EOF
cat <<EOT > ~/build.sh
#!/bin/sh
docker build -t relayer --build-args VERSION=$1 .
EOF
chmod +x build.sh
version=\$(echo "\$VERSION" | sed 's/v//')
docker build -t relayer --build-arg VERSION=\$version .
EOT
chmod +x ~/build.sh
}

build_services() {
Expand All @@ -40,7 +38,9 @@ build_services() {
}

cleanup(){
sudo yum uninstall -y git make tar perl-Digest-SHA
rm -rf goloop
sudo yum remove -y tar perl-Digest-SHA
sudo yum clean all
}

install_deps
Expand Down
12 changes: 6 additions & 6 deletions .github/packer/builds.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ build {
name = local.name
sources = ["source.amazon-ebs.linux"]

provisioner "shell" {
execute_command = "sudo -S bash -c '{{ .Path }}'"
script = "${path.root}/builder.sh"
}

provisioner "file" {
source = "${path.root}/relayer.Dockerfile"
destination = "/tmp/Dockerfile"
destination = "Dockerfile"
}

provisioner "shell" {
execute_command = "sudo -S sh -c '{{ .Path }}'"
script = "${path.root}/builder.sh"
}
}
27 changes: 15 additions & 12 deletions .github/workflows/e2e-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,25 @@ permissions:
pull-requests: read
statuses: write
jobs:
start-runner:
parse-args:
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/run e2e')
runs-on: ubuntu-latest
steps:
- name: Parse relayer version
id: relay
run: |
echo "RELAYER_VERSION=$(echo ${{ github.event.comment.body }} | sed -n 's/.*\/run e2e \(.*\)/\1/p')" >> $GITHUB_ENV
outputs:
relayer_version: ${{ steps.relay.outputs.RELAYER_VERSION }}
start-runner:
needs: parse-args
uses: ./.github/workflows/runner-start.yml
secrets: inherit
with:
relayer_version: ${{ vars.relayer_version == '' && '0.1.0-alpha.7' || vars.relayer_version }}
relayer_version: ${{ needs.parse-args.outputs.relayer_version }}
e2e:
name: E2E tests
runs-on: self-hosted
runs-on: ${{ needs.start-runner.outputs.label }}
needs: start-runner
steps:
- name: Get PR branch
Expand All @@ -32,15 +42,8 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}

- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: 1.21

- name: Run e2e tests
run: make e2e

run: ./scripts/execute-test.sh --clean --use-docker --build-ibc --build-xcall --xcall-branch main --test e2e
- name: Set latest commit status as ${{ job.status }}
uses: myrotvorets/set-commit-status-action@master
if: always()
Expand All @@ -56,4 +59,4 @@ jobs:
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
needs:
- start-runner
- e2e
- e2e
53 changes: 53 additions & 0 deletions .github/workflows/packer-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
on:
push:
branches:
- main
paths:
- ".github/packer/*"

jobs:
start-runner:
uses: ./.github/workflows/runner-start.yml
secrets: inherit
build:
needs: start-runner
runs-on: ${{ needs.start-runner.outputs.label }}
defaults:
run:
working-directory: ./.github/packer
env:
PRODUCT_VERSION: latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: 1.21
- name: Build
uses: hashicorp/setup-packer@main
with:
version: ${{ env.PRODUCT_VERSION }}
- name: Run `packer init`
id: init
run: "packer init ."
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Run `packer validate`
id: validate
run: "packer validate ."
- name: Build and Publish AMI
run: packer build -color=false .
stop-runner:
uses: ./.github/workflows/runner-stop.yml
secrets: inherit
with:
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
needs:
- start-runner
- build
18 changes: 7 additions & 11 deletions .github/workflows/runner-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
relayer_version:
description: "Relayer version"
type: string
default: "0.1.0-alpha.7"
required: true
outputs:
label:
description: "Label of the self-hosted runner"
Expand Down Expand Up @@ -36,21 +34,19 @@ jobs:
--output text --max-items 1)
echo "AMI_ID=$ami_id" >> $GITHUB_OUTPUT
- uses: actions/checkout@v3
- id: relay
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: icon-project/ibc-relay
- name: Start EC2 instance
id: start
uses: machulav/ec2-github-runner@v2
uses: machulav/ec2-github-runner
with:
mode: start
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.GH_RUNNER_PAT }}
ec2-image-id: ${{ steps.ami-id.outputs.AMI_ID }}
ec2-instance-type: c5.2xlarge
subnet-id: subnet-f1fcd4df
security-group-id: sg-03cb8034e27e1caeb
aws-resource-tags: >
[
{"Key": "Name", "Value": "ec2-github-runner"},
{"Key": "Repository", "Value": "${{ github.repository }}"},
{"Key": "Project", "Value": "IBC"}
]
pre-runner-script: |
./build.sh ${{ inputs.relayer_version }}
./build.sh ${{ inputs.relayer_version == '' && steps.relay.outputs.release || inputs.relayer_version }}
4 changes: 2 additions & 2 deletions .github/workflows/runner-stop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GITHUB_TOKEN }}
github-token: ${{ secrets.GH_RUNNER_PAT }}
label: ${{ inputs.label }}
ec2-instance-id: ${{ inputs.ec2-instance-id }}
ec2-instance-id: ${{ inputs.ec2-instance-id }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,4 @@ scripts/download_buf.sh

test/e2e-demo/ibc-config/**

.xcall-multi
.xcall-multi
51 changes: 34 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
BRANCH ?= "main"
export GO111MODULE = on


###############################################################################
### Protobuf ###
###############################################################################

protoVer=0.11.1
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
builderImage=contract-builder
Expand All @@ -22,42 +17,65 @@ proto-all: proto-format proto-lint proto-gen

proto-format:
@echo "Formatting Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
find ./ -name "*.proto" -exec clang-format -i {} \; ; fi
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then \
docker start -a $(containerProtoFmt); \
else \
docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
find ./ -name "*.proto" -exec clang-format -i {} \;; \
fi

proto-lint:
@$(DOCKER_BUF) lint --error-format=json

proto-gen-go:
@echo "Generating Go Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenGo}$$"; then docker start -a $(containerProtoGenGo); else docker run --name $(containerProtoGenGo) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protocgen_go.sh; fi
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenGo}$$"; then \
docker start -a $(containerProtoGenGo); \
else \
docker run --name $(containerProtoGenGo) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protocgen_go.sh; \
fi

proto-gen-rust:
@echo "Generating Rust Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenRust}$$"; then docker start -a $(containerProtoGenRust); else docker run --name $(containerProtoGenRust) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protocgen_rust.sh; fi
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenRust}$$"; then \
docker start -a $(containerProtoGenRust); \
else \
docker run --name $(containerProtoGenRust) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \
sh ./scripts/protocgen_rust.sh; \
fi

build-builder-img:
@echo "Build builder image"
docker build -t "${builderImage}" . -f ./scripts/.DockerfileContractBuilder

optimize-jar:
@echo "Generating optimized jar for ICON contracts"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerBuilder}-icon$$"; then docker start -a "${containerBuilder}-icon" ; else docker run --name "${containerBuilder}-icon" -v $(CURDIR):/workspace --workdir /workspace $(builderImage) bash ./scripts/optimize-jar.sh; fi
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerBuilder}-icon$$"; then \
docker container rm "${containerBuilder}-icon"; \
fi
docker run --name "${containerBuilder}-icon" -v $(CURDIR):/workspace --workdir /workspace $(builderImage) bash ./scripts/optimize-jar.sh;

optimize-cosmwasm:
@echo "Generating optimized cosmwasm for Archway contracts"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerBuilder}-cosmwasm$$"; then docker start -a "${containerBuilder}-cosmwasm" ; else docker run --name "${containerBuilder}-cosmwasm" -v $(CURDIR):/workspace --workdir /workspace $(builderImage) bash ./scripts/optimize-cosmwasm.sh; fi
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerBuilder}-cosmwasm$$"; then \
docker container rm "${containerBuilder}-cosmwasm"; \
fi
docker run --name "${containerBuilder}-cosmwasm" -v $(CURDIR):/workspace --workdir /workspace $(builderImage) bash ./scripts/optimize-cosmwasm.sh

optimize-xcall:
@echo "Generating optimized xcall contracts ..."
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerBuilder}-xcall$$"; then docker start -a "${containerBuilder}-xcall" ; else docker run --name "${containerBuilder}-xcall" -v $(CURDIR):/workspace --workdir /workspace $(builderImage) bash ./scripts/optimize-xcall-build.sh build $(BRANCH); fi

@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerBuilder}-xcall$$"; then \
docker container rm "${containerBuilder}-xcall"; \
fi
docker run --name "${containerBuilder}-xcall" -v $(CURDIR):/workspace --workdir /workspace $(builderImage) bash ./scripts/optimize-xcall-build.sh build $(BRANCH);

optimize-build:
@echo "Generating optimized contracts..."
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerBuilder}$$"; then docker start -a ${containerBuilder}; else docker run --name $(containerBuilder) -v $(CURDIR):/workspace --workdir /workspace $(builderImage) bash ./scripts/optimize-build.sh build; fi
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerBuilder}$$"; then \
docker container rm ${containerBuilder}; \
fi
docker run --name $(containerBuilder) -v $(CURDIR):/workspace --workdir /workspace $(builderImage) bash ./scripts/optimize-build.sh build;

gobuild:
go build .
Expand All @@ -74,5 +92,4 @@ e2e-demo-setup:
e2e-demo-clean:
go test -v ./test/e2e-demo -testify.m TestCleanup


.PHONY: proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps gobuild optimize-build optimize-xcall e2e-demo-setup e2e-demo-clean
6 changes: 6 additions & 0 deletions scripts/execute-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ if [ "$clean" = "true" ]; then
clean_contracts
fi


if [ "$use_docker" = "true" ]; then
make build-builder-img & wait
fi


if [ "$build_ibc" = "true" ]; then
echo "building IBC contracts..."
if [ "$use_docker" = "true" ]; then
Expand Down
2 changes: 1 addition & 1 deletion scripts/optimize-cosmwasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cargo fmt --all
cargo clean

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

RUSTFLAGS='-C link-arg=-s' cargo build --workspace --exclude test-utils --release --lib --target wasm32-unknown-unknown
for WASM in ./target/wasm32-unknown-unknown/release/*.wasm; do
Expand Down
1 change: 0 additions & 1 deletion scripts/optimize-xcall-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
set -e
mkdir -p artifacts/icon
mkdir -p artifacts/archway

LOCAL_X_CALL_REPO=".xcall-multi"

clone_xCall_multi() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
}
},
"key_password": "gochain"
}
}
1 change: 0 additions & 1 deletion test/chains/icon/data/single/auth.json

This file was deleted.

6 changes: 0 additions & 6 deletions test/chains/icon/data/single/icon_config.json

This file was deleted.

1 change: 0 additions & 1 deletion test/chains/icon/data/single/rconfig.json

This file was deleted.

Loading

0 comments on commit 1075482

Please sign in to comment.