From 937288d7d7e508123ebb09f0bf6cbdb074c5dccc Mon Sep 17 00:00:00 2001 From: Marcelo Trevisani Date: Tue, 11 Jul 2023 06:33:06 +0100 Subject: [PATCH 1/8] Fix coverage in tests workflow --- .github/workflows/tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4a273da..692dd67 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -36,7 +36,7 @@ jobs: -vv \ -n auto \ --color=yes \ - --cov=./ \ + --cov=src \ --cov-append \ --cov-report html:coverage-serial-html \ --cov-report xml:coverage-serial.xml \ From 0b492ef155d9d888b83716ab756d0668738d625c Mon Sep 17 00:00:00 2001 From: Marcelo Trevisani Date: Tue, 11 Jul 2023 06:51:32 +0100 Subject: [PATCH 2/8] Add coveragerc file --- .coveragerc | 14 ++++++++++++++ .github/workflows/tests.yaml | 8 ++++---- 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..983f5b7 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,14 @@ +[run] +omit = + .cache/* + */tests/* + docs/* + .pytest_cache/* + setup.py + pyproject.toml + _version.py + orko.egg-info/* + .github/* + +[paths] +source = orko/ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 692dd67..2df4ca9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -36,10 +36,10 @@ jobs: -vv \ -n auto \ --color=yes \ - --cov=src \ + --cov=./ \ --cov-append \ - --cov-report html:coverage-serial-html \ - --cov-report xml:coverage-serial.xml \ + --cov-report html:coverage-${{ matrix.os }}-py${{ matrix.py_ver }}.html \ + --cov-report xml:coverage-${{ matrix.os }}-py${{ matrix.py_ver }}.xml \ --cov-config=.coveragerc \ --junit-xml=${{ matrix.os }}-py${{ matrix.py_ver }}.xml \ --junit-prefix=${{ matrix.os }}-py${{ matrix.py_ver }} @@ -47,7 +47,7 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - files: ./coverage-serial.xml,./coverage-parallel.xml + files: ./coverage-${{ matrix.os }}-py${{ matrix.py_ver }}.xml directory: . flags: unittests name: orko-tests From 889cc8b5b868715bd52e26a1e5804a1fa0e78316 Mon Sep 17 00:00:00 2001 From: Marcelo Trevisani Date: Tue, 11 Jul 2023 16:59:02 +0100 Subject: [PATCH 3/8] test --- .coveragerc | 5 ++++- .github/workflows/tests.yaml | 9 ++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.coveragerc b/.coveragerc index 983f5b7..51f860d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,4 +1,7 @@ [run] +concurrency = multiprocessing +parallel = true +source=src/ omit = .cache/* */tests/* @@ -11,4 +14,4 @@ omit = .github/* [paths] -source = orko/ +source = src/ diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 2df4ca9..74cf37a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -36,10 +36,10 @@ jobs: -vv \ -n auto \ --color=yes \ - --cov=./ \ + --cov=. \ --cov-append \ - --cov-report html:coverage-${{ matrix.os }}-py${{ matrix.py_ver }}.html \ - --cov-report xml:coverage-${{ matrix.os }}-py${{ matrix.py_ver }}.xml \ + --cov-report html:coverage.html \ + --cov-report xml:coverage.xml \ --cov-config=.coveragerc \ --junit-xml=${{ matrix.os }}-py${{ matrix.py_ver }}.xml \ --junit-prefix=${{ matrix.os }}-py${{ matrix.py_ver }} @@ -47,7 +47,6 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: - files: ./coverage-${{ matrix.os }}-py${{ matrix.py_ver }}.xml directory: . flags: unittests - name: orko-tests + fail_ci_if_error: true From 7ab7e4a3fcbeb1df3a48e2e0cad75ccd6c552ce3 Mon Sep 17 00:00:00 2001 From: Marcelo Trevisani Date: Tue, 11 Jul 2023 17:48:40 +0100 Subject: [PATCH 4/8] test coveragerc --- .coveragerc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index 51f860d..157db3e 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,7 +1,9 @@ [run] concurrency = multiprocessing parallel = true -source=src/ +relative_files = True + +[report] omit = .cache/* */tests/* From 4ad5f88ad91a27c9cb19b6f1bde69250253a97dc Mon Sep 17 00:00:00 2001 From: Marcelo Trevisani Date: Thu, 9 Nov 2023 06:04:17 +0000 Subject: [PATCH 5/8] Update pre-commit and add more logs --- .pre-commit-config.yaml | 12 ++++++------ pyproject.toml | 5 +++-- src/orko/core/process.py | 16 +++++++++------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e0c6801..ca87e16 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/PyCQA/autoflake - rev: v2.1.1 + rev: v2.2.1 hooks: - id: autoflake name: autoflake @@ -8,21 +8,21 @@ repos: language: python files: \.py$ - repo: https://github.com/asottile/reorder-python-imports - rev: v3.9.0 + rev: v3.12.0 hooks: - id: reorder-python-imports - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.11.0 hooks: - id: black args: [--safe, --quiet] - repo: https://github.com/asottile/blacken-docs - rev: 1.13.0 + rev: 1.16.0 hooks: - id: blacken-docs additional_dependencies: [black==23.3.0] - 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 @@ -38,7 +38,7 @@ repos: - id: debug-statements language_version: python3 - repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 + rev: 6.1.0 hooks: - id: flake8 exclude: tests/data diff --git a/pyproject.toml b/pyproject.toml index 17ff769..6d65b31 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", ] 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)) From 708aff2f7a8b566a6fe4e82473df55e5351886c1 Mon Sep 17 00:00:00 2001 From: Marcelo Trevisani Date: Thu, 9 Nov 2023 06:20:25 +0000 Subject: [PATCH 6/8] Use ruff instead of flake8, isort and black --- .pre-commit-config.yaml | 40 ++++++---------------------------------- pyproject.toml | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ca87e16..f933d69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,26 +1,10 @@ repos: -- repo: https://github.com/PyCQA/autoflake - rev: v2.2.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.12.0 - hooks: - - id: reorder-python-imports -- repo: https://github.com/psf/black - rev: 23.11.0 - hooks: - - id: black - args: [--safe, --quiet] -- repo: https://github.com/asottile/blacken-docs - rev: 1.16.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.5.0 hooks: @@ -37,15 +21,3 @@ repos: args: [--autofix] - id: debug-statements language_version: python3 -- repo: https://github.com/PyCQA/flake8 - rev: 6.1.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 6d65b31..c6a3a2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,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" From cbbd28175b11523dda7c122b55f414a3e81ad8d0 Mon Sep 17 00:00:00 2001 From: Marcelo Trevisani Date: Thu, 9 Nov 2023 06:24:35 +0000 Subject: [PATCH 7/8] Fix coverage --- .github/workflows/tests.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 74cf37a..f206995 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -38,8 +38,6 @@ jobs: --color=yes \ --cov=. \ --cov-append \ - --cov-report html:coverage.html \ - --cov-report xml:coverage.xml \ --cov-config=.coveragerc \ --junit-xml=${{ matrix.os }}-py${{ matrix.py_ver }}.xml \ --junit-prefix=${{ matrix.os }}-py${{ matrix.py_ver }} From 83c2fc888ba8fb5adbbf790a6e0970bd69a11c5c Mon Sep 17 00:00:00 2001 From: Marcelo Duarte Trevisani Date: Sat, 25 Nov 2023 23:50:39 +0000 Subject: [PATCH 8/8] Update tests.yaml --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index f206995..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,7 +36,7 @@ jobs: -vv \ -n auto \ --color=yes \ - --cov=. \ + --cov \ --cov-append \ --cov-config=.coveragerc \ --junit-xml=${{ matrix.os }}-py${{ matrix.py_ver }}.xml \