diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..157db3e --- /dev/null +++ b/.coveragerc @@ -0,0 +1,19 @@ +[run] +concurrency = multiprocessing +parallel = true +relative_files = True + +[report] +omit = + .cache/* + */tests/* + docs/* + .pytest_cache/* + setup.py + pyproject.toml + _version.py + orko.egg-info/* + .github/* + +[paths] +source = src/ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4a273da..3846ea8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -27,7 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install .[testing] + python -m pip install -e .[testing] - name: Running tests shell: bash -l {0} @@ -36,10 +36,8 @@ jobs: -vv \ -n auto \ --color=yes \ - --cov=./ \ + --cov \ --cov-append \ - --cov-report html:coverage-serial-html \ - --cov-report xml:coverage-serial.xml \ --cov-config=.coveragerc \ --junit-xml=${{ matrix.os }}-py${{ matrix.py_ver }}.xml \ --junit-prefix=${{ matrix.os }}-py${{ matrix.py_ver }} @@ -47,7 +45,6 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - files: ./coverage-serial.xml,./coverage-parallel.xml directory: . flags: unittests - name: orko-tests + fail_ci_if_error: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0c6801..f933d69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,28 +1,12 @@ repos: -- repo: https://github.com/PyCQA/autoflake - rev: v2.1.1 - hooks: - - id: autoflake - name: autoflake - args: ["--in-place", "--remove-unused-variables", "--remove-all-unused-imports"] - language: python - files: \.py$ -- repo: https://github.com/asottile/reorder-python-imports - rev: v3.9.0 - hooks: - - id: reorder-python-imports -- repo: https://github.com/psf/black - rev: 23.3.0 - hooks: - - id: black - args: [--safe, --quiet] -- repo: https://github.com/asottile/blacken-docs - rev: 1.13.0 - hooks: - - id: blacken-docs - additional_dependencies: [black==23.3.0] +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.5 + hooks: + - id: ruff + args: [ --fix ] + - id: ruff-format - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -37,15 +21,3 @@ repos: args: [--autofix] - id: debug-statements language_version: python3 -- repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 - hooks: - - id: flake8 - exclude: tests/data - language_version: python3 - additional_dependencies: - - flake8-typing-imports==1.14.0 - - flake8-builtins==2.1.0 - - flake8-bugbear==23.1.20 - - toml - - flake8-comprehensions diff --git a/pyproject.toml b/pyproject.toml index 17ff769..c6a3a2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "orko" authors = [ { name = "Marcelo Duarte Trevisani", email = "marceloduartetrevisani@gmail.com" }, ] -description = "Project to generate recipes for conda packages" +description = "Project to manage conda environments and dependencies." readme = "README.md" keywords = ["conda", "environment", "pyproject.toml"] license = { text = "Apache-2.0" } @@ -19,7 +19,7 @@ dependencies = [ "tomli", "packaging", "pyyaml", - "conda-souschef" + "conda-souschef", ] [project.scripts] @@ -33,6 +33,7 @@ testing = [ "pip", ] dev = [ + "orko[testing]", "pre-commit", ] @@ -64,3 +65,18 @@ where = ["src"] [tool.pytest.ini_options] testpaths = ["tests"] + +[tool.ruff] +line-length = 88 +indent-width = 4 +target-version = "py310" + +[tool.ruff.lint] +select = ["E", "F"] +fixable = ["ALL"] + +[tool.ruff.format] +quote-style = "double" +indent-style = "space" +skip-magic-trailing-comma = false +line-ending = "auto" diff --git a/src/orko/core/process.py b/src/orko/core/process.py index b55deaf..682db47 100644 --- a/src/orko/core/process.py +++ b/src/orko/core/process.py @@ -6,6 +6,8 @@ import tomli from orko.core.base import Dependency +logger = logging.getLogger(__name__) + def extract_specific_deps( pyproject: dict, path_key: list | None = None @@ -21,7 +23,7 @@ def extract_specific_deps( all_deps.extend(convert_to_dependency_obj(dep)) else: all_deps.extend(convert_to_dependency_obj(group_project)) - logging.debug(f"Extracted dependencies from {'.'.join(path_key)}: {all_deps}") + logger.debug(f"Extracted dependencies from {'.'.join(path_key)}: {all_deps}") return all_deps @@ -39,7 +41,7 @@ def replace_deps_with_orko_if_duplicated( if not find_pkg: normalised_deps.append(project_pkg) normalised_deps = list(set(normalised_deps)) - logging.debug( + logger.debug( f"Dependency replace. Old: {project_deps}, Replaced by: {normalised_deps}" ) return normalised_deps @@ -64,7 +66,7 @@ def get_run_deps( if not merge_deps: project_deps = replace_deps_with_orko_if_duplicated(project_deps, orko_deps) - logging.debug(f"[project] deps: {project_deps}") + logger.debug(f"[project] deps: {project_deps}") if optional_deps_sections == "*" or "*" in optional_deps_sections: opt_deps_project_sections = list( pyproject.get("project", {}).get("optional-dependencies", {}).keys() @@ -95,8 +97,8 @@ def get_run_deps( pyproject, ["tools", "orko", "optional-dependencies", k] ) ) - logging.debug(f"[orko.optional-dependencies]: {all_opt_deps_orko}") - logging.debug(f"[project.optional-dependencies]: {all_opt_deps_project}") + logger.debug(f"[orko.optional-dependencies]: {all_opt_deps_orko}") + logger.debug(f"[project.optional-dependencies]: {all_opt_deps_project}") all_opt_deps = all_opt_deps_orko if merge_deps: all_opt_deps.extend(all_opt_deps_project) @@ -106,9 +108,9 @@ def get_run_deps( all_opt_deps_project, all_opt_deps_orko ) ) - logging.debug(f"Optional dependencies to install: {all_opt_deps}") + logger.debug(f"Optional dependencies to install: {all_opt_deps}") all_required_deps = project_deps + orko_deps - logging.debug(f"Required deps to install: {all_required_deps}") + logger.debug(f"Required deps to install: {all_required_deps}") if requires_python := pyproject.get("project", {}).get("requires-python", None): all_required_deps.append(Dependency("python", version=requires_python))