-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): improve
hive
workflow (#9320)
- Loading branch information
Showing
6 changed files
with
188 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
# Create the hive_assets directory | ||
mkdir hive_assets/ | ||
|
||
cd hivetests | ||
go build . | ||
|
||
./hive -client reth # first builds and caches the client | ||
|
||
# Run each hive command in the background for each simulator and wait | ||
echo "Building images" | ||
./hive -client reth --sim "pyspec" -sim.timelimit 1s || true & | ||
./hive -client reth --sim "ethereum/engine" -sim.timelimit 1s || true & | ||
./hive -client reth --sim "devp2p" -sim.timelimit 1s || true & | ||
./hive -client reth --sim "ethereum/rpc-compat" -sim.timelimit 1s || true & | ||
./hive -client reth --sim "smoke/genesis" -sim.timelimit 1s || true & | ||
./hive -client reth --sim "smoke/network" -sim.timelimit 1s || true & | ||
./hive -client reth --sim "ethereum/sync" -sim.timelimit 1s || true & | ||
wait | ||
|
||
# Run docker save in parallel and wait | ||
echo "Saving images" | ||
docker save hive/hiveproxy:latest -o ../hive_assets/hiveproxy.tar & | ||
docker save hive/simulators/devp2p:latest -o ../hive_assets/devp2p.tar & | ||
docker save hive/simulators/ethereum/engine:latest -o ../hive_assets/engine.tar & | ||
docker save hive/simulators/ethereum/rpc-compat:latest -o ../hive_assets/rpc_compat.tar & | ||
docker save hive/simulators/ethereum/pyspec:latest -o ../hive_assets/pyspec.tar & | ||
docker save hive/simulators/smoke/genesis:latest -o ../hive_assets/smoke_genesis.tar & | ||
docker save hive/simulators/smoke/network:latest -o ../hive_assets/smoke_network.tar & | ||
docker save hive/simulators/ethereum/sync:latest -o ../hive_assets/ethereum_sync.tar & | ||
wait | ||
|
||
# Make sure we don't rebuild images on the CI jobs | ||
git apply ../.github/assets/hive/no_sim_build.diff | ||
go build . | ||
mv ./hive ../hive_assets/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -eo pipefail | ||
|
||
# List of tar files to load | ||
IMAGES=( | ||
"/tmp/hiveproxy.tar" | ||
"/tmp/devp2p.tar" | ||
"/tmp/engine.tar" | ||
"/tmp/rpc_compat.tar" | ||
"/tmp/pyspec.tar" | ||
"/tmp/smoke_genesis.tar" | ||
"/tmp/smoke_network.tar" | ||
"/tmp/ethereum_sync.tar" | ||
"/tmp/reth_image.tar" | ||
) | ||
|
||
# Loop through the images and load them | ||
for IMAGE_TAR in "${IMAGES[@]}"; do | ||
echo "Loading image $IMAGE_TAR..." | ||
docker load -i "$IMAGE_TAR" & | ||
done | ||
|
||
wait | ||
|
||
docker image ls -a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
diff --git a/internal/libdocker/builder.go b/internal/libdocker/builder.go | ||
index 4731c9d..d717f52 100644 | ||
--- a/internal/libdocker/builder.go | ||
+++ b/internal/libdocker/builder.go | ||
@@ -7,9 +7,7 @@ import ( | ||
"fmt" | ||
"io" | ||
"io/fs" | ||
- "os" | ||
"path/filepath" | ||
- "strings" | ||
|
||
"github.com/ethereum/hive/internal/libhive" | ||
docker "github.com/fsouza/go-dockerclient" | ||
@@ -53,24 +51,8 @@ func (b *Builder) BuildClientImage(ctx context.Context, client libhive.ClientDes | ||
|
||
// BuildSimulatorImage builds a docker image of a simulator. | ||
func (b *Builder) BuildSimulatorImage(ctx context.Context, name string) (string, error) { | ||
- dir := b.config.Inventory.SimulatorDirectory(name) | ||
- buildContextPath := dir | ||
- buildDockerfile := "Dockerfile" | ||
- // build context dir of simulator can be overridden with "hive_context.txt" file containing the desired build path | ||
- if contextPathBytes, err := os.ReadFile(filepath.Join(filepath.FromSlash(dir), "hive_context.txt")); err == nil { | ||
- buildContextPath = filepath.Join(dir, strings.TrimSpace(string(contextPathBytes))) | ||
- if strings.HasPrefix(buildContextPath, "../") { | ||
- return "", fmt.Errorf("cannot access build directory outside of Hive root: %q", buildContextPath) | ||
- } | ||
- if p, err := filepath.Rel(buildContextPath, filepath.Join(filepath.FromSlash(dir), "Dockerfile")); err != nil { | ||
- return "", fmt.Errorf("failed to derive relative simulator Dockerfile path: %v", err) | ||
- } else { | ||
- buildDockerfile = p | ||
- } | ||
- } | ||
tag := fmt.Sprintf("hive/simulators/%s:latest", name) | ||
- err := b.buildImage(ctx, buildContextPath, buildDockerfile, tag, nil) | ||
- return tag, err | ||
+ return tag, nil | ||
} | ||
|
||
// BuildImage creates a container by archiving the given file system, | ||
diff --git a/internal/libdocker/proxy.go b/internal/libdocker/proxy.go | ||
index a53e5af..0bb2ea9 100644 | ||
--- a/internal/libdocker/proxy.go | ||
+++ b/internal/libdocker/proxy.go | ||
@@ -16,7 +16,7 @@ const hiveproxyTag = "hive/hiveproxy" | ||
|
||
// Build builds the hiveproxy image. | ||
func (cb *ContainerBackend) Build(ctx context.Context, b libhive.Builder) error { | ||
- return b.BuildImage(ctx, hiveproxyTag, hiveproxy.Source) | ||
+ return nil | ||
} | ||
|
||
// ServeAPI starts the API server. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
# set -x | ||
|
||
cd hivetests/ | ||
|
||
sim="${1}" | ||
limit="${2}" | ||
|
||
run_hive() { | ||
hive --sim "${sim}" --sim.limit "${limit}" --sim.parallelism 4 --client reth 2>&1 | tee /tmp/log || true | ||
} | ||
|
||
check_log() { | ||
tail -n 1 /tmp/log | sed -r 's/\x1B\[[0-9;]*[mK]//g' | ||
} | ||
|
||
attempt=0 | ||
max_attempts=5 | ||
|
||
while [ $attempt -lt $max_attempts ]; do | ||
run_hive | ||
|
||
# Check if no tests were run. sed removes ansi colors | ||
if check_log | grep -q "suites=0"; then | ||
echo "no tests were run, retrying in 5 seconds" | ||
sleep 5 | ||
attempt=$((attempt + 1)) | ||
continue | ||
fi | ||
|
||
# Check the last line of the log for "finished", "tests failed", or "test failed" | ||
if check_log | grep -Eq "(finished|tests? failed)"; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi | ||
done | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters