Skip to content

Commit

Permalink
feat(testing): docker nodes for E2E local tests (berachain#865)
Browse files Browse the repository at this point in the history
Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Devon Bear <[email protected]>
Co-authored-by: archbear <[email protected]>
Co-authored-by: Cal Bera <[email protected]>
  • Loading branch information
5 people authored Jul 14, 2023
1 parent edb3d31 commit 38ff320
Show file tree
Hide file tree
Showing 67 changed files with 3,190 additions and 572 deletions.
165 changes: 165 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# SPDX-License-Identifier: BUSL-1.1
#
# Copyright (C) 2023, Berachain Foundation. All rights reserved.
# Use of this software is govered by the Business Source License included
# in the LICENSE file of this repository and at www.mariadb.com/bsl11.
#
# ANY USE OF THE LICENSED WORK IN VIOLATION OF THIS LICENSE WILL AUTOMATICALLY
# TERMINATE YOUR RIGHTS UNDER THIS LICENSE FOR THE CURRENT AND ALL OTHER
# VERSIONS OF THE LICENSED WORK.
#
# THIS LICENSE DOES NOT GRANT YOU ANY RIGHT IN ANY TRADEMARK OR LOGO OF
# LICENSOR OR ITS AFFILIATES (PROVIDED THAT YOU MAY USE A TRADEMARK OR LOGO OF
# LICENSOR AS EXPRESSLY REQUIRED BY THIS LICENSE).
#
# TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
# AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
# EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
# TITLE.

name: e2e

on:
pull_request:

jobs:
build-base:
strategy:
matrix:
namespace: [cosmos]
docker-version: [base]
os: [ubuntu-latest]
go-version: [1.20.4]
go-arch: [amd64]
image-name: ["polard/base:v0.0.0"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Cache Golang Deps
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Run ${{ matrix.namespace }}:docker ${{ matrix.docker-version }} ${{ matrix.go-arch }}
uses: magefile/mage-action@v2
with:
version: latest
args: ${{ matrix.namespace }}:docker base ${{ matrix.go-arch }}
env:
GOPATH: /home/runner/go
- name: Save base image
run: docker save ${{ matrix.image-name }} -o base-image.tar
- name: Upload image artifact
uses: actions/upload-artifact@v2
with:
name: base-image
path: base-image.tar

localnet:
needs: build-base
strategy:
matrix:
namespace: [localnet]
os: [ubuntu-latest]
go-version: [1.20.4]
base-image: [base-image]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Cache Golang Deps
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- name: Install Go Tools
run: |
go run magefiles/setup/setup.go ci
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download image artifact
uses: actions/download-artifact@v2
with:
name: ${{ matrix.base-image }}
- name: Load ${{ matrix.base-image }}
run: docker load -i ${{ matrix.base-image }}.tar
- name: Run ${{ matrix.namespace }}:build
uses: magefile/mage-action@v2
with:
version: latest
args: ${{ matrix.namespace }}:build
env:
GOPATH: /home/runner/go
- name: Run teste2e
uses: magefile/mage-action@v2
with:
version: latest
args: teste2e
env:
GOPATH: /home/runner/go

hive:
needs: build-base
strategy:
matrix:
simulator: [polaris/rpc, polaris/graphql]
namespace: [cosmos]
os: [ubuntu-latest]
go-version: [1.20.4]
base-image: [base-image]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download image artifact
uses: actions/download-artifact@v2
with:
name: ${{ matrix.base-image }}
- name: Load ${{ matrix.base-image }}
run: docker load -i ${{ matrix.base-image }}.tar
- name: Cache Golang Deps
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- name: Run ${{ matrix.namespace }}:testhive ${{ matrix.simulator }}
uses: magefile/mage-action@v2
with:
version: latest
args: ${{ matrix.namespace }}:testhive ${{ matrix.simulator }}
env:
GOPATH: /home/runner/go
61 changes: 0 additions & 61 deletions .github/workflows/hive.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,6 @@ out

# hardhat
**/cache/

# integration testing coverage
coverage-testunitcover.txt
46 changes: 12 additions & 34 deletions cosmos/docker/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,7 @@ ARG CMD_PATH=./cosmos/simapp/polard
ARG FOUNDRY_DIR=contracts

#######################################################
### Stage 1 - Build Solidity Bindings ###
#######################################################

# Use the latest foundry image
FROM ghcr.io/foundry-rs/foundry:nightly as foundry

# Set working directory
WORKDIR /workdir

# Required for forge install.
COPY .git/ .git/

# Copy over all the solidity code.
ARG FOUNDRY_DIR
COPY ${FOUNDRY_DIR} ${FOUNDRY_DIR}

# Move into the forge repo for building.
WORKDIR /workdir/${FOUNDRY_DIR}

# Install dependecies for solidity contracts.
RUN forge install --no-commit

# Build the contracts using special flags required for abigen.
RUN forge build --extra-output-files bin --extra-output-files abi

#######################################################
### Stage 2 - Build the Application ###
### Stage 1 - Build the Application ###
#######################################################

FROM golang:${GO_VERSION}-alpine as builder
Expand All @@ -67,19 +41,23 @@ RUN set -eux; \
# Set the working directory
WORKDIR /workdir

# Copy go.mod and go.sum files recursively (🔥 upgrade)
COPY **/go.mod **/go.sum **/go.work ./
# Copy go.work and go.work.sum files (🔥 upgrade)
COPY ./go.work ./go.work.sum ./

# Copy the go.mod and go.sum files for each module
COPY ./contracts/go.sum ./contracts/go.mod ./contracts/
COPY ./cosmos/go.sum ./cosmos/go.mod ./cosmos/
COPY ./eth/go.sum ./eth/go.mod ./eth/
COPY ./lib/go.sum ./lib/go.mod ./lib/
COPY ./magefiles/go.sum ./magefiles/go.mod ./magefiles/
COPY ./e2e/localnet/go.sum ./e2e/localnet/go.mod ./e2e/localnet/

# Download the go module dependencies
RUN go mod download

# Copy the rest of the source code
COPY . .

# Copy the forge output
ARG FOUNDRY_DIR
COPY --from=foundry /workdir/${FOUNDRY_DIR}/out /workdir/${FOUNDRY_DIR}/out

# Build args
ARG NAME
ARG GOARCH
Expand Down Expand Up @@ -109,7 +87,7 @@ RUN VERSION=$(echo $(git describe --tags) | sed 's/^v//') && \
${CMD_PATH}

#######################################################
### Stage 3 - Prepare the Final Image ###
### Stage 2 - Prepare the Final Image ###
#######################################################

FROM golang:${GO_VERSION}-alpine
Expand Down
2 changes: 1 addition & 1 deletion cosmos/docker/local/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

ARG GO_VERSION
ARG GOARCH=arm64
ARG GOOS=darwin
ARG GOOS=linux
ARG POLARD_VERSION=v0.0.0

#######################################################
Expand Down
2 changes: 1 addition & 1 deletion cosmos/docker/rpc/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

ARG GO_VERSION
ARG GOARCH=arm64
ARG GOOS=darwin
ARG GOOS=linux
ARG POLARD_VERSION=v0.0.0

# Use the latest foundry image
Expand Down
2 changes: 1 addition & 1 deletion cosmos/docker/sentry/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

ARG GO_VERSION
ARG GOARCH=arm64
ARG GOOS=darwin
ARG GOOS=linux
ARG POLARD_VERSION=v0.0.0

# Use the latest foundry image
Expand Down
8 changes: 4 additions & 4 deletions cosmos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/holiman/uint256 v1.2.2
github.com/huandu/skiplist v1.2.0 // indirect
github.com/onsi/ginkgo/v2 v2.9.5
github.com/onsi/gomega v1.27.6
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.8
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
github.com/tidwall/btree v1.6.0
Expand Down Expand Up @@ -178,7 +178,7 @@ require (
github.com/klauspost/compress v1.16.7 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lib/pq v1.10.7 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
Expand Down Expand Up @@ -248,7 +248,7 @@ require (
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.1 // indirect
golang.org/x/tools v0.9.3 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.126.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
Loading

0 comments on commit 38ff320

Please sign in to comment.