Skip to content
Draft
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.

61 changes: 34 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,48 @@
name: Python CI
name: CI

on:
push:
branches:
- master
branches: [master]
pull_request:
branches:
- '**'
# Allow this workflow to be called from other workflows
workflow_call:

jobs:
run_tests:
name: Tests
runs-on: ${{ matrix.os }}
# matrix.job-name overrides the display name for specific entries; used to
# preserve "Tests (ubuntu-latest, 3.12)" which is a required branch-
# protection status check on the main branch and cannot be renamed there.
name: ${{ matrix.job-name || matrix.toxenv }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
python-version:
- "3.12"
python-version: ["3.12"]
toxenv: [lint, mypy, docs, py312-test]
include:
- toxenv: py312-test
job-name: "Tests (ubuntu-latest, 3.12)"

steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: setup python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
with:
python-version: ${{ matrix.python-version }}
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install dependencies
run: pip install -r requirements/test.txt
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
enable-cache: true
python-version: "${{ matrix.python-version }}"

- name: Run Tests
run: |
make test
cd docs && make html
- name: Install CI dependencies
run: uv sync --group ci

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

- name: Upload coverage to Codecov
if: matrix.toxenv == 'py312-test'
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests
fail_ci_if_error: true
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
113 changes: 34 additions & 79 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,97 +1,52 @@
.PHONY: help requirements upgrade upgrade-package lint pylint test mypy docs clean
.PHONY: deploy-configure deploy-check deploy-stage deploy-stage-branch deploy-prod

.DEFAULT_GOAL := help

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

clean: ## Clean cache, test, and build directories
-rm -rf .cache build dist *.egg-info .coverage htmlcov docs/_build prof
-rm -rf .cache build dist *.egg-info .coverage htmlcov docs/_build prof .pytest_cache

testschema: ## Install a schema under test.
# Get the version of repo-tools-data-schema that corresponds to our branch.
pip uninstall -y repo-tools-data-schema
pip install -U git+https://github.com/openedx/repo-tools-data-schema.git@$$(git rev-parse --abbrev-ref HEAD)
testschema: ## Install the repo-tools-data-schema version matching the current branch
uv pip install -U "repo-tools-data-schema @ git+https://github.com/openedx/repo-tools-data-schema.git@$$(git rev-parse --abbrev-ref HEAD)"

TEST_FLAGS = $(TEST_ARGS) -rxefs --cov=openedx_webhooks --cov=tests --cov-report=
test: ## Run tests
uv run tox -e py312-test

test: ## Run tests
pytest $(TEST_FLAGS) --cov-context=test
coverage html --show-contexts
coverage xml
fulltest: ## Run tests including flaky GitHub emulation
uv run pytest -rxefs --cov=openedx_webhooks --cov=tests --cov-report= --cov-config=pyproject.toml
uv run pytest -rxefs --cov=openedx_webhooks --cov=tests --cov-report= --cov-config=pyproject.toml --cov-append -m flaky_github --disable-warnings --percent-404=1 --count=100
uv run coverage html

fulltest: ## Run tests with randomness to emulate flaky GitHub
pytest $(TEST_FLAGS)
pytest $(TEST_FLAGS) --cov-append -m flaky_github --disable-warnings --percent-404=1 --count=100
coverage html

test-html-coverage-report: test ## Run tests and show coverage report in browser
test-html-coverage-report: test ## Run tests and open coverage report in browser
open htmlcov/index.html

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

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-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
lint: ## Run linting checks
uv run tox -e lint

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
pylint: ## Run pylint
-uv run pylint --rcfile=pylintrc src/openedx_webhooks tests

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
mypy: ## Run mypy type checks
uv run tox -e mypy

docs: ## Build documentation
uv run tox -e docs

upgrade: ## Upgrade and regenerate pinned 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; }
uv lock --upgrade-package $(package)

requirements: ## Sync dev dependencies
uv sync --group dev
uv tool install tox --with tox-uv

DEPLOY_PROD_APP=openedx-webhooks
DEPLOY_STAGING_APP=openedx-webhooks-staging
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Codecov configuration
# https://docs.codecov.com/docs/codecovyml-reference
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../src'))

# -- General configuration -----------------------------------------------------

Expand Down
21 changes: 17 additions & 4 deletions pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
# SERIOUSLY.
#
# ------------------------------
# Generated by edx-lint version: 5.3.4
# Generated by edx-lint version: 6.1.0
# ------------------------------
[MASTER]
ignore =
Expand Down Expand Up @@ -282,11 +282,24 @@ disable =
unspecified-encoding,
unused-wildcard-import,
use-maxsplit-arg,

feature-toggle-needs-doc,
illegal-waffle-usage,

logging-fstring-interpolation,
missing-module-docstring,
missing-class-docstring,
missing-function-docstring,
import-outside-toplevel,
cyclic-import,
broad-exception-caught,
logging-format-interpolation,
too-many-positional-arguments,
no-else-continue,
use-yield-from,
too-many-statements,
protected-access,
raise-missing-from,
consider-using-in,
use-implicit-booleaness-not-comparison,

[REPORTS]
output-format = text
Expand Down Expand Up @@ -383,4 +396,4 @@ int-import-graph =
[EXCEPTIONS]
overgeneral-exceptions = builtins.Exception

# f9fb9a3189dea137f974048ba886a47f1211eb65
# 62e011bfb4e7b1a8b42018cb1e878316aa5d8e08
58 changes: 58 additions & 0 deletions pylintrc_tweaks
Original file line number Diff line number Diff line change
@@ -1,2 +1,60 @@
[MASTER]
load-plugins = edx_lint.pylint,pylint_celery,pylint_pytest

[MESSAGES CONTROL]
disable =
# Preserved from original edx-lint 5.3.4 base config
bad-indentation,
broad-exception-raised,
consider-using-f-string,
duplicate-code,
file-ignored,
fixme,
global-statement,
invalid-name,
locally-disabled,
no-else-return,
suppressed-message,
too-few-public-methods,
too-many-ancestors,
too-many-arguments,
too-many-branches,
too-many-instance-attributes,
too-many-lines,
too-many-locals,
too-many-public-methods,
too-many-return-statements,
ungrouped-imports,
unspecified-encoding,
unused-wildcard-import,
use-maxsplit-arg,
feature-toggle-needs-doc,
illegal-waffle-usage,
logging-fstring-interpolation,
# Pre-existing: many modules and functions lack docstrings
missing-module-docstring,
missing-class-docstring,
missing-function-docstring,
# Pre-existing: intentional import patterns (circular-avoiding lazy imports)
import-outside-toplevel,
cyclic-import,
# Pre-existing: broad-exception-caught is the pylint 4.x rename of broad-except
broad-exception-caught,
# Pre-existing: logging .format() usage throughout codebase
logging-format-interpolation,
# Pre-existing: functions with >5 positional args (new rule in pylint 3.3+)
too-many-positional-arguments,
# Pre-existing: else-after-continue style (new rule)
no-else-continue,
# Pre-existing: yield-from style (new rule)
use-yield-from,
# Pre-existing: too many statements in a single function
too-many-statements,
# Pre-existing: test helpers access private members
protected-access,
# Pre-existing: raise without chaining in test helpers
raise-missing-from,
# Pre-existing: comparison style in tests
consider-using-in,
# Pre-existing: implicit boolean comparison style (new rule)
use-implicit-booleaness-not-comparison,
Loading
Loading