Compare commits

..

1 Commits

Author SHA1 Message Date
Muhammad Faraz Maqsood
7f2b681cb5 chore: remove Python 3.8 references
- drop support for python 3.8 and set Python 3.9 as the minimum supported python version.
2024-11-12 12:25:44 +05:00
19 changed files with 109 additions and 198 deletions

View File

@ -1,12 +1,9 @@
name: Auto Add Issues and Pull Requests to Project
name: Auto Add Issues to Project
on:
issues:
types:
- opened
pull_request_target:
types:
- opened
jobs:
# https://github.com/actions/add-to-project

View File

@ -2,7 +2,7 @@ name: Sync with private repo
on:
push:
branches: [ release, main ]
branches: [ master, main, nightly ]
jobs:
sync:

View File

@ -2,9 +2,7 @@ name: Run tests
on:
pull_request:
branches: [ release, main ]
push:
branches: [ release, main ]
branches: [master]
jobs:
tests:
@ -18,6 +16,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools
- name: Install dependencies
run: |
pip install .[dev]

View File

@ -1,22 +0,0 @@
# https://hatch.pypa.io/latest/how-to/config/dynamic-metadata/
import os
import typing as t
from hatchling.metadata.plugin.interface import MetadataHookInterface
HERE = os.path.dirname(__file__)
class MetaDataHook(MetadataHookInterface):
def update(self, metadata: dict[str, t.Any]) -> None:
about = load_about()
metadata["version"] = about["__version__"]
def load_about() -> dict[str, str]:
about: dict[str, str] = {}
with open(
os.path.join(HERE, "tutorcredentials", "__about__.py"), "rt", encoding="utf-8"
) as f:
exec(f.read(), about)
return about

View File

@ -19,31 +19,6 @@ instructions, because git commits are used to generate release notes:
<!-- scriv-insert-here -->
<a id='changelog-20.0.0'></a>
## v20.0.0 (2025-06-05)
- [Improvement] Migrate packaging from setup.py/setuptools to pyproject.toml/hatch. (by @mlabeeb03)
- For more details view tutor core PR: https://github.com/overhangio/tutor/pull/1163
- [Improvement] Add hatch_build.py in sdist target to fix the installation issues (by @dawoudsheraz)
- 💥[Feature] Upgrade to Teak. (by @mlabeeb03)
<a id='changelog-19.0.0'></a>
## v19.0.0 (2024-10-23)
- 💥 [Deprecation] Drop support for python 3.8 and set Python 3.9 as the minimum supported python version. (by @Faraz32123)
- 💥[Improvement] Rename Tutor's two branches (by @DawoudSheraz):
* Rename **master** to **release**, as this branch runs the latest official Open edX release tag.
* Rename **nightly** to **main**, as this branch runs the Open edX master branches, which are the basis for the next Open edX release.
- 💥[Feature] Upgrade to Sumac. (by @Faraz32123)
- [BugFix] Uwsgi workers wasn't starting properly using `UWSGI_WORKERS` flag, passing the value directly fixes the issue. (by @Faraz32123)
- 💥[Feature] Update Credentials Image to use Ubuntu `24.04` as base OS. (by @Faraz32123)
- Add `mime-support` alternatives that are `media-types mailcap`.
- Update `python-openssl` to `python3-openssl`.
- [Bugfix] Fix legacy warnings during Docker build. (by @regisb)
<a id='changelog-18.0.0'></a>
## v18.0.0 (2024-06-07)

2
MANIFEST.in Normal file
View File

@ -0,0 +1,2 @@
recursive-include tutorcredentials/patches *
recursive-include tutorcredentials/templates *

View File

