Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(geth): add asan and race builds #201

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@
target:
tag: bad-block-generator
repository: ethpandaops/geth
- source:
repository: ethereum/go-ethereum
ref: master
build_script: ./geth/build-asan.sh
target:
tag: asan
repository: ethpandaops/geth
- source:
repository: ethereum/go-ethereum
ref: master
build_script: ./geth/build-race.sh
target:
tag: race
repository: ethpandaops/geth
########
# reth #
########
Expand Down
50 changes: 50 additions & 0 deletions geth/build-asan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#! /bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd ${SCRIPT_DIR}/../source

# need to update dockerfile to use debian instead of alpine
# as asan go builds doesn't seem to like alpine
ORIGINAL_DOCKER_FILE="Dockerfile"
NEW_DOCKER_FILE="Dockerfile.asan"

sed -e 's|-alpine AS builder| AS builder|' \
-e 's|RUN apk add --no-cache gcc musl-dev linux-headers git|RUN apt-get update \&\& apt-get install -y --no-install-recommends build-essential git \&\& rm -rf /var/lib/apt/lists/*|' \
-e 's|RUN cd /go-ethereum \&\& go run build/ci.go install -static ./cmd/geth|RUN cd /go-ethereum \&\& go run build/ci.go install ./cmd/geth|' \
-e 's|FROM alpine:latest|FROM debian:bookworm-slim|' \
-e 's|RUN apk add --no-cache ca-certificates|RUN apt-get update \&\& apt-get install -y --no-install-recommends ca-certificates libasan8 \&\& rm -rf /var/lib/apt/lists/*|' \
"$ORIGINAL_DOCKER_FILE" > "$NEW_DOCKER_FILE"

if((`stat -c%s "${ORIGINAL_DOCKER_FILE}"`==`stat -c%s "${NEW_DOCKER_FILE}"`));then
echo "no changes detected, aborting..."
echo "needed to update dockerfile"
exit 1
fi

mv $NEW_DOCKER_FILE $ORIGINAL_DOCKER_FILE

# need to add -asan flag to geth custom build script
ORIGINAL_CI_FILE="build/ci.go"
NEW_CI_FILE="build/ci.asan.go"

awk '
/^func buildFlags\(env build\.Environment, staticLinking bool, buildTags \[\]string\) \(flags \[\]string\)/ {
print
getline
print " flags = append(flags, \"-asan\")"
}
/^[^f]/ { print }
/^func / && !/^func buildFlags/ { print }
' "$ORIGINAL_CI_FILE" > "$NEW_CI_FILE"

if((`stat -c%s "${ORIGINAL_CI_FILE}"`==`stat -c%s "${NEW_CI_FILE}"`));then
echo "no changes detected, aborting..."
echo "needed to update build/ci.go"
exit 1
fi

mv $NEW_CI_FILE $ORIGINAL_CI_FILE

docker build -t "${target_repository}:${target_tag}" -t "${target_repository}:${target_tag}-${source_git_commit_hash}" -f "../${target_dockerfile}" .
docker push "${target_repository}:${target_tag}"
docker push "${target_repository}:${target_tag}-${source_git_commit_hash}"
49 changes: 49 additions & 0 deletions geth/build-race.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#! /bin/bash

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd ${SCRIPT_DIR}/../source

# need to update dockerfile to use debian instead of alpine
ORIGINAL_DOCKER_FILE="Dockerfile"
NEW_DOCKER_FILE="Dockerfile.race"

sed -e 's|-alpine AS builder| AS builder|' \
-e 's|RUN apk add --no-cache gcc musl-dev linux-headers git|RUN apt-get update \&\& apt-get install -y --no-install-recommends build-essential git \&\& rm -rf /var/lib/apt/lists/*|' \
-e 's|RUN cd /go-ethereum \&\& go run build/ci.go install -static ./cmd/geth|RUN cd /go-ethereum \&\& go run build/ci.go install ./cmd/geth|' \
-e 's|FROM alpine:latest|FROM debian:bookworm-slim|' \
-e 's|RUN apk add --no-cache ca-certificates|RUN apt-get update \&\& apt-get install -y --no-install-recommends ca-certificates \&\& rm -rf /var/lib/apt/lists/*|' \
"$ORIGINAL_DOCKER_FILE" > "$NEW_DOCKER_FILE"

if((`stat -c%s "${ORIGINAL_DOCKER_FILE}"`==`stat -c%s "${NEW_DOCKER_FILE}"`));then
echo "no changes detected, aborting..."
echo "needed to update dockerfile"
exit 1
fi

mv $NEW_DOCKER_FILE $ORIGINAL_DOCKER_FILE

# need to add -race flag to geth custom build script
ORIGINAL_CI_FILE="build/ci.go"
NEW_CI_FILE="build/ci.race.go"

awk '
/^func buildFlags\(env build\.Environment, staticLinking bool, buildTags \[\]string\) \(flags \[\]string\)/ {
print
getline
print " flags = append(flags, \"-race\")"
}
/^[^f]/ { print }
/^func / && !/^func buildFlags/ { print }
' "$ORIGINAL_CI_FILE" > "$NEW_CI_FILE"

if((`stat -c%s "${ORIGINAL_CI_FILE}"`==`stat -c%s "${NEW_CI_FILE}"`));then
echo "no changes detected, aborting..."
echo "needed to update build/ci.go"
exit 1
fi

mv $NEW_CI_FILE $ORIGINAL_CI_FILE

docker build -t "${target_repository}:${target_tag}" -t "${target_repository}:${target_tag}-${source_git_commit_hash}" -f "../${target_dockerfile}" .
docker push "${target_repository}:${target_tag}"
docker push "${target_repository}:${target_tag}-${source_git_commit_hash}"
Loading