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
3 changes: 0 additions & 3 deletions .coveragerc

This file was deleted.

45 changes: 34 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,50 @@ jobs:
strategy:
matrix:
os:
- ubuntu-latest
- ubuntu-latest
python-version:
- "3.12"
- "3.12"

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: setup python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0

- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
python-version: "${{ matrix.python-version }}"

- name: Install dependencies
run: pip install -r requirements/test.txt
- name: Install CI dependencies
run: uv sync --group ci

- name: Run Tests
run: |
make test
cd docs && make html
- name: Run tox
run: uv run tox -e py

- name: Run Coverage
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true

quality_and_docs:
name: ${{ matrix.toxenv }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
toxenv: [quality, docs]

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
enable-cache: true
python-version: "${{ matrix.python-version }}"

- name: Install CI dependencies
run: uv sync --group ci

- name: Run tox
run: uv run tox -e ${{ matrix.toxenv }}
5 changes: 4 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ build:

python:
install:
- requirements: requirements/dev.txt
- method: uv
command: sync
groups:
- doc
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ RUN apt-get install -qy \
RUN apt update -qy
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata

RUN pip install tox
RUN pip install uv

RUN mkdir -p /edx/app/openedx-webhooks
WORKDIR /edx/app/openedx-webhooks
COPY Makefile ./
COPY requirements ./requirements
COPY Makefile pyproject.toml uv.lock ./
RUN make install-dev-requirements

COPY . /edx/app/openedx-webhooks
Expand Down
10 changes: 10 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Exclude development, test, and documentation folders
prune .github
prune docs
prune tests

# Exclude root level configuration and build files
exclude Makefile
exclude conftest.py
exclude .gitignore
exclude tox.ini
61 changes: 8 additions & 53 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ help: ## Display this help message
@echo "Please use \`make <target>' where <target> is one of the following:"
@awk -F ':.*?## ' '/^[a-zA-Z]/ && NF==2 {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

check-setup.py: ## Check setup
python setup.py check -r -s
check-pyproject.toml: ## Check setup
uv run python -c "import tomllib; tomllib.load(open('pyproject.toml', 'rb')); print('pyproject.toml is valid and parsed successfully')"

clean: ## Clean cache, test, and build directories
-rm -rf .cache build dist *.egg-info .coverage htmlcov docs/_build prof
Expand All @@ -31,67 +31,22 @@ test-html-coverage-report: test ## Run tests and show coverage report in browser
open htmlcov/index.html

pylint: ## Run pylint
-pylint --rcfile=pylintrc openedx_webhooks tests setup.py
-pylint --rcfile=pylintrc openedx_webhooks tests

TYPEABLE = openedx_webhooks tests
mypy: ## Run mypy to check type annotations
-mypy $(TYPEABLE)

PIP_COMPILE = pip-compile --allow-unsafe --resolver=backtracking ${COMPILE_OPTS}
compile-requirements: export CUSTOM_COMPILE_COMMAND=make upgrade
compile-requirements: ## Update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -qr requirements/pip-tools.txt
# Make sure to compile files after any other files they include!
$(PIP_COMPILE) --rebuild -o requirements/pip.txt requirements/pip.in
$(PIP_COMPILE) -o requirements/pip-tools.txt requirements/pip-tools.in
pip install -qr requirements/pip.txt
pip install -qr requirements/pip-tools.txt
$(PIP_COMPILE) -o requirements/base.txt requirements/base.in
$(PIP_COMPILE) -o requirements/test.txt requirements/test.in
$(PIP_COMPILE) -o requirements/dev.txt requirements/dev.in
$(PIP_COMPILE) -o requirements/doc.txt requirements/doc.in

upgrade: ## Update the requirements/*.txt files with the latest packages satisfying requirements/*.in
$(MAKE) compile-requirements COMPILE_OPTS="--upgrade"
upgrade: ## update python dependencies
uv run --with edx-lint edx_lint write_uv_constraints pyproject.toml
uv lock --upgrade

upgrade-package: ## Update just one package to the latest usable release
@test -n "$(package)" || { echo "\nUsage: make upgrade-package package=...\n"; exit 1; }
$(MAKE) compile-requirements COMPILE_OPTS="--upgrade-package $(package)"

PRIVATE_IN = requirements/private.in
PRIVATE_OUT = requirements/private.txt

pip-compile: ## Compile Python requirements without upgrading
pip install --no-cache-dir -q pip-tools
pip-compile requirements/base.in
pip-compile requirements/dev.in
pip-compile requirements/doc.in
pip-compile requirements/test.in
ifneq (, $(wildcard $(PRIVATE_IN)))
pip-compile $(PRIVATE_IN)
else
endif

pip-compile-upgrade: ## Compile and upgrade Python requirements
pip install --no-cache-dir -q pip-tools
pip-compile -U requirements/base.in
pip-compile -U requirements/dev.in
pip-compile -U requirements/doc.in
pip-compile -U requirements/test.in
ifneq (, $(wildcard $(PRIVATE_IN)))
pip-compile -U $(PRIVATE_IN)
endif
uv lock --upgrade-package $(package)

install-dev-requirements: ## Install development requirements
pip install --no-cache-dir -q pip-tools
ifneq (, $(wildcard $(PRIVATE_OUT)))
pip-sync $(PRIVATE_OUT)
else
pip-sync requirements/dev.txt
endif
@# This run of mypy is to discover the missing type stubs, then we install them
-mypy $(TYPEABLE) > /dev/null
mypy --install-types --non-interactive
uv sync --group dev

DEPLOY_PROD_APP=openedx-webhooks
DEPLOY_STAGING_APP=openedx-webhooks-staging
Expand Down
6 changes: 5 additions & 1 deletion openedx_webhooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import sys
import traceback
from importlib.metadata import PackageNotFoundError, version

from celery import Celery
from flask import Flask
Expand All @@ -12,7 +13,10 @@
from werkzeug.middleware.proxy_fix import ProxyFix
from werkzeug.utils import import_string

__version__ = "0.1.0"
try:
__version__ = version("openedx_webhooks")
except PackageNotFoundError: # pragma: no cover
__version__ = "unknown"

log_level = os.environ.get('LOGLEVEL', 'INFO').upper()
logger = logging.getLogger(__name__)
Expand Down
150 changes: 150 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "openedx_webhooks"
version = "0.1.0"
description = "Automated tasks for Open edX"
requires-python = ">=3.12"
license = "Apache-2.0"
license-files = ["LICENSE*"]
authors = [
{name = "Open edX Project", email = "oscm@openedx.org"},
]
classifiers = [
"Development Status :: 3 - Alpha",
"Framework :: Flask",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
]
keywords = [
"Python",
"edx",
]

readme = "README.rst"

dependencies = [
"Flask",
"celery[redis]",
"github3.py",
"Flask-SSLify",
"PyYAML",
"URLObject",
"arrow",
"blinker",
"cachetools",
"click",
"cryptography",
"glom",
"gunicorn",
"jira",
"logging_tree",
"oauthlib[signedtoken]",
"redis",
"requests",
"requests-oauthlib",
"sentry-sdk[flask]",
]

[project.urls]
Homepage = "https://github.com/openedx/openedx-webhooks"
Repository = "https://github.com/openedx/openedx-webhooks"

[dependency-groups]
test = [
"freezegun",
"pytest",
"pytest-cov",
"pytest-mock",
"pytest-repeat",
"pytz",
"requests-mock",
"repo-tools-data-schema @ git+https://github.com/openedx/repo-tools-data-schema.git",
]
doc = [
"Sphinx",
"readme_renderer",
"sphinx_rtd_theme",
"sphinxcontrib-httpdomain",
]
quality = [
{include-group = "test"},
"edx-lint",
"mypy",
"pylint-pytest",
"types-PyYAML",
"types-cachetools",
"types-requests",
]
ci = [
"tox",
"tox-uv",
]
dev = [
{include-group = "test"},
{include-group = "ci"},
"edx-lint",
"mypy",
"pylint-pytest",
"python-dotenv",
"scriv",
"types-PyYAML",
"types-cachetools",
"types-requests",
]

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
exclude = ["tests*", "*.tests", "*.tests.*"]

[tool.setuptools.package-data]
"*" = [
"*.html",
"*.j2",
]

[tool.uv]
package = true
# DO NOT EDIT constraint-dependencies DIRECTLY.
# This list is managed by `edx_lint write_uv_constraints`
# and will be overwritten the next time `make upgrade` is run.
# - GLOBAL constraints: edit edx_lint/files/common_constraints.txt
# - REPO-SPECIFIC constraints: edit [tool.edx_lint].uv_constraints in this file
constraint-dependencies = [
"Django<6.0",
"elasticsearch<7.14.0",
]

[tool.edx_lint]
# Repo-specific uv constraints merged with edx-lint's global constraints.
# Local entries override global ones for the same package.
# Run `make upgrade` to regenerate [tool.uv].constraint-dependencies.
uv_constraints = []

[tool.coverage.run]
source = ["openedx_webhooks"]
branch = true

[tool.mypy]
ignore_missing_imports = true
check_untyped_defs = true

[tool.pytest.ini_options]
markers = [
"flaky_github: tests to run with flaky GitHub behavior emulated",
]
filterwarnings = [
"ignore:SelectableGroups dict interface is deprecated. Use select.:DeprecationWarning",
]

[tool.scriv]
output_file = "README.rst"
rst_header_chars = "~."
categories = ""
version = ""
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

25 changes: 0 additions & 25 deletions requirements/base.in

This file was deleted.

Loading