Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ RUN mkdir -p $BIN_DIR \
&& mkdir -p $DATA_DIR/logs

COPY entrypoint.sh pyproject.toml uv.lock README.md $APP_DIR/
COPY webhook_server_container $APP_DIR/webhook_server_container/
COPY webhook_server $APP_DIR/webhook_server/

RUN usermod --add-subuids 100000-165535 --add-subgids 100000-165535 $USERNAME \
&& chown -R $USERNAME:$USERNAME $HOME_DIR
Expand Down
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

SERVER_RUN_CMD="uv run uvicorn webhook_server_container.app:FASTAPI_APP --host 0.0.0.0 --port 5000 "
SERVER_RUN_CMD="uv run uvicorn webhook_server.app:FASTAPI_APP --host 0.0.0.0 --port 5000 "
UVICORN_WORKERS="${UVICORN_MAX_WORKERS:=10}"

set -ep

uv run webhook_server_container/utils/github_repository_and_webhook_settings.py
uv run webhook_server/utils/github_repository_and_webhook_settings.py

if [[ -z $DEVELOPMENT ]]; then
eval "${SERVER_RUN_CMD} --workers ${UVICORN_WORKERS}"
Expand Down
2 changes: 1 addition & 1 deletion example.config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/myk-org/github-webhook-server/refs/heads/main/webhook_server_container/config/schema.yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/myk-org/github-webhook-server/refs/heads/main/webhook_server/config/schema.yaml

log-level: INFO # Set global log level, change take effect immediately without server restart
log-file: webhook-server.log # Set global log file, change take effect immediately without server restart
Expand Down
36 changes: 18 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.coverage.run]
omit = [ "tests/*" ]
omit = ["tests/*"]

[tool.coverage.report]
fail_under = 35
Expand All @@ -14,8 +14,8 @@ line-length = 120
fix = true
output-format = "grouped"

[tool.ruff.format]
exclude = [ ".git", ".venv", ".mypy_cache", ".tox", "__pycache__" ]
[tool.ruff.format]
exclude = [".git", ".venv", ".mypy_cache", ".tox", "__pycache__"]

[tool.mypy]
check_untyped_defs = true
Expand All @@ -31,10 +31,10 @@ warn_unused_configs = true
warn_redundant_casts = true

[tool.hatch.build.targets.wheel]
packages = [ "webhook_server_container" ]
packages = ["webhook_server"]

[tool.uv]
dev-dependencies = [ "ipdb>=0.13.13", "ipython>=8.12.3" ]
dev-dependencies = ["ipdb>=0.13.13", "ipython>=8.12.3"]

