Skip to content

Commit 86aae16

Browse files
Alec4rbrian-smith-tcril
authored andcommitted
chore: add CI workflow and local development tooling
1 parent 042a89d commit 86aae16

File tree

17 files changed

+1086
-0
lines changed

17 files changed

+1086
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Workflow dedicated to testing the tutor-contrib-paragon plugin only
2+
name: Test - tutor-contrib-paragon
3+
4+
on:
5+
pull_request:
6+
paths:
7+
# Trigger this workflow only if files change inside this plugin folder
8+
- 'plugins/tutor-contrib-paragon/**'
9+
10+
jobs:
11+
test-paragon:
12+
name: Run tests for tutor-contrib-paragon
13+
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
# All steps will run from this directory
17+
working-directory: plugins/tutor-contrib-paragon
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: "3.12"
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
make dev-requirements
31+
32+
- name: Run tests
33+
run: make run-tests
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.*.swp
2+
!.gitignore
3+
TODO
4+
__pycache__
5+
*.egg-info/
6+
/build/
7+
/dist/
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# https://hatch.pypa.io/latest/how-to/config/dynamic-metadata/
2+
3+
import os
4+
import typing as t
5+
6+
from hatchling.metadata.plugin.interface import MetadataHookInterface
7+
8+
HERE = os.path.dirname(__file__)
9+
10+
11+
class MetaDataHook(MetadataHookInterface):
12+
def update(self, metadata: dict[str, t.Any]) -> None:
13+
about = load_about()
14+
metadata["version"] = about["__version__"]
15+
16+
17+
def load_about() -> dict[str, str]:
18+
about: dict[str, str] = {}
19+
with open(os.path.join(HERE, "tutorparagon", "__about__.py"), "rt", encoding="utf-8") as f:
20+
exec(f.read(), about) # pylint: disable=exec-used
21+
return about

plugins/tutor-contrib-paragon/LICENSE.txt

Lines changed: 662 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
recursive-include tutorparagon/patches *
2+
recursive-include tutorparagon/templates *
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.DEFAULT_GOAL := help
2+
.PHONY: docs
3+
SRC_DIRS = ./tutorparagon
4+
BLACK_OPTS = --exclude templates ${SRC_DIRS}
5+
6+
# Warning: These checks are not necessarily run on every PR.
7+
test: test-lint test-types test-format # Run some static checks.
8+
9+
test-format: ## Run code formatting tests
10+
black --check --diff $(BLACK_OPTS)
11+
12+
test-lint: ## Run code linting tests
13+
pylint --errors-only --enable=unused-import,unused-argument --ignore=templates --ignore=docs/_ext ${SRC_DIRS}
14+
15+
test-types: ## Run type checks.
16+
mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS}
17+
18+
format: ## Format code automatically
19+
black $(BLACK_OPTS)
20+
21+
isort: ## Sort imports. This target is not mandatory because the output may be incompatible with black formatting. Provided for convenience purposes.
22+
isort --skip=templates ${SRC_DIRS}
23+
24+
unittest: ## Run code tests cases
25+
pytest tests
26+
27+
dev-requirements: ## Install dev requirements
28+
pip install -e .[dev]
29+
30+
run-tests: test unittest # Run static analysis and unit tests
31+
32+
ESCAPE = 
33+
help: ## Print this help
34+
@grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \
35+
| sed 's/######* \(.*\)/@ $(ESCAPE)[1;31m\1$(ESCAPE)[0m/g' | tr '@' '\n' \
36+
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
paragon plugin for `Tutor <https://docs.tutor.edly.io>`__
2+
#########################################################
3+
4+
Facilitates the generation and static hosting of Paragon-based theme CSS files for Open edX MFEs using Tutor.
5+
6+
7+
Installation
8+
************
9+
10+
.. code-block:: bash
11+
12+
pip install git+https://github.com/openedx/openedx-tutor-plugins.git#subdirectory=plugins/tutor-contrib-paragon
13+
14+
Usage
15+
*****
16+
17+
.. code-block:: bash
18+
19+
tutor plugins enable paragon
20+
21+
22+
License
23+
*******
24+
25+
This software is licensed under the terms of the AGPLv3.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
2+
# https://hatch.pypa.io/latest/config/build/
3+
4+
[project]
5+
name = "tutor-contrib-paragon"
6+
description = "Facilitates the generation and static hosting of Paragon-based theme CSS files for Open edX MFEs using Tutor."
7+
authors = [
8+
{ name = "Alejandro Cardenas"},
9+
{ email = "alejandro.cardenas@edunext.co" },
10+
]
11+
license = { text = "AGPL-3.0-only" }
12+
13+
readme = {file = "README.rst", content-type = "text/x-rst"}
14+
requires-python = ">= 3.9"
15+
classifiers = [
16+
"Development Status :: 3 - Alpha",
17+
"Intended Audience :: Developers",
18+
"License :: OSI Approved :: GNU Affero General Public License v3",
19+
"Operating System :: OS Independent",
20+
"Programming Language :: Python",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: Implementation :: CPython",
26+
"Programming Language :: Python :: Implementation :: PyPy",
27+
28+
]
29+
dependencies = [
30+
"tutor>=19.0.0,<20.0.0",
31+
]
32+
33+
optional-dependencies = { dev = ["tutor[dev]>=19.0.0,<20.0.0", "pytest>=8.3.4"] }
34+
35+
# These fields will be set by hatch_build.py
36+
dynamic = ["version"]
37+
38+
# https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels
39+
[project.urls]
40+
Documentation = "https://github.com/openedx/openedx-tutor-plugins.git#subdirectory=plugins/tutor-contrib-paragon#readme"
41+
Issues = "https://github.com/openedx/openedx-tutor-plugins.git#subdirectory=plugins/tutor-contrib-paragon/issues"
42+
Source = "https://github.com/openedx/openedx-tutor-plugins.git#subdirectory=plugins/tutor-contrib-paragon"
43+
44+
[build-system]
45+
requires = ["hatchling"]
46+
build-backend = "hatchling.build"
47+
48+
# hatch-specific configuration
49+
[tool.hatch.metadata.hooks.custom]
50+
path = ".hatch_build.py"
51+
52+
[tool.hatch.build.targets.wheel]
53+
packages = ["tutorparagon"]
54+
55+
[tool.hatch.build.targets.sdist]
56+
# Disable strict naming, otherwise twine is not able to detect name/version
57+
strict-naming = false
58+
include = [ "/tutorparagon", ".hatch_build.py"]
59+
exclude = ["tests*"]
60+
61+
[project.entry-points."tutor.plugin.v1"]
62+
paragon = "tutorparagon.plugin"

plugins/tutor-contrib-paragon/tests/__init__.py

Whitespace-only changes.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
Tutor paragon plugin tests
3+
"""
4+
5+
from tutorparagon import __about__
6+
7+
def test_version_exists():
8+
assert hasattr(__about__, "__version__")
9+
assert isinstance(__about__.__version__, str)
10+
assert __about__.__version__ != ""

0 commit comments

Comments
 (0)