Skip to content

Commit 0137814

Browse files
authored
Merge pull request HemeraProtocol#186 from HemeraProtocol/pre-release/v0.4.0
Release/v0.4.0
2 parents 2876d8f + c7dc068 commit 0137814

File tree

86 files changed

+4140
-1645
lines changed

Some content is hidden

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

86 files changed

+4140
-1645
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
ETHEREUM_PUBLIC_NODE_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_RPC_URL }}'
2424
LINEA_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_DEBUG_RPC_URL }}'
2525
LINEA_PUBLIC_NODE_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_RPC_URL }}'
26+
MANTLE_PUBLIC_NODE_RPC_URL: '${{ secrets.MANTLE_PUBLIC_NODE_RPC_URL }}'
27+
MANTLE_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.MANTLE_PUBLIC_NODE_DEBUG_RPC_URL }}'
2628
POSTGRES_USER: hemera
2729
POSTGRES_PASSWORD: password
2830
POSTGRES_URL: postgresql://hemera:password@localhost:5432/hemera

.github/workflows/push-image.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Push image to AWS ECR
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- 'v*'
9+
workflow_dispatch:
10+
inputs:
11+
runPushAWS:
12+
description: 'Run push image to aws (yes/no)'
13+
required: true
14+
default: 'false'
15+
arch:
16+
required: false
17+
default: 'amd64'
18+
19+
jobs:
20+
build-and-push:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
- name: Set arch variable
27+
run: |
28+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
29+
echo "ARCH=${{ github.event.inputs.arch }}" >> $GITHUB_ENV
30+
else
31+
echo "ARCH=amd64" >> $GITHUB_ENV
32+
fi
33+
34+
- name: Set up AWS credentials
35+
uses: aws-actions/configure-aws-credentials@v1
36+
with:
37+
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }}
38+
aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }}
39+
aws-region: ${{ secrets.AWS_REGION }}
40+
41+
- name: Configure AWS CLI profile
42+
run: |
43+
aws configure set aws_access_key_id ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} --profile prod
44+
aws configure set aws_secret_access_key ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} --profile prod
45+
46+
- name: Build and Push to AWS ECR
47+
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') || github.event.inputs.runPushAWS == 'yes'
48+
env:
49+
ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com
50+
ECR_REPO: hemera-protocol
51+
run: |
52+
echo "Architecture: ${{ env.ARCH }}"
53+
echo "Building and pushing to AWS ECR"
54+
55+
if [[ $GITHUB_REF == refs/tags/* ]]; then
56+
# It's a tag push, use the tag as is
57+
TAG=${GITHUB_REF#refs/tags/}
58+
# Remove 'v' prefix if present
59+
TAG=${TAG#v}
60+
else
61+
# Use the original naming convention
62+
VERSION=$(grep '^version = ' pyproject.toml | sed 's/^version = //;s/"//g')
63+
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then
64+
# It's a pull request
65+
BUILD=$(echo ${{ github.event.pull_request.head.sha }} | cut -c 1-7)
66+
else
67+
# It's a push to a branch (e.g., master)
68+
BUILD=$(git rev-parse --short=7 HEAD)
69+
fi
70+
TAG=$VERSION-$BUILD-${{ env.ARCH }}
71+
fi
72+
73+
echo "Tag: $TAG"
74+
75+
# Build the Docker image using make
76+
make image TAG=$TAG ARCH=${{ env.ARCH }}
77+
78+
# Login to ECR
79+
aws ecr get-login-password --region ${{ secrets.AWS_REGION }} --profile prod | docker login --username AWS --password-stdin $ECR_REGISTRY
80+
81+
# Tag the image for ECR
82+
docker tag $ECR_REPO:$TAG $ECR_REGISTRY/$ECR_REPO:$TAG
83+
84+
# Push the image to ECR
85+
docker push $ECR_REGISTRY/$ECR_REPO:$TAG

.github/workflows/ut.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
ETHEREUM_PUBLIC_NODE_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_RPC_URL }}'
3434
LINEA_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_DEBUG_RPC_URL }}'
3535
LINEA_PUBLIC_NODE_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_RPC_URL }}'
36+
MANTLE_PUBLIC_NODE_RPC_URL: '${{ secrets.MANTLE_PUBLIC_NODE_RPC_URL }}'
37+
MANTLE_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.MANTLE_PUBLIC_NODE_DEBUG_RPC_URL }}'
3638
run: |
3739
export PYTHONPATH=$(pwd)
38-
make test indexer
40+
make test indexer

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ resource/hemera.ini
5050
sync_record
5151
alembic.ini
5252
!indexer/modules/custom/hemera_ens/abi/*.json
53+
!indexer/modules/custom/cyber_id/abi/*.json

Makefile

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1-
VERSION := $(shell poetry version -s)
1+
ARCH=amd64
2+
VERSION := $(shell grep '^version = ' pyproject.toml | sed 's/^version = //;s/"//g')
23
BUILD := `git rev-parse --short=7 HEAD`
3-
SERVICES =
4-
.PHONY: all build image test
4+
5+
TAG := $(VERSION)-$(BUILD)-$(ARCH)
6+
7+
8+
PRE_COMMIT_INSTALLED := $(shell command -v pre-commit > /dev/null 2>&1 && echo yes || echo no)
9+
VENV_DIR := .venv
10+
POETRY_INSTALLED := $(shell command -v poetry > /dev/null 2>&1 && echo yes || echo no)
11+
12+
IMAGE_FLAGS := $(IMAGE_FLAGS) --platform linux/$(ARCH)
513

614
RED=\033[31m
715
GREEN=\033[32m
816
YELLOW=\033[33m
917
RESET=\033[0m
1018

11-
image:
1219

13-
docker build $(IMAGE_FLAGS) --network host -t hemera-protocol:$(VERSION)-$(BUILD) . --no-cache
14-
echo "Built image hemera-protocol:$(VERSION)-$(BUILD)"
20+
.PHONY: format init_db development image test
21+
22+
image:
23+
@echo "Build tag: $(TAG)"
24+
@echo "Build flags: $(IMAGE_FLAGS)"
25+
docker buildx build $(IMAGE_FLAGS) --network host -t hemera-protocol:$(TAG) . --no-cache
26+
@echo "Built image hemera-protocol:$(TAG)"
1527

1628
test:
1729
@if [ "$(filter-out $@,$(MAKECMDGOALS))" = "" ]; then \
@@ -21,8 +33,6 @@ test:
2133
fi
2234

2335

24-
PRE_COMMIT_INSTALLED := $(shell command -v pre-commit > /dev/null 2>&1 && echo yes || echo no)
25-
2636
format:
2737
ifeq ($(PRE_COMMIT_INSTALLED),yes)
2838
@echo "$(YELLOW)Formatting code...$(RESET)"
@@ -33,4 +43,46 @@ endif
3343

3444
init_db:
3545
@echo "Initializing database..."
36-
poetry run python -m hemera.py init_db
46+
poetry run python -m hemera.py init_db
47+
48+
development:
49+
@echo "Setting up development environment..."
50+
@bash -c 'set -euo pipefail; \
51+
PYTHON_CMD=$$(command -v python3 || command -v python); \
52+
if [ -z "$$PYTHON_CMD" ] || ! "$$PYTHON_CMD" --version 2>&1 | grep -q "Python 3"; then \
53+
echo "Python 3 is not found. Please install Python 3 and try again."; \
54+
exit 1; \
55+
fi; \
56+
python_version=$$($$PYTHON_CMD -c "import sys; print(\"{}.{}\".format(sys.version_info.major, sys.version_info.minor))"); \
57+
if ! echo "$$python_version" | grep -qE "^3\.(8|9|10|11)"; then \
58+
echo "Python version $$python_version is not supported. Please use Python 3.8, 3.9, 3.10, or 3.11."; \
59+
exit 1; \
60+
fi; \
61+
echo "Using Python: $$($$PYTHON_CMD --version)"; \
62+
if [ ! -d ".venv" ]; then \
63+
echo "Creating virtual environment..."; \
64+
$$PYTHON_CMD -m venv .venv || { \
65+
echo "Failed to create virtual environment. Installing venv..."; \
66+
sudo apt-get update && sudo apt-get install -y python3-venv && $$PYTHON_CMD -m venv .venv; \
67+
}; \
68+
fi; \
69+
echo "Activating virtual environment..."; \
70+
. .venv/bin/activate; \
71+
if ! pip --version &> /dev/null; then \
72+
echo "Installing pip..."; \
73+
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py; \
74+
$$PYTHON_CMD get-pip.py; \
75+
rm get-pip.py; \
76+
fi; \
77+
if ! poetry --version &> /dev/null; then \
78+
echo "Installing Poetry..."; \
79+
pip install poetry; \
80+
else \
81+
echo "Poetry is already installed."; \
82+
fi; \
83+
echo "Installing project dependencies..."; \
84+
poetry install -v; \
85+
echo "Development environment setup complete."; \
86+
echo ""; \
87+
echo "To activate the virtual environment, run:"; \
88+
echo "source .venv/bin/activate"'

0 commit comments

Comments
 (0)