@ -1,30 +1,25 @@
.DEFAULT_GOAL := help
.PHONY: docs
SRC_DIRS = ./tutorcredentials
BLACK_OPTS = --exclude templates ${SRC_DIRS}
# Warning: These checks are run on every PR.
test: test-lint test-types test-format test-pythonpackage # Run some static checks.
test: test-lint test-types test-format # Run some static checks.
test-format: ## Run code formatting tests.
ruff format --check --diff ${SRC_DIRS}
black --check --diff $(BLACK_OPTS)
test-lint: ## Run code linting tests
ruff check ${SRC_DIRS}
pylint --errors-only --enable=unused-import,unused-argument --ignore=templates --ignore=docs/_ext ${SRC_DIRS}
test-types: ## Run type checks.
mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS}
build-pythonpackage: ## Build the "tutor-credentials" python package for upload to pypi
python -m build --sdist
test-pythonpackage: build-pythonpackage ## Test that package can be uploaded to pypi
twine check dist/tutor_credentials-$(shell make version).tar.gz
format: ## Format code automatically.
ruff format ${SRC_DIRS}
black $(BLACK_OPTS)
fix-lint: ## Fix lint errors automatically
ruff check --fix ${SRC_DIRS}
isort: ## Sort imports. This target is not mandatory because the output may be incompatible with black formatting. Provided for convenience purposes.
isort --skip=templates ${SRC_DIRS}
changelog-entry: ## Create a new changelog entry.
scriv create
@ -32,9 +27,6 @@ changelog-entry: ## Create a new changelog entry.
changelog: ## Collect changelog entries in the CHANGELOG.md file.
scriv collect
version: ## Print the current tutor-credentials version
@python -c 'import io, os; about = {}; exec(io.open(os.path.join("tutorcredentials", "__about__.py"), "rt", encoding="utf-8").read(), about); print(about["__version__"])'
ESCAPE = 
help: ## Print this help.
@grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \

View File

@ -6,7 +6,7 @@ Credentials application supports course and program certificates. This plugin of
Note that user will have to create the course/program using `Discovery plugin <https://github.com/overhangio/tutor-discovery>`__. Then Credentials plugin will be used for certificates configurations.
.. image:: https://github.com/overhangio/tutor-credentials/blob/release/doc/django-admin-screen-shot.png
.. image:: https://github.com/overhangio/tutor-credentials/blob/master/doc/django-admin-screen-shot.png
:alt: Django Admin
Installation
@ -38,7 +38,7 @@ For Copying programs that user make in `Discovery plugin <https://github.com/ove
Using Django Admin
~~~~~~~~~~~~~~~~~~
The credentials user interface will be available at http://credentials.local.openedx.io for a local instance, and at ``CREDENTIALS_HOST`` (by default: ``http(s)://credentials.<your lms host>``) in production. In order to run commands from the UI login with an admin user at: http://credentials.local.openedx.io/admin/. User should be able to authenticate with the same username and password that he used for his lms.
The credentials user interface will be available at http://credentials.local.edly.io for a local instance, and at ``CREDENTIALS_HOST`` (by default: ``http(s)://credentials.<your lms host>``) in production. In order to run commands from the UI login with an admin user at: http://credentials.local.edly.io/admin/. User should be able to authenticate with the same username and password that he used for his lms.
User can also create superuser for credentials using the below command
::
@ -47,7 +47,7 @@ User can also create superuser for credentials using the below command
Learner Record UI
-----------------
.. image:: https://github.com/overhangio/tutor-credentials/blob/release/doc/learner-record.png
.. image:: https://github.com/overhangio/tutor-credentials/blob/master/doc/learner-record.png
:alt: Learner Record MFE screenshot
This plugin installs and enables the `Learner Record MFE <https://github.com/openedx/frontend-app-learner-record>`__ by default. It contains views for a learners current status in a program, their current grade, and the ability to share any earned credentials either publically or with institutions.
@ -91,7 +91,7 @@ Application Third party authentication
Learner Record UI configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Learner Record is configurable dynamically via runtime configuration. To change any of the variables below, go to your LMS's Django admin Site Configuration page (for instance, http://local.openedx.io/admin/site_configuration/siteconfiguration/) and add or modify corresponding JSON dict entries in the appropriate site:
The Learner Record is configurable dynamically via runtime configuration. To change any of the variables below, go to your LMS's Django admin Site Configuration page (for instance, http://local.edly.io/admin/site_configuration/siteconfiguration/) and add or modify corresponding JSON dict entries in the appropriate site:
- ``SUPPORT_URL_LEARNER_RECORDS`` (default: ``""``): the URL the learner is taken to when clicking the "read more in our records help area" link.
@ -107,9 +107,9 @@ This plugin was initially developed and open sourced to the community thanks to
Troubleshooting
---------------
This Tutor plugin is maintained by Muhammad Labeeb from `Edly <https://edly.io/>`__. Community support is available from the official `Open edX forum <https://discuss.openedx.org>`__. Do you need help with this plugin? See the `troubleshooting <https://docs.tutor.edly.io/troubleshooting.html>`__ section from the Tutor documentation.
This Tutor plugin is maintained by Muhammad Faraz Maqsood from `Edly <https://edly.io/>`__. Community support is available from the official `Open edX forum <https://discuss.openedx.org>`__. Do you need help with this plugin? See the `troubleshooting <https://docs.tutor.edly.io/troubleshooting.html>`__ section from the Tutor documentation.
License
-------
This software is licensed under the terms of the `GNU Affero General Public License (AGPL) <https://github.com/overhangio/tutor-credentials/blob/release/LICENSE.txt>`_.
This software is licensed under the terms of the `GNU Affero General Public License (AGPL) <https://github.com/overhangio/tutor-credentials/blob/master/LICENSE.txt>`_.

