Skip to content

Commit

Permalink
Merge pull request #50 from CodeWithEmad/feat/test-lint
Browse files Browse the repository at this point in the history
Feat: Testing and Linting
  • Loading branch information
hinakhadim committed Dec 6, 2023
2 parents 9ffd29a + 060b47d commit b60d73e
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 4 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Run tests

on:
pull_request:
branches: [master]

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Upgrade pip
run: python -m pip install --upgrade pip setuptools
- name: Install dependencies
run: |
pip install .[dev]
- name: Test lint, types, and format
run: make test
34 changes: 34 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
.DEFAULT_GOAL := help
.PHONY: docs
SRC_DIRS = ./tutorindigo
BLACK_OPTS = --exclude templates ${SRC_DIRS}

# Warning: These checks are not necessarily run on every PR.
test: test-lint test-types test-format # Run some static checks.

test-format: ## Run code formatting tests
black --check --diff $(BLACK_OPTS)

test-lint: ## Run code linting tests
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}

format: ## Format code automatically
black $(BLACK_OPTS)

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

changelog: ## Collect changelog entries in the CHANGELOG.md file.
scriv collect

ESCAPE = 
help: ## Print this help
@grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \
| sed 's/######* \(.*\)/@ $(ESCAPE)[1;31m\1$(ESCAPE)[0m/g' | tr '@' '\n' \
| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}'
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Installation

Indigo was specially developed to be used with `Tutor <https://docs.tutor.edly.io>`__ (at least v14.0.0). If you have not installed Open edX with Tutor, then installation instructions will vary.

Since Tutor v13.2.0, Indigo can be installed as a Tutor plugin::
Install and enable Indigo plugin::

tutor plugins install indigo
tutor plugins enable indigo
Expand Down
1 change: 1 addition & 0 deletions changelog.d/20231004_141354_codewithemad.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- [Improvement] Added Makefile and test action to repository and formatted code with Black and isort. (by @CodeWithEmad)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def load_about():
include_package_data=True,
python_requires=">=3.8",
install_requires=["tutor>=16.0.0,<17.0.0"],
extras_require={"dev": "tutor[dev]>=16.0.0,<17.0.0"},
entry_points={"tutor.plugin.v1": ["indigo = tutorindigo.plugin"]},
classifiers=[
"Development Status :: 5 - Production/Stable",
Expand Down
1 change: 0 additions & 1 deletion tutorindigo/__about__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
__version__ = "16.0.0"

5 changes: 3 additions & 2 deletions tutorindigo/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pkg_resources
import typing as t

import pkg_resources
from tutor import hooks
from tutor.__about__ import __version_suffix__

Expand All @@ -11,7 +12,7 @@


################# Configuration
config = {
config: t.Dict[str, t.Dict[str, t.Any]] = {
# Add here your new settings
"defaults": {
"VERSION": __version__,
Expand Down

0 comments on commit b60d73e

Please sign in to comment.