datahaven/.github/workflows/task-e2e.yml
undercover-cactus 53d209bbae
test: only inject contracts in e2e tests if INJECT_CONTRACTS env is 'true' (#315)
In this PR we add an environment variable `INJECT_CONTRACTS`. This
environment variable specify if the contracts should be injected in the
e2e tests. By default it is false. The environment variable is set to
`true` in the CI job that run the e2e tests.

We are using a environment variable because `bun test` doesn't allow for
passing extra arguments.

A note about the new variable has been added in the documentation to
inform about the new behavior.

---------

Co-authored-by: Gonza Montiel <gonzamontiel@users.noreply.github.com>
2025-11-24 12:07:36 +01:00

150 lines
5 KiB
YAML

# End-To-End Tests: CI for starting a full ETH private network, deploying AVS and running tests.
#
# Overview:
# 1. Start kurtosis network
# 2. Deploy AVS contracts
# 3. Start DataHaven node
# 4. Run E2E tests
name: E2E - Kurtosis Deploy and Verify
on:
workflow_dispatch:
inputs:
image-tag:
description: "The tag of the docker image"
required: true
type: string
workflow_call:
inputs:
image-tag:
description: "The tag of the docker image"
required: true
type: string
permissions:
contents: read
packages: read
env:
FOUNDRY_PROFILE: ci
LOG_LEVEL: debug
DOCKER_HOST: unix:///run/user/1020/podman/podman.sock
KURTOSIS_CORE_IMAGE: ghcr.io/stiiifff/kurtosis/kurtosis-core
KURTOSIS_ENGINE_IMAGE: ghcr.io/stiiifff/kurtosis/kurtosis-engine
KURTOSIS_VERSION: 1.11.1
INJECT_CONTRACTS: true
jobs:
kurtosis:
runs-on:
group: DH-Testing
name: E2E Tests with Kurtosis Ethereum Network
defaults:
run:
working-directory: test
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- uses: oven-sh/setup-bun@v2
with:
bun-version-file: test/.bun-version
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Pull Kurtosis images
run: |
docker pull ${{ env.KURTOSIS_CORE_IMAGE }}:${{ env.KURTOSIS_VERSION }}
docker pull ${{ env.KURTOSIS_ENGINE_IMAGE }}:${{ env.KURTOSIS_VERSION }}
- name: Install Kurtosis
run: |
# Install Kurtosis locally without sudo
if ! command -v kurtosis &> /dev/null; then
echo "Installing Kurtosis $KURTOSIS_VERSION locally"
mkdir -p ~/.local/bin
# wget -q -O kurtosis-cli.tar.gz "https://github.com/kurtosis-tech/kurtosis-cli-release-artifacts/releases/download/${KURTOSIS_VERSION}/kurtosis-cli_${KURTOSIS_VERSION}_linux_amd64.tar.gz"
# tar -xzf kurtosis-cli.tar.gz -C ~/.local/bin
# rm kurtosis-cli.tar.gz
# For now, we use a patched version of Kurtosis CLI & Engine that supports Podman properly
wget -q -O ~/.local/bin/kurtosis https://github.com/stiiifff/kurtosis/releases/download/1.11.99/kurtosis
echo "$HOME/.local/bin" >> $GITHUB_PATH
export PATH="$HOME/.local/bin:$PATH"
else
echo "Kurtosis is already installed: $(kurtosis version)"
fi
kurtosis analytics disable
kurtosis version
- name: Configure Kurtosis cluster = podman
run: |
# Get the config path from Kurtosis itself (portable)
CFG_PATH="$(kurtosis config path)"
mkdir -p "$(dirname "$CFG_PATH")"
# Create/update config with a podman cluster entry
cat > "$CFG_PATH" <<'YML'
config-version: 6
should-send-metrics: true
kurtosis-clusters:
docker:
type: "docker"
podman:
type: "podman"
YML
kurtosis cluster set podman
kurtosis cluster get
- name: Start Kurtosis engine with Podman
run: |
kurtosis engine stop
kurtosis clean
kurtosis engine start
kurtosis engine status
- uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Cache Foundry libraries
uses: actions/cache/restore@v4
with:
path: ../contracts/lib
key: ${{ runner.os }}-foundry-libs-${{ hashFiles('.gitmodules') }}
restore-keys: |
${{ runner.os }}-foundry-libs-
- name: Cache Foundry build artifacts
uses: actions/cache/restore@v4
with:
path: |
../contracts/out
../contracts/cache
key: ${{ runner.os }}-foundry-build-${{ hashFiles('contracts/foundry.toml', 'contracts/**/*.sol') }}
restore-keys: |
${{ runner.os }}-foundry-build-
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download Snowbridge relay binary
run: |
docker create --name temp datahavenxyz/snowbridge-relay:latest
mkdir -p tmp/bin
docker cp temp:/usr/local/bin/snowbridge-relay tmp/bin/
chmod +x tmp/bin/snowbridge-relay
docker rm -fv temp
tmp/bin/snowbridge-relay --help
- name: Pull DataHaven node image
run: |
docker pull ghcr.io/datahaven-xyz/datahaven/datahaven:${{ inputs.image-tag }}
docker tag ghcr.io/datahaven-xyz/datahaven/datahaven:${{ inputs.image-tag }} datahavenxyz/datahaven:local
- run: bun install
- name: Run E2E tests
run: bun test:e2e
- name: Delete volumes not used
if: always()
run: podman system prune --volumes -f