[project]
name = "github-webhook-server"
Expand All @@ -45,7 +45,7 @@ readme = "README.md"
license = "Apache-2.0"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent"
"Operating System :: OS Independent",
]
dependencies = [
"build>=1.2.2.post1",
Expand All @@ -68,20 +68,20 @@ dependencies = [
"uwsgi>=2.0.27",
]

[[project.authors]]
name = "Meni Yakove"
email = " myakove@gmail.com"
[[project.authors]]
name = "Meni Yakove"
email = " myakove@gmail.com"

[[project.authors]]
name = "Ruth Netser"
email = "ruth.netser@gmail.com"
[[project.authors]]
name = "Ruth Netser"
email = "ruth.netser@gmail.com"

[project.urls]
homepage = "https://github.com/myakove/github-webhook-server"
repository = "https://github.com/myakove/github-webhook-server"
Download = "https://quay.io/repository/myakove/github-webhook-server"
"Bug Tracker" = "https://github.com/myakove/github-webhook-server/issues"
[project.urls]
homepage = "https://github.com/myakove/github-webhook-server"
repository = "https://github.com/myakove/github-webhook-server"
Download = "https://quay.io/repository/myakove/github-webhook-server"
"Bug Tracker" = "https://github.com/myakove/github-webhook-server/issues"

[build-system]
requires = [ "hatchling" ]
requires = ["hatchling"]
build-backend = "hatchling.build"
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
addopts =
--pdbcls=IPython.terminal.debugger:TerminalPdb
--cov-config=pyproject.toml --cov-report=html --cov-report=term --cov=webhook_server_container
--cov-config=pyproject.toml --cov-report=html --cov-report=term --cov=webhook_server
--log-cli-level=DEBUG
2 changes: 1 addition & 1 deletion tox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ commands = [

[env.unittests]
deps = ["uv"]
commands = [["uv", "run", "pytest", "webhook_server_container/tests"]]
commands = [["uv", "run", "pytest", "webhook_server/tests"]]
File renamed without changes.
4 changes: 2 additions & 2 deletions webhook_server_container/app.py → webhook_server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import urllib3
from fastapi import FastAPI, Request

from webhook_server_container.libs.github_api import ProcessGithubWehook
from webhook_server_container.utils.helpers import get_logger_with_params
from webhook_server.libs.github_api import ProcessGithubWehook
from webhook_server.utils.helpers import get_logger_with_params

FASTAPI_APP: FastAPI = FastAPI(title="webhook-server")
APP_URL_ROOT_PATH: str = "/webhook_server"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_value(self, value: str, return_on_none: Any = None) -> Any:
@property
def repository_local_data(self) -> dict[str, Any]:
if self.repository and self.repository_full_name:
from webhook_server_container.utils.helpers import get_api_with_highest_rate_limit, get_github_repo_api
from webhook_server.utils.helpers import get_api_with_highest_rate_limit, get_github_repo_api

github_api, _, _ = get_api_with_highest_rate_limit(config=self, repository_name=self.repository)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
from stringcolor import cs
from timeout_sampler import TimeoutExpiredError, TimeoutSampler

from webhook_server_container.libs.config import Config
from webhook_server_container.utils.constants import (
from webhook_server.libs.config import Config
from webhook_server.utils.constants import (
ADD_STR,
APPROVE_STR,
APPROVED_BY_LABEL_PREFIX,
Expand Down Expand Up @@ -68,10 +68,10 @@
VERIFIED_LABEL_STR,
WIP_STR,
)
from webhook_server_container.utils.github_repository_settings import (
from webhook_server.utils.github_repository_settings import (
get_repository_github_app_api,
)
from webhook_server_container.utils.helpers import (
from webhook_server.utils.helpers import (
extract_key_from_dict,
get_api_with_highest_rate_limit,
get_apis_and_tokes_from_config,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from starlette.datastructures import Headers

import pytest
from webhook_server_container.libs.github_api import ProcessGithubWehook
from webhook_server.libs.github_api import ProcessGithubWehook

ALL_CHANGED_FILES = [
"OWNERS",
Expand Down Expand Up @@ -96,8 +96,8 @@ def get_contents(self, path: str):

@pytest.fixture(scope="function")
def process_github_webhook(mocker, request):
base_import_path = "webhook_server_container.libs.github_api"
os.environ["WEBHOOK_SERVER_DATA_DIR"] = "webhook_server_container/tests/manifests"
base_import_path = "webhook_server.libs.github_api"
os.environ["WEBHOOK_SERVER_DATA_DIR"] = "webhook_server/tests/manifests"

mocker.patch(f"{base_import_path}.get_repository_github_app_api", return_value=True)
mocker.patch("github.AuthenticatedUser", return_value=True)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import os

import pytest
from webhook_server_container.libs.config import Config
from webhook_server_container.utils.github_repository_settings import (
from webhook_server.libs.config import Config
from webhook_server.utils.github_repository_settings import (
DEFAULT_BRANCH_PROTECTION,
get_repo_branch_protection_rules,
)


@pytest.fixture()
def branch_protection_rules(request, mocker):
config_path = "webhook_server_container.libs.config.Config"
os.environ["WEBHOOK_SERVER_DATA_DIR"] = "webhook_server_container/tests/manifests"
config_path = "webhook_server.libs.config.Config"
os.environ["WEBHOOK_SERVER_DATA_DIR"] = "webhook_server/tests/manifests"
repo_name = "test-repo"
config = Config(repository=repo_name)
root_data = config.root_data
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import yaml

import pytest
from webhook_server_container.tests.conftest import ContentFile, Tree
from webhook_server_container.utils.constants import APPROVED_BY_LABEL_PREFIX
from webhook_server.tests.conftest import ContentFile, Tree
from webhook_server.utils.constants import APPROVED_BY_LABEL_PREFIX


class Repository:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest

from webhook_server_container.utils.constants import SIZE_LABEL_PREFIX
from webhook_server.utils.constants import SIZE_LABEL_PREFIX


class Label:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

import github

from webhook_server_container.libs.config import Config
from webhook_server_container.utils.github_repository_settings import (
from webhook_server.libs.config import Config
from webhook_server.utils.github_repository_settings import (
set_all_in_progress_check_runs_to_queued,
set_repositories_settings,
)
from webhook_server_container.utils.helpers import get_api_with_highest_rate_limit, get_logger_with_params
from webhook_server_container.utils.webhook import create_webhook
from webhook_server.utils.helpers import get_api_with_highest_rate_limit, get_logger_with_params
from webhook_server.utils.webhook import create_webhook


def get_repository_api(repository: str) -> tuple[str, github.Github | None, str]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from github.Label import Label
from github.Repository import Repository

from webhook_server_container.libs.config import Config
from webhook_server_container.utils.constants import (
from webhook_server.libs.config import Config
from webhook_server.utils.constants import (
BUILD_CONTAINER_STR,
CAN_BE_MERGED_STR,
CONVENTIONAL_TITLE_STR,
Expand All @@ -26,7 +26,7 @@
STATIC_LABELS_DICT,
TOX_STR,
)
from webhook_server_container.utils.helpers import (
from webhook_server.utils.helpers import (
get_future_results,
get_logger_with_params,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from github.Repository import Repository
from simple_logger.logger import get_logger

from webhook_server_container.libs.config import Config
from webhook_server.libs.config import Config


def get_logger_with_params(name: str, repository_name: str = "") -> Logger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from github.Hook import Hook

from webhook_server_container.libs.config import Config
from webhook_server_container.utils.helpers import (
from webhook_server.libs.config import Config
from webhook_server.utils.helpers import (
get_future_results,
get_github_repo_api,
get_logger_with_params,
Expand Down