Skip to content

Commit

Permalink
Merge branch 'main' into price-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedmamdouh22 committed Nov 5, 2024
2 parents 361fed6 + 862193b commit 7a7f5bc
Show file tree
Hide file tree
Showing 115 changed files with 4,940 additions and 2,870 deletions.
1 change: 0 additions & 1 deletion .dockerignore

This file was deleted.

99 changes: 64 additions & 35 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ jobs:
- name: Check if current version is published
id: pre-val
run: |
LOCAL_VERSION=$(grep '^version =' pyproject.toml | head -1 | awk -F '"' '{print $2}')
REMOTE_VERSION=$(curl -s https://pypi.org/pypi/tarsier/json | jq -r .info.version)
LOCAL_CORE_VERSION=$(grep '^version =' core/pyproject.toml | head -1 | awk -F '"' '{print $2}')
LOCAL_SDK_VERSION=$(grep '^version =' sdk/pyproject.toml | head -1 | awk -F '"' '{print $2}')
REMOTE_VERSION=$(curl -s https://pypi.org/pypi/harambe/json | jq -r .info.version)
echo "Local version: $LOCAL_VERSION"
echo "Local core version: $LOCAL_CORE_VERSION"
echo "Local SDK version: $LOCAL_SDK_VERSION"
echo "Remote version: $REMOTE_VERSION"
if [ $LOCAL_CORE_VERSION != $LOCAL_SDK_VERSION ]; then
echo "Core and SDK versions do not match"
exit 1
fi
if [ "$LOCAL_VERSION" != "$REMOTE_VERSION" ]; then
if [ "$LOCAL_SDK_VERSION" != "$REMOTE_VERSION" ]; then
echo "Version $LOCAL_VERSION is not published yet"
echo "::set-output name=should_publish::true"
fi
Expand All @@ -33,46 +40,68 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'
- run: make RESOLVE_DEPS
- name: Check code formatting
run: make FORMAT_CHECK
- name: Run linter
run: make LINT_CHECK
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Run ruff check
run: uvx ruff format --check .

pytest:
pytest-core:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'poetry'
- run: make RESOLVE_DEPS
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Run pytest
run: make TEST
working-directory: core
run: uv run pytest -vv --cov="${{ inputs.package }}" .

pytest-sdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Install playwright
working-directory: sdk
run: uv run playwright install chromium firefox webkit --with-deps
- name: Run pytest
working-directory: sdk
run: uv run pytest -vv --cov="${{ inputs.package }}" .

publish-core:
needs: [ check-version, format, pytest-core, pytest-sdk ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && needs.check-version.outputs.should_publish == 'true'
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Build and Publish
working-directory: core
run: |
uv build
uv publish --token ${{ secrets.PYPI_TOKEN_CORE }}
publish:
needs: [ check-version, format, pytest ]
publish-sdk:
needs: [ check-version, format, pytest-core, pytest-sdk ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && needs.check-version.outputs.should_publish == 'true'
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "poetry"
- run: make RESOLVE_DEPS
- name: Install uv
uses: astral-sh/setup-uv@v2
- name: Set up Python
run: uv python install ${{ env.PYTHON_VERSION }}
- name: Build and Publish
working-directory: sdk
run: |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
poetry publish --build
uv build
uv publish --token ${{ secrets.PYPI_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,5 @@ cython_debug/
*.bin
/screenshots/
/data/
*.venv
*.DS_Store
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
16 changes: 0 additions & 16 deletions Dockerfile

This file was deleted.

69 changes: 0 additions & 69 deletions Makefile

This file was deleted.

11 changes: 0 additions & 11 deletions Prebuild.mk

This file was deleted.

11 changes: 11 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cd "$(dirname "$0")" || exit 1

cd core || exit 1
uv run ruff format .
uv run pytest . || exit 1
cd - || exit 1

cd sdk || exit 1
uv run ruff format .
uv run pytest . || exit 1
cd - || exit 1
1 change: 1 addition & 0 deletions core/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
File renamed without changes.
8 changes: 8 additions & 0 deletions core/harambe_core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from .types import Schema
from .parser import SchemaParser


__all__ = [
"Schema",
"SchemaParser",
]
14 changes: 14 additions & 0 deletions core/harambe_core/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class HarambeException(Exception):
"""Base exception for all custom exceptions in Harambe."""

pass


class SchemaValidationError(HarambeException):
def __init__(self, message: str = None):
super().__init__(message)


class CaptchaError(HarambeException):
def __init__(self, message: str = "CAPTCHA was hit.") -> None:
super().__init__(message)
File renamed without changes.
5 changes: 5 additions & 0 deletions core/harambe_core/parser/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .parser import SchemaParser

__all__ = [
"SchemaParser",
]
4 changes: 4 additions & 0 deletions core/harambe_core/parser/expression/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .evaluator import ExpressionEvaluator
from . import functions # noqa

__all__ = ["ExpressionEvaluator"]
Loading

0 comments on commit 7a7f5bc

Please sign in to comment.