View File

@ -0,0 +1 @@
- [Bugfix] Fix legacy warnings during Docker build. (by @regisb)

View File

@ -0,0 +1 @@
- 💥 [Deprecation] Drop support for python 3.8 and set Python 3.9 as the minimum supported python version. (by @Faraz32123)

View File

@ -1,2 +0,0 @@
- [Improvement] Migrate from pylint and black to ruff. (by @mlabeeb03)
- [Improvement] Test python package distribution build when running make test. (by @mlabeeb03)

View File

@ -1,2 +0,0 @@
- [Bugfix] Fixed an issue when syncing `credentials.core_user` to `openedx.auth_user` where the `full_name` field population failed with `ERROR 1292 (22007): Truncated incorrect DOUBLE value: 'FirstName'`.
MySQL does not support string concatenation with `+`, so it was incorrectly treated as a numeric operation. Updated to use `CONCAT()` for proper string concatenation.

View File

@ -1,86 +1,2 @@
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
# https://hatch.pypa.io/latest/config/build/
[project]
name = "tutor-credentials"
license = { text = "AGPL-3.0-only" }
authors = [
{name = "Lawrence McDaniel"},
{email = "lpm0073@gmail.com"},
]
maintainers = [
{name = "Muhammad Labeeb"},
{email = "muhammad.labeeb@arbisoft.com"},
]
description = "A Tutor plugin for Open edX Credentials service"
readme = {file = "README.rst", content-type = "text/x-rst"}
requires-python = ">= 3.9"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dependencies = [
"tutor>=20.0.0,<21.0.0",
"tutor-discovery>=20.0.0,<21.0.0",
"tutor-mfe>=20.0.0,<21.0.0"
]
# these fields will be set by hatch_build.py
dynamic = ["version"]
[project.optional-dependencies]
dev = [
"tutor[dev]>=20.0.0,<21.0.0",
"ruff",
]
[project.entry-points."tutor.plugin.v1"]
credentials = "tutorcredentials.plugin"
# https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels
[project.urls]
Homepage = "https://docs.tutor.edly.io/"
Documentation = "https://docs.tutor.edly.io/"
Code = "https://github.com/overhangio/tutor-credentials"
Issues = "https://github.com/overhangio/tutor-credentials.git/issues"
Changelog = "https://github.com/overhangio/tutor-credentials/blob/release/CHANGELOG.md"
Community = "https://discuss.openedx.org/tag/tutor"
# hatch-specific configuration
[tool.hatch.metadata.hooks.custom]
path = ".hatch_build.py"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.sdist]
# Disable strict naming, otherwise twine is not able to detect name/version
strict-naming = false
include = [ "/tutorcredentials", '.hatch_build.py']
exclude = ["tests*"]
[tool.hatch.build.targets.wheel]
packages = ["tutorcredentials"]
[tool.ruff]
exclude = ["templates", "docs/_ext"]
[tool.ruff.lint]
# E: pycodestyle errors
# I: isort
# N: pep8-naming
select = ["E", "I", "N"]
# F401: unused-import
# F841: unused-variable
# W292: missing-newline-at-end-of-file
extend-select = ["F401", "F841", "W292"]
[tool.ruff.format]
requires = ["setuptools", "wheel"]

61
setup.py Normal file
View File

