Skip to content

Commit aba5e06

Browse files
committed
feat(e2e): backport e2e/kind framework to release/1.3.x
Backports the Kind-based E2E framework (originally added on main via #105 and follow-ups) onto release/1.3.x so the same upgrade-flow and smoke tests run on this branch's PRs. Should have been part of #247 (the v1.3.0 upgrade handler). This PR is the follow-up that wires the test harness. Includes: - e2e/kind/ (framework, scripts, manifests, contracts, tests incl. test_upgrade_hardfork.sh / test_upgrade_governance.sh) - .github/workflows/e2e-kind.yml (per-PR + workflow_dispatch) - .github/workflows/notify-e2e.yml (moca-e2e hub cross-repo trigger) - Makefile e2e-fw / e2e-kind-* targets Snapshot taken from main HEAD at backport time. No app/SDK code touched.
1 parent f4bd5e5 commit aba5e06

34 files changed

Lines changed: 4191 additions & 1 deletion

.github/workflows/e2e-kind.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: E2E Kind Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
inputs:
9+
old_version:
10+
description: "Old version tag for upgrade tests (used by hardfork/governance/comprehensive)"
11+
default: "v1.1.2"
12+
type: string
13+
14+
env:
15+
OLD_VERSION: ${{ inputs.old_version || 'v1.1.2' }}
16+
DOCKER_IMAGE: mocachain/moca
17+
DOCKER_TAG: e2e-local
18+
CGO_CFLAGS: "-O -D__BLST_PORTABLE__"
19+
CGO_CFLAGS_ALLOW: "-O -D__BLST_PORTABLE__"
20+
21+
jobs:
22+
# ── Build Docker images once, share via artifact ─────────────────────────────
23+
build-e2e-images:
24+
name: Build E2E Images
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 30
27+
steps:
28+
- uses: actions/checkout@v6
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v4
32+
33+
- name: Build current version image
34+
uses: docker/build-push-action@v7
35+
with:
36+
context: .
37+
file: e2e/kind/Dockerfile.e2e
38+
tags: ${{ env.DOCKER_IMAGE }}:${{ env.DOCKER_TAG }}
39+
load: true
40+
no-cache: true
41+
42+
- name: Build old version image
43+
uses: docker/build-push-action@v7
44+
with:
45+
context: .
46+
file: e2e/kind/Dockerfile.e2e-gitref
47+
build-args: GIT_REF=${{ env.OLD_VERSION }}
48+
tags: ${{ env.DOCKER_IMAGE }}:${{ env.OLD_VERSION }}
49+
load: true
50+
no-cache: true
51+
52+
- name: Save images
53+
run: |
54+
docker save \
55+
"$DOCKER_IMAGE:$DOCKER_TAG" \
56+
"$DOCKER_IMAGE:$OLD_VERSION" \
57+
| gzip > /tmp/e2e-images.tar.gz
58+
59+
- name: Upload images
60+
uses: actions/upload-artifact@v7
61+
with:
62+
name: e2e-images
63+
path: /tmp/e2e-images.tar.gz
64+
retention-days: 1
65+
66+
# ── Run tests in parallel, reusing pre-built images ──────────────────────────
67+
e2e-tests:
68+
name: "E2E: ${{ matrix.name }}"
69+
needs: build-e2e-images
70+
runs-on: ubuntu-latest
71+
timeout-minutes: 20
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
include:
76+
- name: Smoke
77+
script: test_smoke.sh
78+
- name: Upgrade (hardfork)
79+
script: test_upgrade_hardfork.sh
80+
- name: Upgrade (governance)
81+
script: test_upgrade_governance.sh
82+
- name: Comprehensive
83+
script: test_upgrade_comprehensive.sh
84+
foundry: true
85+
- name: Validator devcontainer parity
86+
script: test_validator_devcontainer_parity.sh
87+
- name: RPC suite
88+
script: test_rpc_suite.sh
89+
foundry: true
90+
91+
steps:
92+
- uses: actions/checkout@v6
93+
94+
- name: Download images
95+
uses: actions/download-artifact@v8
96+
with:
97+
name: e2e-images
98+
path: /tmp
99+
100+
- name: Load images into Docker
101+
run: gunzip -c /tmp/e2e-images.tar.gz | docker load
102+
103+
- name: Install Kind
104+
run: |
105+
curl -sSLo ./kind "https://kind.sigs.k8s.io/dl/v0.29.0/kind-linux-amd64"
106+
chmod +x ./kind
107+
sudo mv ./kind /usr/local/bin/kind
108+
109+
- name: Install Foundry
110+
if: matrix.foundry
111+
uses: foundry-rs/foundry-toolchain@v1
112+
113+
- name: Run ${{ matrix.name }}
114+
env:
115+
FW_SKIP_BUILD: "true"
116+
FW_SKIP_CLEANUP: "true"
117+
run: bash e2e/kind/tests/${{ matrix.script }}
118+
119+
- name: Collect debug logs
120+
if: failure()
121+
run: |
122+
mkdir -p /tmp/e2e-logs
123+
for i in 0 1 2 3; do
124+
kubectl logs -n moca-e2e "validator-${i}-0" -c mocad --tail=200 \
125+
> "/tmp/e2e-logs/validator-${i}.log" 2>/dev/null || true
126+
kubectl describe pod -n moca-e2e "validator-${i}-0" \
127+
> "/tmp/e2e-logs/validator-${i}-describe.txt" 2>/dev/null || true
128+
done
129+
130+
- name: Upload debug logs
131+
if: failure()
132+
uses: actions/upload-artifact@v7
133+
with:
134+
name: e2e-logs-${{ matrix.name }}
135+
path: /tmp/e2e-logs
136+
retention-days: 7

.github/workflows/notify-e2e.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Notify E2E Hub
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions: {}
8+
9+
jobs:
10+
notify:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Dispatch to moca-e2e
14+
uses: peter-evans/repository-dispatch@v4
15+
with:
16+
token: ${{ secrets.E2E_HUB_PAT }}
17+
repository: mocachain/moca-e2e
18+
event-type: repo-updated
19+
client-payload: >-
20+
{
21+
"repo": "${{ github.repository }}",
22+
"sha": "${{ github.sha }}",
23+
"ref": "${{ github.ref }}",
24+
"actor": "${{ github.actor }}"
25+
}

Makefile

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,4 +622,39 @@ precompile:
622622
@cd x/evm/precompiles && sh compile.sh
623623

624624
verify:
625-
@cd solidity && node verify.js
625+
@cd solidity && node verify.js
626+
627+
###############################################################################
628+
### Kind E2E Tests ###
629+
###############################################################################
630+
631+
E2E_KIND_DIR := e2e/kind
632+
633+
# Run all Kind e2e framework tests
634+
e2e-fw:
635+
@bash $(E2E_KIND_DIR)/framework/runner.sh
636+
637+
# Run a single test: make e2e-fw-test TEST=smoke
638+
# Validator parity (moca-devcontainer check-validators.sh test): TEST=validator_devcontainer_parity
639+
# RPC + balances/validators parity (devcontainer RPC/rpc.sh + check-validators): TEST=rpc_suite
640+
e2e-fw-test:
641+
@bash $(E2E_KIND_DIR)/tests/test_$(TEST).sh
642+
643+
# Run without cleanup (for dev): make e2e-fw-dev TEST=smoke
644+
e2e-fw-dev:
645+
@FW_SKIP_CLEANUP=true bash $(E2E_KIND_DIR)/tests/test_$(TEST).sh
646+
647+
# Individual Kind e2e steps
648+
e2e-kind-setup:
649+
@bash $(E2E_KIND_DIR)/scripts/setup-kind.sh
650+
651+
e2e-kind-build:
652+
@bash $(E2E_KIND_DIR)/scripts/build-images.sh
653+
654+
e2e-kind-deploy:
655+
@bash $(E2E_KIND_DIR)/scripts/deploy.sh
656+
657+
e2e-kind-cleanup:
658+
@bash $(E2E_KIND_DIR)/scripts/cleanup.sh
659+
660+
.PHONY: e2e-fw e2e-fw-test e2e-fw-dev e2e-kind-setup e2e-kind-build e2e-kind-deploy e2e-kind-cleanup

e2e/kind/Dockerfile.e2e

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# syntax=docker/dockerfile:1
2+
# Build mocad from local source for e2e testing.
3+
FROM golang:1.25.10-bookworm AS builder
4+
5+
ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__"
6+
ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__"
7+
8+
WORKDIR /workspace
9+
COPY go.mod go.sum ./
10+
RUN --mount=type=cache,target=/go/pkg/mod \
11+
go mod download
12+
13+
COPY . .
14+
RUN --mount=type=cache,target=/go/pkg/mod \
15+
--mount=type=cache,target=/root/.cache/go-build \
16+
make build
17+
18+
FROM debian:bookworm-slim
19+
RUN apt-get update && apt-get install -y --no-install-recommends bash ca-certificates jq curl && rm -rf /var/lib/apt/lists/*
20+
COPY --from=builder /workspace/build/mocad /usr/local/bin/mocad
21+
ENTRYPOINT ["mocad"]

e2e/kind/Dockerfile.e2e-gitref

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# syntax=docker/dockerfile:1
2+
# Build mocad from a specific git ref (tag/branch/commit) for upgrade tests.
3+
ARG GO_VERSION=1.25.10
4+
FROM golang:${GO_VERSION}-bookworm AS builder
5+
6+
ARG GIT_REF=main
7+
ARG REPO_URL=github.com/mocachain/moca
8+
9+
ENV CGO_CFLAGS="-O -D__BLST_PORTABLE__"
10+
ENV CGO_CFLAGS_ALLOW="-O -D__BLST_PORTABLE__"
11+
12+
WORKDIR /workspace
13+
14+
RUN git clone "https://${REPO_URL}.git" . && \
15+
git checkout "${GIT_REF}" && \
16+
make build
17+
18+
FROM debian:bookworm-slim
19+
RUN apt-get update && apt-get install -y --no-install-recommends bash ca-certificates jq curl && rm -rf /var/lib/apt/lists/*
20+
COPY --from=builder /workspace/build/mocad /usr/local/bin/mocad
21+
ENTRYPOINT ["mocad"]

0 commit comments

Comments
 (0)