Skip to content

Commit id a04483fe0b1567dc3c590e6340a5caf83bc8e87b: CI-CD build and deploy docker images based on the commit id in the main branch #407

Commit id a04483fe0b1567dc3c590e6340a5caf83bc8e87b: CI-CD build and deploy docker images based on the commit id in the main branch

Commit id a04483fe0b1567dc3c590e6340a5caf83bc8e87b: CI-CD build and deploy docker images based on the commit id in the main branch #407

name: CI-CD build and deploy docker images based on the last commit in the main branch
run-name: "Commit id ${{ github.sha }}: CI-CD build and deploy docker images based on the commit id in the main branch"
env:
APPLICATION: "erigon"
BUILDER_IMAGE: "golang:1.22-bookworm"
APP_REPO: "erigontech/erigon"
PACKAGE: "github.com/erigontech/erigon"
TARGET_BASE_IMAGE: "debian:12.7-slim"
LABEL_DESCRIPTION: "[docker image built on a last commit id from the ref branch] Erigon is an implementation of Ethereum (execution layer with embeddable consensus layer), on the efficiency frontier. Archive Node by default."
KEEP_IMAGES: 100
on:
push:
branches:
- 'release/2.61'
paths-ignore:
- '.github/**'
workflow_dispatch:
jobs:
define_matrix:
runs-on: ubuntu-latest
outputs:
os: ${{ steps.os.outputs.os }}
steps:
- name: Define os
id: os
run: echo 'os=ubuntu-latest' >> "$GITHUB_OUTPUT"
Build_and_test:
needs: define_matrix
runs-on: ${{ needs.define_matrix.outputs.os }}
steps:
- name: Fast checkout git repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 ## 4.1.7 release
with:
repository: ${{ env.APP_REPO }}
fetch-depth: 1
ref: ${{ github.ref_name }}
path: 'erigon'
- name: Setup go env and cache
uses: actions/setup-go@v5
with:
go-version: '>=1.22'
go-version-file: 'erigon/go.mod'
cache-dependency-path: |
erigon/go.sum
- name: Get commit id
id: getCommitId
run: |
cd erigon
echo "id=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "short_commit_id=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT
echo "week_of_the_year=$(/bin/date -u "+%Y-%W")" >> $GITHUB_OUTPUT
cd ..
- name: Set up QEMU
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf ## v3.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db ## v3.6.1
- name: Setup GO build and pkg cache for one week only
id: cache
uses: actions/cache@v4
with:
key: cache-year-week-${{ steps.getCommitId.outputs.week_of_the_year }}-go.mod-hash:${{ hashFiles('erigon/go.mod') }}
path: |
~/go/pkg
~/.cache
# - name: Build for linux/arm64
# run: >
# docker run --platform linux/arm64
# --rm
# -v $(pwd)/erigon:/erigon:ro
# -v ${GITHUB_WORKSPACE}/build-arm64:/erigon-build
# -v ${HOME}/.cache:/root/.cache
# -v ${HOME}/go/pkg/mod:/go/pkg/mod
# -w /erigon --entrypoint /bin/bash
# ${{ env.BUILDER_IMAGE }}
# -c "git config --global --add safe.directory /erigon;
# make GOARCH=arm64 GOBIN=/erigon-build BUILD_TAGS=nosqlite,noboltdb,nosilkworm
# erigon downloader devnet evm caplin diag integration rpcdaemon sentry txpool"
- name: Build for linux/amd64
run: >
docker run --platform linux/amd64
--rm
-v $(pwd)/erigon:/erigon:ro
-v ${GITHUB_WORKSPACE}/build-amd64:/erigon-build
-v ${HOME}/.cache:/root/.cache
-v ${HOME}/go/pkg/mod:/go/pkg/mod
-w /erigon --entrypoint /bin/bash
${{ env.BUILDER_IMAGE }}
-c "git config --global --add safe.directory /erigon;
make GOARCH=amd64 GOAMD64=v1 GOBIN=/erigon-build BUILD_TAGS=nosqlite,noboltdb
erigon downloader devnet evm caplin diag integration rpcdaemon sentry txpool;
find / -name libsilkworm_capi.so -exec install {} /erigon-build \; "
- name: Create archives and checksums
env:
RELEASE_VERSION: "local-${{ steps.getCommitId.outputs.short_commit_id }}"
run: |
cd ${GITHUB_WORKSPACE}
mkdir $GITHUB_WORKSPACE/release
for dir in build-*; do
cd $dir
echo Current directory is $(pwd). Checksum file and archive will be created for this directory
# sha256sum * > checksums.txt
tar czvf $GITHUB_WORKSPACE/release/${APPLICATION}_${RELEASE_VERSION}_linux_$(echo $dir | sed 's,build-,,').tar.gz \
--transform "s,^./,${APPLICATION}_${RELEASE_VERSION}_linux_$(echo $dir | sed 's,build-,,')/," .
cd -
done
cd $GITHUB_WORKSPACE/release
sha256sum * > ${APPLICATION}_${RELEASE_VERSION}_checksums.txt
echo Content of release directory:
find . -type f -ls
- name: Build multi-platform docker image based on the commit id ${{ steps.getCommitId.outputs.short_commit_id }} in the ref branch
env:
BUILD_VERSION: "local-${{ steps.getCommitId.outputs.short_commit_id }}"
DOCKERFILE_PATH: Dockerfile.release
run: |
cd ${GITHUB_WORKSPACE}/release
echo "Current directory is $(pwd) ."
docker build \
--file ${{ github.workspace }}/erigon/${{ env.DOCKERFILE_PATH }} \
--build-arg RELEASE_DOCKER_BASE_IMAGE=${{ env.TARGET_BASE_IMAGE }} \
--build-arg VERSION=${{ env.BUILD_VERSION }} \
--build-arg APPLICATION=${{ env.APPLICATION }} \
--tag ${{ env.APPLICATION }}:${{ env.BUILD_VERSION }} \
--tag ${{ env.APPLICATION }}:latest \
--tag ${{ env.APPLICATION }} \
--target release .
- name: Cleanup some space
run: |
df -h
sudo rm -drf \
/usr/share/dotnet \
/usr/share/swift \
/usr/local/julia* \
/opt/google/chrome \
/opt/microsoft/msedge \
/opt/microsoft/powershell \
/usr/lib/mono \
/usr/local/lib/android \
/usr/local/share/chromium
echo DEBUG current list of docker images
docker image ls
echo DEBUG Removing legacy node:1 matching docker images
sudo docker image rm $(docker image ls --filter=reference='node:1*' -q)
echo DEBUG new disk free output
df -h
- name: Install dependencies on Linux
if: runner.os == 'Linux'
run: sudo apt update && sudo apt install build-essential
- name: download kurtosis config - with pectra
env:
BUILD_VERSION: local-${{ steps.getCommitId.outputs.short_commit_id }}
# TODO: update the path to the config file with main branch before PR is merged
run: |
wget -O kurtosis_config_with_p.yaml https://raw.githubusercontent.com/erigontech/erigon/feat/assertor-testing/.github/workflows/kurtosis/config.properties
sed 's#<<ERIGON_IMAGE_PLACEHOLDER>>#${{ env.APPLICATION }}:${{ env.BUILD_VERSION }}#g' kurtosis_config_with_p.yaml > kurtosis_config.yaml
- name: Run Kurtosis + assertoor tests
uses: ethpandaops/kurtosis-assertoor-github-action@v1
with:
enclave_name: "kurtosis-run-${{ github.run_id }}"
ethereum_package_args: "./kurtosis_config.yaml"
#kurtosis_extra_args: --verbosity detailed --cli-log-level trace
enclave_dump: false