Skip to content
Closed
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
4 changes: 0 additions & 4 deletions .isort.cfg

This file was deleted.

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
114 changes: 35 additions & 79 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,97 +1,53 @@
.PHONY: help requirements upgrade upgrade-package lint format 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 .ruff_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
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=
uv run pytest -rxefs --cov=openedx_webhooks --cov=tests --cov-report= --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
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
format: ## Auto-fix formatting and import order issues
uv run ruff check --fix .
uv run ruff format .

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
tox -e mypy

docs: ## Build documentation
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
Loading
Loading