@ -0,0 +1,61 @@
import io
import os
from setuptools import setup, find_packages
HERE = os.path.abspath(os.path.dirname(__file__))
def load_readme():
with io.open(os.path.join(HERE, "README.rst"), "rt", encoding="utf8") as f:
return f.read()
def load_about():
about = {}
with io.open(
os.path.join(HERE, "tutorcredentials", "__about__.py"),
"rt",
encoding="utf-8",
) as f:
exec(f.read(), about) # pylint: disable=exec-used
return about
ABOUT = load_about()
setup(
name="tutor-credentials",
version=ABOUT["__version__"],
url="https://github.com/overhangio/tutor-credentials.git",
project_urls={
"Code": "https://github.com/overhangio/tutor-credentials.git",
"Issue tracker": "https://github.com/overhangio/tutor-credentials.git/issues",
"Community": "https://discuss.overhang.io",
},
license="AGPLv3",
author="Lawrence McDaniel",
author_email="lpm0073@gmail.com",
maintainer="Edly",
maintainer_email="faraz.maqsood@arbisoft.com",
description="A Tutor plugin for Open edX Credentials service",
long_description=load_readme(),
long_description_content_type="text/x-rst",
packages=find_packages(exclude=["tests*"]),
include_package_data=True,
python_requires=">=3.9",
install_requires=["tutor>=18.0.0,<19.0.0", "tutor-discovery>=18.0.0,<19.0.0", "tutor-mfe>=18.0.0,<19.0.0"],
extras_require={"dev": ["tutor[dev]>=18.0.0,<19.0.0"]},
entry_points={"tutor.plugin.v1": ["credentials = tutorcredentials.plugin"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
)

View File

@ -1 +1 @@
__version__ = "20.0.0"
__version__ = "18.0.0"

View File

@ -15,8 +15,8 @@ spec:
app.kubernetes.io/name: credentials
spec:
securityContext:
runAsUser: {{ APP_USER_ID }}
runAsGroup: {{ APP_USER_ID }}
runAsUser: 1000
runAsGroup: 1000
containers:
- name: credentials
image: {{ CREDENTIALS_DOCKER_IMAGE }}

View File

@ -11,7 +11,7 @@ from tutormfe.hooks import MFE_APPS, MFE_ATTRS_TYPE
from .__about__ import __version__
# Handle version suffix in main mode, just like tutor core
# Handle version suffix in nightly mode, just like tutor core
if __version_suffix__:
__version__ += "-" + __version_suffix__
@ -24,7 +24,7 @@ config: t.Dict[str, t.Dict[str, t.Any]] = {
"defaults": {
"VERSION": __version__,
"BACKEND_SERVICE_EDX_OAUTH2_KEY": "{{ CREDENTIALS_OAUTH2_KEY }}",
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/openedx-credentials:{{ CREDENTIALS_VERSION }}", # noqa: E501
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY }}overhangio/openedx-credentials:{{ CREDENTIALS_VERSION }}",
"EXTRA_PIP_REQUIREMENTS": [],
"HOST": "credentials.{{ LMS_HOST }}",
"MYSQL_DATABASE": "credentials",
@ -68,7 +68,7 @@ tutor_hooks.Filters.CONFIG_OVERRIDES.add_items(
@MFE_APPS.add() # type: ignore
def _add_learner_record_mfe(
apps: dict[str, MFE_ATTRS_TYPE],
apps: dict[str, MFE_ATTRS_TYPE]
) -> dict[str, MFE_ATTRS_TYPE]:
apps.update(
{

View File

@ -1,12 +1,8 @@
# syntax=docker/dockerfile:1
###### Minimal image with base system requirements for most stages
FROM docker.io/ubuntu:24.04 AS minimal
FROM docker.io/ubuntu:20.04 AS minimal
ENV DEBIAN_FRONTEND=noninteractive
# Delete default UID=1000 `ubuntu` user to ensure we can use id 1000 for app user
RUN userdel -r ubuntu
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt update && \
@ -15,6 +11,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
ENV LC_ALL=en_US.UTF-8
{{ patch("credentials-dockerfile-minimal") }}
###### Install python with pyenv in /opt/pyenv and create virtualenv in /openedx/venv
FROM minimal AS python
# https://github.com/pyenv/pyenv/wiki/Common-build-problems#prerequisites
@ -22,7 +19,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked apt update && \
apt install -y libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
# Install pyenv
# https://www.python.org/downloads/
@ -39,9 +36,6 @@ RUN $PYENV_ROOT/versions/$PYTHON_VERSION/bin/python -m venv /openedx/venv
###### Checkout credentials
FROM minimal AS code
# Below warnings will occurr due to the variable name(have word "credentials" in it).
# - SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "CREDENTIALS_REPOSITORY") (line 41)
# - SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ARG "CREDENTIALS_VERSION") (line 42)
ARG CREDENTIALS_REPOSITORY="{{ CREDENTIALS_REPOSITORY }}"
ARG CREDENTIALS_VERSION="{{ CREDENTIALS_REPOSITORY_VERSION }}"
RUN mkdir -p /openedx/credentials && \
@ -70,7 +64,7 @@ RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install \
# https://pypi.org/project/setuptools/
# https://pypi.org/project/pip/
# https://pypi.org/project/wheel/
setuptools==77.0.3 pip==25.0.1 wheel==0.45.1
setuptools==69.1.1 pip==24.0 wheel==0.43.0
# Install base requirements
RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install -r requirements/production.txt
@ -80,7 +74,7 @@ RUN --mount=type=cache,target=/openedx/.cache/pip,sharing=shared pip install \
# Use redis as a django cache https://pypi.org/project/django-redis/
django-redis==5.4.0 \
# uwsgi server https://pypi.org/project/uWSGI/
uwsgi==2.0.28
uwsgi==2.0.24
{{ patch("credentials-dockerfile-post-python-requirements") }}
@ -108,15 +102,15 @@ FROM minimal AS production
# Install system requirements
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked apt update \
&& apt install -y libxml2 libmysqlclient-dev media-types mailcap
&& apt install -y libxml2 libmysqlclient-dev mime-support
# From then on, run as unprivileged "app" user
ARG APP_USER_ID={{ HOST_USER_ID }}
ARG APP_USER_ID=1000
RUN if [ "$APP_USER_ID" = 0 ]; then echo "app user may not be root" && false; fi
RUN useradd --home-dir /openedx --create-home --shell /bin/bash --uid ${APP_USER_ID} app
USER ${APP_USER_ID}
# Change file ownership to the new app user
# change file ownership to the new app user
COPY --chown=app:app --from=code /openedx/credentials /openedx/credentials
COPY --chown=app:app --from=python /opt/pyenv /opt/pyenv
COPY --chown=app:app --from=python-requirements /openedx/venv /openedx/venv
@ -135,8 +129,6 @@ RUN python manage.py compilemessages
# Setup minimal yml config file, which is required by production settings
RUN echo "{}" > /openedx/config.yml
# Below warning will occurr due to the variable name(have word "credentials" in it).
# - SecretsUsedInArgOrEnv: Do not use ARG or ENV instructions for sensitive data (ENV "CREDENTIALS_CFG") (line 136)
ENV CREDENTIALS_CFG=/openedx/config.yml
{{ patch("credentials-dockerfile-pre-assets") }}
@ -160,13 +152,13 @@ EXPOSE 8000
###### Final image with production cmd
FROM production AS final
CMD ["uwsgi", \
"--static-map", "/static=/openedx/credentials/credentials/assets", \
"--static-map", "/media=/openedx/credentials/credentials/media", \
"--http", "0.0.0.0:8000", \
"--thunder-lock", \
"--single-interpreter", \
"--enable-threads", \
"--processes=2", \
"--buffer-size=8192", \
"--wsgi-file", "credentials/wsgi.py"]
CMD uwsgi \
--static-map /static=/openedx/credentials/credentials/assets \
--static-map /media=/openedx/credentials/credentials/media \
--http 0.0.0.0:8000 \
--thunder-lock \
--single-interpreter \
--enable-threads \
--processes=${UWSGI_WORKERS:-2} \
--buffer-size=8192 \
--wsgi-file credentials/wsgi.py

View File

@ -11,7 +11,7 @@ INSERT {{ CREDENTIALS_MYSQL_DATABASE }}.core_user (password, last_login, is_supe
lms_user.is_staff, \
lms_user.is_active, \
lms_user.date_joined, \
CASE WHEN NOT ISNULL(lms_profile.name) THEN lms_profile.name ELSE CONCAT(lms_user.first_name, ' ', lms_user.last_name) END as full_name, \
CASE WHEN NOT ISNULL(lms_profile.name) THEN lms_profile.name ELSE lms_user.first_name + ' ' + lms_user.last_name END as full_name, \
lms_user.id as lms_user_id \
FROM {{ OPENEDX_MYSQL_DATABASE }}.auth_user lms_user \
LEFT JOIN {{ OPENEDX_MYSQL_DATABASE }}.auth_userprofile as lms_profile ON (lms_user.id = lms_profile.user_id) \