Skip to content

Commit

Permalink
Merge pull request HemeraProtocol#174 from HemeraProtocol/pre-release…
Browse files Browse the repository at this point in the history
…/v0.3.0

Release/v0.3.0
  • Loading branch information
shanshuo0918 authored Sep 29, 2024
2 parents 3d9489f + edf77d6 commit 9ba1ed2
Show file tree
Hide file tree
Showing 277 changed files with 35,640 additions and 1,711 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Hemera Indexer Continuous Integration

on: [pull_request]

jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: hemera
POSTGRES_PASSWORD: password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
env:
ETHEREUM_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_DEBUG_RPC_URL }}'
ETHEREUM_PUBLIC_NODE_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_RPC_URL }}'
LINEA_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_DEBUG_RPC_URL }}'
LINEA_PUBLIC_NODE_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_RPC_URL }}'
POSTGRES_USER: hemera
POSTGRES_PASSWORD: password
POSTGRES_URL: postgresql://hemera:password@localhost:5432/hemera
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'

- name: Install dependencies
run: |
pip install --upgrade pip
pip install poetry
poetry update
poetry install -v
poetry show
- name: Set PYTHONPATH
run: echo "PYTHONPATH=\$PYTHONPATH:$(pwd)" >> $GITHUB_ENV

- name: Verify PYTHONPATH
run: echo $PYTHONPATH

- name: Init database
run: |
export PYTHONPATH=$(pwd)
make init_db
- name: Pipeline Test with pytest
run: |
export PYTHONPATH=$(pwd)
make test indexer
31 changes: 0 additions & 31 deletions .github/workflows/test.yaml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/workflows/ut.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Python application unit test

on: [pull_request]

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'

- name: Install dependencies
run: |
pip install --upgrade pip
pip install poetry
poetry update
poetry install -v
- name: Set PYTHONPATH
run: echo "PYTHONPATH=\$PYTHONPATH:$(pwd)" >> $GITHUB_ENV

- name: Verify PYTHONPATH
run: echo $PYTHONPATH

- name: Unit Test with pytest
env:
ETHEREUM_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_DEBUG_RPC_URL }}'
ETHEREUM_PUBLIC_NODE_RPC_URL: '${{ secrets.ETHEREUM_PUBLIC_NODE_RPC_URL }}'
LINEA_PUBLIC_NODE_DEBUG_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_DEBUG_RPC_URL }}'
LINEA_PUBLIC_NODE_RPC_URL: '${{ secrets.LINEA_PUBLIC_NODE_RPC_URL }}'
run: |
export PYTHONPATH=$(pwd)
make test indexer
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ docker-compose/postgres/
resource/hemera.ini
sync_record
alembic.ini
!indexer/modules/custom/hemera_ens/abi/*.json
22 changes: 15 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
FROM python:3.9-slim
FROM python:3.9-slim AS builder

ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1

WORKDIR /app
RUN pip install poetry && poetry config virtualenvs.in-project true

WORKDIR "/app"
COPY . .

RUN pip install --no-cache-dir build && \
python -m build && \
pip install dist/*.whl && \
rm dist/*.whl
RUN poetry install
RUN poetry build

FROM python:3.9-slim

WORKDIR "/app"

ENV PYTHONPATH=/app:$PYTHONPATH
COPY --from=builder /app/migrations ./migrations
COPY --from=builder /app/dist/*.whl .
RUN pip install *.whl

ENTRYPOINT ["hemera"]
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION := $(shell cat VERSION)
VERSION := $(shell poetry version -s)
BUILD := `git rev-parse --short=7 HEAD`
SERVICES =
.PHONY: all build image test
Expand All @@ -10,15 +10,17 @@ RESET=\033[0m

image:

docker build $(IMAGE_FLAGS) --network host -t hemera-protocol:$(VERSION)-$(BUILD) . -q
docker build $(IMAGE_FLAGS) --network host -t hemera-protocol:$(VERSION)-$(BUILD) . --no-cache
echo "Built image hemera-protocol:$(VERSION)-$(BUILD)"

test:
@if [ "$(filter-out $@,$(MAKECMDGOALS))" = "" ]; then \
pytest -vv; \
poetry run pytest -vv; \
else \
pytest -vv -m $(filter-out $@,$(MAKECMDGOALS)); \
poetry run pytest -vv -m $(filter-out $@,$(MAKECMDGOALS)); \
fi


PRE_COMMIT_INSTALLED := $(shell command -v pre-commit > /dev/null 2>&1 && echo yes || echo no)

format:
Expand All @@ -27,4 +29,8 @@ ifeq ($(PRE_COMMIT_INSTALLED),yes)
@pre-commit run --all-files
else
@echo "Please install pre-commit in your local machine(pip install pre-commit or brew install pre-commit)"
endif
endif

init_db:
@echo "Initializing database..."
poetry run python -m hemera.py init_db
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

5 changes: 3 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path

VERSION_FILE = Path(__file__).parent / "VERSION"
__version__ = VERSION_FILE.read_text().strip()
import tomli

__version__ = "0.3.0"
7 changes: 7 additions & 0 deletions api/app/address/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from flask_restx.namespace import Namespace

address_features_namespace = Namespace(
"Address Features",
path="/",
description="Address Features API",
)
43 changes: 43 additions & 0 deletions api/app/address/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from sqlalchemy import Column, Integer, PrimaryKeyConstraint, func
from sqlalchemy.dialects.postgresql import BOOLEAN, BYTEA, INTEGER, NUMERIC, TEXT, TIMESTAMP

from common.models import HemeraModel


class AddressBaseProfile(HemeraModel):
__tablename__ = "af_base_profile"

address = Column(BYTEA, primary_key=True, nullable=False)
init_funding_from_address = Column(BYTEA)
init_funding_value = Column(NUMERIC)
init_funding_transaction_hash = Column(BYTEA)
init_funding_block_timestamp = Column(TIMESTAMP)
init_block_hash = Column(BYTEA)
init_block_number = Column(INTEGER)
creation_code = Column(BYTEA)
deployed_code = Column(BYTEA)
deployed_block_timestamp = Column(TIMESTAMP)
deployed_block_number = Column(INTEGER)
deployed_block_hash = Column(BYTEA)
deployed_transaction_hash = Column(BYTEA)
deployed_internal_transaction_from_address = Column(BYTEA)
deployed_transaction_from_address = Column(BYTEA)
deployed_trace_id = Column(TEXT)
is_contract = Column(BOOLEAN)
first_transaction_hash = Column(BYTEA)
first_block_hash = Column(BYTEA)
first_block_number = Column(INTEGER)
first_block_timestamp = Column(TIMESTAMP)
first_trace_id = Column(TEXT)
first_is_from_address = Column(BOOLEAN)
first_trace_type = Column(TEXT)
first_call_type = Column(TEXT)


class ScheduledMetadata(HemeraModel):
__tablename__ = "af_base_na_scheduled_metadata"

id = Column(Integer, primary_key=True)
dag_id = Column(TEXT)
execution_date = Column(TIMESTAMP)
last_data_timestamp = Column(TIMESTAMP)
Loading

0 comments on commit 9ba1ed2

Please sign in to comment.