Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa053ac7ae | ||
|
|
18d1825de7 |
@ -18,5 +18,5 @@ def load_about() -> dict[str, str]:
|
||||
with open(
|
||||
os.path.join(HERE, "tutordiscovery", "__about__.py"), "rt", encoding="utf-8"
|
||||
) as f:
|
||||
exec(f.read(), about) # pylint: disable=exec-used
|
||||
exec(f.read(), about)
|
||||
return about
|
||||
|
||||
24
Makefile
24
Makefile
@ -1,16 +1,15 @@
|
||||
.DEFAULT_GOAL := help
|
||||
.PHONY: docs
|
||||
SRC_DIRS = ./tutordiscovery ./tests
|
||||
BLACK_OPTS = --exclude templates ${SRC_DIRS}
|
||||
|
||||
# Warning: These checks are run on every PR.
|
||||
test: test-lint test-types test-format test-unit # Run some static checks.
|
||||
test: test-lint test-types test-format test-unit test-pythonpackage # Run some static checks.
|
||||
|
||||
test-format: ## Run code formatting tests.
|
||||
black --check --diff $(BLACK_OPTS)
|
||||
ruff format --check --diff ${SRC_DIRS}
|
||||
|
||||
test-lint: ## Run code linting tests
|
||||
pylint --errors-only --enable=unused-import,unused-argument --ignore=templates --ignore=docs/_ext ${SRC_DIRS}
|
||||
ruff check ${SRC_DIRS}
|
||||
|
||||
test-types: ## Run type checks.
|
||||
mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS}
|
||||
@ -18,11 +17,17 @@ test-types: ## Run type checks.
|
||||
test-unit: ## Run unit tests
|
||||
python -m unittest discover tests
|
||||
|
||||
format: ## Format code automatically.
|
||||
black $(BLACK_OPTS)
|
||||
build-pythonpackage: ## Build the "tutor-discovery" python package for upload to pypi
|
||||
python -m build --sdist
|
||||
|
||||
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}
|
||||
test-pythonpackage: build-pythonpackage ## Test that package can be uploaded to pypi
|
||||
twine check dist/tutor_discovery-$(shell make version).tar.gz
|
||||
|
||||
format: ## Format code automatically.
|
||||
ruff format ${SRC_DIRS}
|
||||
|
||||
fix-lint: ## Fix lint errors automatically
|
||||
ruff check --fix ${SRC_DIRS}
|
||||
|
||||
changelog-entry: ## Create a new changelog entry.
|
||||
scriv create
|
||||
@ -30,6 +35,9 @@ changelog-entry: ## Create a new changelog entry.
|
||||
changelog: ## Collect changelog entries in the CHANGELOG.md file.
|
||||
scriv collect
|
||||
|
||||
version: ## Print the current tutor-discovery version
|
||||
@python -c 'import io, os; about = {}; exec(io.open(os.path.join("tutordiscovery", "__about__.py"), "rt", encoding="utf-8").read(), about); print(about["__version__"])'
|
||||
|
||||
ESCAPE =
|
||||
help: ## Print this help.
|
||||
@grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \
|
||||
|
||||
2
changelog.d/20250808_142901_muhammad.labeeb_release.md
Normal file
2
changelog.d/20250808_142901_muhammad.labeeb_release.md
Normal file
@ -0,0 +1,2 @@
|
||||
- [Improvement] Migrate from pylint and black to ruff. (by @mlabeeb03)
|
||||
- [Improvement] Test python package distribution build when running make test. (by @mlabeeb03)
|
||||
@ -35,8 +35,7 @@ dynamic = ["version"]
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"tutor[dev]>=20.0.0,<21.0.0",
|
||||
"pylint",
|
||||
"black"
|
||||
"ruff",
|
||||
]
|
||||
|
||||
# https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels
|
||||
@ -65,5 +64,21 @@ exclude = ["tests*"]
|
||||
[tool.hatch.build.targets.wheel]
|
||||
packages = ["tutordiscovery"]
|
||||
|
||||
[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]
|
||||
|
||||
[project.entry-points."tutor.plugin.v1"]
|
||||
discovery = "tutordiscovery.plugin"
|
||||
|
||||
@ -20,7 +20,7 @@ class UtilsTests(unittest.TestCase):
|
||||
|
||||
@patch("subprocess.run")
|
||||
def test_is_docker_rootless_podman(self, mock_run: MagicMock) -> None:
|
||||
"""Test the `is_docker_rootless` when podman is used or any other error with `docker info`"""
|
||||
"""Test the `is_docker_rootless` when podman is used or any other error with `docker info`""" # noqa: E501
|
||||
utils.is_docker_rootless.cache_clear()
|
||||
mock_run.side_effect = subprocess.CalledProcessError(1, "docker info")
|
||||
self.assertFalse(utils.is_docker_rootless())
|
||||
|
||||
@ -15,8 +15,8 @@ spec:
|
||||
app.kubernetes.io/name: discovery
|
||||
spec:
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
runAsUser: {{ APP_USER_ID }}
|
||||
runAsGroup: {{ APP_USER_ID }}
|
||||
containers:
|
||||
- name: discovery
|
||||
image: {{ DISCOVERY_DOCKER_IMAGE }}
|
||||
@ -53,9 +53,9 @@ spec:
|
||||
app.kubernetes.io/name: elasticsearch
|
||||
spec:
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
fsGroup: 1000
|
||||
runAsUser: {{ APP_USER_ID }}
|
||||
runAsGroup: {{ APP_USER_ID }}
|
||||
fsGroup: {{ APP_USER_ID }}
|
||||
fsGroupChangePolicy: "OnRootMismatch"
|
||||
containers:
|
||||
- name: elasticsearch
|
||||
|
||||
@ -1 +1 @@
|
||||
{% if DISCOVERY_RUN_ELASTICSEARCH %}setowner 1000 /mounts/elasticsearch{% endif %}
|
||||
{% if DISCOVERY_RUN_ELASTICSEARCH %}setowner {{ APP_USER_ID }} /mounts/elasticsearch{% endif %}
|
||||
|
||||
@ -25,7 +25,7 @@ discovery:
|
||||
soft: -1
|
||||
hard: -1
|
||||
restart: unless-stopped
|
||||
user: "1000:1000"
|
||||
user: "{{ APP_USER_ID }}:{{ APP_USER_ID }}"
|
||||
volumes:
|
||||
- ../../data/elasticsearch:/usr/share/elasticsearch/data
|
||||
depends_on:
|
||||
|
||||
@ -22,7 +22,7 @@ APP_NAME = "discovery"
|
||||
config: t.Dict[str, t.Dict[str, t.Any]] = {
|
||||
"defaults": {
|
||||
"VERSION": __version__,
|
||||
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY}}overhangio/openedx-discovery:{{ DISCOVERY_VERSION }}",
|
||||
"DOCKER_IMAGE": "{{ DOCKER_REGISTRY}}overhangio/openedx-discovery:{{ DISCOVERY_VERSION }}", # noqa: E501
|
||||
"HOST": "discovery.{{ LMS_HOST }}",
|
||||
"INDEX_OVERRIDES": {},
|
||||
"MYSQL_DATABASE": "discovery",
|
||||
|
||||
@ -11,7 +11,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
|
||||
pkg-config libsqlite3-dev media-types mailcap libbz2-dev liblzma-dev
|
||||
ENV LC_ALL=en_US.UTF-8
|
||||
|
||||
ARG APP_USER_ID=1000
|
||||
ARG APP_USER_ID={{ HOST_USER_ID }}
|
||||
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}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user