Skip to content

Commit d8c4b0e

Browse files
Merge branch 'feature/erigon-live-tracer-hook-port-based-on-main' into feat/firehose-live-tracer-hook-port-based-on-main
2 parents b71690d + b22cb87 commit d8c4b0e

File tree

5,852 files changed

+1183068
-1396416
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,852 files changed

+1183068
-1396416
lines changed
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
name: CI-CD build and deploy docker images based on the last commit in the main branch
2+
run-name: "Commit id ${{ github.sha }}: CI-CD build and deploy docker images based on the commit id in the main branch"
3+
4+
env:
5+
APPLICATION: "erigon"
6+
BUILDER_IMAGE: "golang:1.23.3-alpine3.20"
7+
TARGET_BASE_IMAGE: "alpine:3.20.3"
8+
APP_REPO: "erigontech/erigon"
9+
CHECKOUT_REF: "main"
10+
DOCKERHUB_REPOSITORY: "erigontech/erigon"
11+
LABEL_DESCRIPTION: "[docker image built on a last commit id from the main branch] Erigon is an implementation of Ethereum (execution layer with embeddable consensus layer), on the efficiency frontier. Archive Node by default."
12+
KEEP_IMAGES: 100
13+
14+
on:
15+
push:
16+
branches:
17+
- 'main'
18+
paths-ignore:
19+
- '.github/**'
20+
workflow_dispatch:
21+
22+
jobs:
23+
define_matrix:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
os: ${{ steps.os.outputs.os }}
27+
28+
steps:
29+
- name: Define os
30+
id: os
31+
run: echo 'os=ubuntu-latest' >> "$GITHUB_OUTPUT"
32+
33+
Build:
34+
needs: define_matrix
35+
runs-on: ${{ needs.define_matrix.outputs.os }}
36+
timeout-minutes: 45
37+
outputs:
38+
docker_build_tag: ${{ steps.built_tag_export.outputs.docker_build_tag }}
39+
40+
steps:
41+
- name: Fast checkout git repository
42+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 ## 4.1.7 release
43+
with:
44+
repository: ${{ env.APP_REPO }}
45+
fetch-depth: 1
46+
ref: ${{ env.CHECKOUT_REF }}
47+
path: 'erigon'
48+
49+
- name: Setup go env and cache
50+
uses: actions/setup-go@v5
51+
with:
52+
go-version: '>=1.22'
53+
go-version-file: 'erigon/go.mod'
54+
cache-dependency-path: |
55+
erigon/go.sum
56+
57+
- name: Get commit id
58+
id: getCommitId
59+
run: |
60+
cd erigon
61+
echo "id=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
62+
echo "short_commit_id=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT
63+
cd ..
64+
65+
- name: Login to Docker Hub
66+
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 ## v3.3.0
67+
with:
68+
username: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_USERNAME }}
69+
password: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_TOKEN }}
70+
71+
- name: Set up QEMU
72+
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf ## v3.2.0
73+
74+
- name: Set up Docker Buildx
75+
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db ## v3.6.1
76+
77+
- name: Build arm64
78+
run: |
79+
docker run --platform linux/arm64 \
80+
--rm -v $(pwd)/erigon:/erigon:ro \
81+
-v $(pwd)/build-arm64:/erigon-build \
82+
-v ${HOME}/.cache/go-build/arm64:/root/.cache/go-build \
83+
-v ${HOME}/go/pkg/mod:/go/pkg/mod \
84+
-w /erigon --entrypoint /bin/sh \
85+
${{ env.BUILDER_IMAGE }} \
86+
-c "apk update; apk add make git gcc libstdc++ build-base linux-headers bash ca-certificates; git config --global --add safe.directory /erigon; make GOARCH=arm64 GOBIN=/erigon-build BUILD_TAGS=nosqlite,noboltdb,nosilkworm erigon integration rpcdaemon"
87+
88+
- name: Build amd64
89+
run: |
90+
docker run --platform linux/amd64 \
91+
--rm -v $(pwd)/erigon:/erigon:ro \
92+
-v $(pwd)/build-amd64:/erigon-build \
93+
-v ${HOME}/.cache/go-build/amd64:/root/.cache/go-build \
94+
-v ${HOME}/go/pkg/mod:/go/pkg/mod \
95+
-w /erigon --entrypoint /bin/sh \
96+
${{ env.BUILDER_IMAGE }} \
97+
-c "apk update; apk add make git gcc libstdc++ build-base linux-headers bash ca-certificates; git config --global --add safe.directory /erigon; make GOARCH=amd64 GOAMD64=v2 GOBIN=/erigon-build BUILD_TAGS=nosqlite,noboltdb,nosilkworm erigon integration rpcdaemon"
98+
99+
- name: Build and push multi-platform docker image based on the commit id ${{ steps.getCommitId.outputs.short_commit_id }} in the main branch
100+
env:
101+
BUILD_VERSION: "main-${{ steps.getCommitId.outputs.short_commit_id }}"
102+
DOCKER_URL: ${{ env.DOCKERHUB_REPOSITORY }}
103+
DOCKERFILE_PATH: Dockerfile.release
104+
run: |
105+
cp -vr build-amd64 erigon/
106+
cp -vr build-arm64 erigon/
107+
cd erigon
108+
docker buildx build \
109+
--file ${{ env.DOCKERFILE_PATH }} \
110+
--target ci-cd-main-branch \
111+
--attest type=provenance,mode=max \
112+
--sbom=true \
113+
--build-arg CI_CD_MAIN_TARGET_BASE_IMAGE=${{ env.TARGET_BASE_IMAGE }} \
114+
--build-arg CI_CD_MAIN_BUILDER_IMAGE=${{ env.BUILDER_IMAGE }} \
115+
--tag ${{ env.DOCKER_URL }}:${{ env.BUILD_VERSION }} \
116+
--tag ${{ env.DOCKER_URL }}:main-latest \
117+
--label org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
118+
--label org.opencontainers.image.authors="https://github.com/erigontech/erigon/graphs/contributors" \
119+
--label org.opencontainers.image.url="https://github.com/erigontech/erigon/blob/main/Dockerfile" \
120+
--label org.opencontainers.image.documentation="https://github.com/erigontech/erigon/blob/main/Dockerfile" \
121+
--label org.opencontainers.image.source="https://github.com/erigontech/erigon/blob/main/Dockerfile" \
122+
--label org.opencontainers.image.version=${{ steps.getCommitId.outputs.id }} \
123+
--label org.opencontainers.image.revision=${{ steps.getCommitId.outputs.id }} \
124+
--label org.opencontainers.image.vcs-ref-short=${{ steps.getCommitId.outputs.short_commit_id }} \
125+
--label org.opencontainers.image.vendor="${{ github.repository_owner }}" \
126+
--label org.opencontainers.image.description="${{ env.LABEL_DESCRIPTION }}" \
127+
--label org.opencontainers.image.base.name="${{ env.TARGET_BASE_IMAGE }}" \
128+
--push \
129+
--platform linux/amd64,linux/arm64 .
130+
131+
- name: export and print docker build tag, cleanup old docker images
132+
id: built_tag_export
133+
env:
134+
BUILD_VERSION: "main-${{ steps.getCommitId.outputs.short_commit_id }}"
135+
run: |
136+
echo "docker_build_tag=${{ env.BUILD_VERSION }}" >> $GITHUB_OUTPUT
137+
echo The following docker images have been published:
138+
echo "${{ env.DOCKERHUB_REPOSITORY }}:main-${{ env.BUILD_VERSION }}"
139+
echo "${{ env.DOCKERHUB_REPOSITORY }}:main-latest"
140+
echo
141+
echo "Cleanup old docker images matching pattern tag ~= main-XXXXXXX"
142+
curl_cmd="curl -s -H \"Authorization: JWT ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_TOKEN }}\" "
143+
dockerhub_url='https://hub.docker.com/v2/namespaces/erigontech/repositories/erigon'
144+
my_list () {
145+
# First page:
146+
next_page="$dockerhub_url/tags?page=1&page_size=100"
147+
while [ "$next_page" != "null" ]
148+
do
149+
# Print tags and push dates for tags matching "main-":
150+
$curl_cmd $next_page | jq -r '.results|.[]|.name + " " + .tag_last_pushed' | grep 'main-'
151+
next_page=`$curl_cmd $next_page | jq '.next' | sed -e 's/^\"//' -e 's/\"$//'`
152+
done
153+
}
154+
155+
my_list | tail -n+${{ env.KEEP_IMAGES }} | while read line; do
156+
echo -n "Removing docker image/published - $line "
157+
current_image=$(echo $line | sed -e 's/^\(main-.\{7\}\) .*/\1/')
158+
output_code=$(curl --write-out %{http_code} --output curl-output.log \
159+
-s -X DELETE -H "Accept: application/json" \
160+
-H "Authorization: JWT ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_TOKEN }}" \
161+
https://hub.docker.com/v2/repositories/erigontech/erigon/tags/${current_image} )
162+
if [ $output_code -ne 204 ]; then
163+
echo "ERROR: failed to remove docker image erigon:${current_image}"
164+
echo "ERROR: API response: $(cat curl-output.log)."
165+
else
166+
echo -n " - removed. "
167+
fi
168+
echo "Done."
169+
done
170+
171+
run-kurtosis-assertoor:
172+
needs: [define_matrix, Build]
173+
uses: erigontech/erigon/.github/workflows/test-kurtosis-assertoor.yml@main
174+
with:
175+
checkout_ref: ${{ github.sha }}
176+
os: ${{ needs.define_matrix.outputs.os }}
177+
docker_build_tag: ${{ needs.Build.outputs.docker_build_tag }}

.github/workflows/ci.yml

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ on:
66
- 'release/**'
77
pull_request:
88
branches:
9-
- main
10-
- 'release/**'
9+
- '**'
1110
types:
1211
- opened
1312
- reopened
@@ -17,7 +16,11 @@ on:
1716

1817
concurrency:
1918
group: ${{ github.ref }}
20-
cancel-in-progress: true
19+
cancel-in-progress: ${{ !contains(fromJSON('[
20+
"refs/heads/release/2.60",
21+
"refs/heads/release/2.61",
22+
"refs/heads/main"
23+
]'), github.ref) }}
2124

2225
jobs:
2326
tests:
@@ -34,9 +37,16 @@ jobs:
3437
- uses: actions/checkout@v4
3538
with:
3639
fetch-depth: 0
37-
- uses: actions/setup-go@v4
40+
41+
- uses: actions/setup-go@v5
3842
with:
39-
go-version: '1.21'
43+
go-version: '1.22'
44+
cache: ${{ contains(fromJSON('[
45+
"refs/heads/release/2.60",
46+
"refs/heads/release/2.61",
47+
"refs/heads/main"
48+
]'), github.ref) }}
49+
4050
- name: Install dependencies on Linux
4151
if: runner.os == 'Linux'
4252
run: sudo apt update && sudo apt install build-essential
@@ -54,24 +64,12 @@ jobs:
5464
echo >&2 "Reproducible build broken"; cat erigon1.sha256; cat erigon2.sha256; exit 1
5565
fi
5666
57-
- name: Install golangci-lint
58-
if: runner.os == 'Linux'
59-
uses: golangci/golangci-lint-action@v4
60-
with:
61-
version: v1.59.1
62-
skip-build-cache: true
63-
args: --help
64-
65-
- name: Lint
66-
if: runner.os == 'Linux'
67-
run: make lint
68-
6967
- name: Test
7068
run: make test
7169

7270
- name: SonarCloud
7371
if: runner.os == 'Linux'
74-
uses: SonarSource/sonarcloud-github-action@v2.1.1
72+
uses: SonarSource/sonarcloud-github-action@v2.3.0
7573
env:
7674
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
7775
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -90,11 +88,16 @@ jobs:
9088
with:
9189
minimum-size: 8GB
9290
- uses: actions/checkout@v4
93-
- uses: actions/setup-go@v4
91+
- uses: actions/setup-go@v5
9492
with:
95-
go-version: '1.21'
96-
97-
- uses: actions/cache@v3
93+
go-version: '1.22'
94+
cache: ${{ contains(fromJSON('[
95+
"refs/heads/release/2.60",
96+
"refs/heads/release/2.61",
97+
"refs/heads/main"
98+
]'), github.ref) }}
99+
100+
- uses: actions/cache@v4
98101
with:
99102
path: |
100103
C:\ProgramData\chocolatey\lib\mingw
@@ -113,31 +116,3 @@ jobs:
113116

114117
- name: Test erigon-lib
115118
run: cd erigon-lib && make test-no-fuzz
116-
117-
docker-build-check:
118-
# don't run this on main - the PR must have run it to be merged and it misleads that this pushes the docker image
119-
if: (${{ github.event_name == 'push' || !github.event.pull_request.draft }}) && ${{ github.ref != 'refs/heads/main' }}
120-
runs-on: ubuntu-22.04
121-
122-
steps:
123-
- uses: AutoModality/action-clean@v1
124-
- uses: actions/checkout@v4
125-
with:
126-
fetch-depth: 0 # fetch git tags for "git describe"
127-
128-
- name: make docker (see dockerhub for image builds)
129-
run: DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker
130-
131-
# check with root permissions, should be cached from previous build
132-
- name: sudo make docker
133-
run: sudo DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker
134-
135-
# automated-tests:
136-
# runs-on:
137-
# ubuntu-22.04
138-
# if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}
139-
# steps:
140-
# - uses: actions/checkout@v4
141-
#
142-
# - name: run automated testing
143-
# run: BUILD_ERIGON=1 ./tests/automated-testing/run.sh
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Remove docker image
2+
run-name: Request to remove erigontech/erigon:${{ inputs.docker_image_tag }} by @${{ github.actor }}
3+
4+
env:
5+
DOCKERHUB_REPOSITORY: "erigontech/erigon"
6+
API_URL: "https://hub.docker.com/v2/repositories/erigontech/erigon/tags"
7+
8+
on:
9+
push:
10+
branches-ignore:
11+
- '**'
12+
workflow_dispatch:
13+
inputs:
14+
docker_image_tag:
15+
required: true
16+
type: string
17+
default: 'not_yet_defined'
18+
description: 'Docker image tag to remove from hub.docker.com. Works only for erigontech/erigon'
19+
20+
jobs:
21+
22+
build-release:
23+
runs-on: ubuntu-latest
24+
timeout-minutes: 15
25+
name: Remove docker image
26+
27+
steps:
28+
29+
- name: Run API Call
30+
env:
31+
TOKEN: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_TOKEN }}
32+
run: |
33+
output_code=$(curl --write-out %{http_code} --output curl-output.log \
34+
-s -X DELETE -H "Accept: application/json" \
35+
-H "Authorization: JWT ${{ env.TOKEN }}" \
36+
${{ env.API_URL }}/${{ inputs.docker_image_tag }} )
37+
if [ $output_code -ne 204 ]; then
38+
echo "ERROR: failed to remove docker image ${{ env.DOCKERHUB_REPOSITORY }}:${{ inputs.docker_image_tag }}"
39+
echo "ERROR: API response: $(cat curl-output.log)."
40+
exit 1
41+
else
42+
echo "SUCCESS: docker image ${{ env.DOCKERHUB_REPOSITORY }}:${{ inputs.docker_image_tag }} removed."
43+
exit 0
44+
fi

.github/workflows/docker-tags.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,24 @@ jobs:
1616
fetch-depth: 0
1717

1818
- name: dockerhub-login
19-
uses: docker/login-action@v2
19+
uses: docker/login-action@v3
2020
with:
2121
username: ${{ secrets.DOCKERHUB }}
2222
password: ${{ secrets.DOCKERHUB_KEY }}
2323
- name: ghcr-login
24-
uses: docker/login-action@v2
24+
uses: docker/login-action@v3
2525
with:
2626
registry: ghcr.io
2727
username: ${{ github.repository_owner }}
2828
password: ${{ secrets.GITHUB_TOKEN }}
2929

30-
- uses: docker/setup-qemu-action@v2
30+
- uses: docker/setup-qemu-action@v3
3131

3232
- run: |
3333
make release-dry-run
3434
docker images
35-
# docker image push --all-tags thorax/erigon
36-
# docker image push --all-tags ghcr.io/erigontech/erigon
3735
env:
3836
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3937
VERSION: ${GITHUB_REF#refs/tags/}
4038
DOCKER_USERNAME: ${{ secrets.DOCKERHUB }}
41-
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_KEY }}
39+
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_KEY }}

0 commit comments

Comments
 (0)