Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix coverage in tests workflow #5

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -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/
9 changes: 3 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -36,18 +36,15 @@ 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 }}

- 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
42 changes: 7 additions & 35 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
20 changes: 18 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "orko"
authors = [
{ name = "Marcelo Duarte Trevisani", email = "[email protected]" },
]
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" }
Expand All @@ -19,7 +19,7 @@ dependencies = [
"tomli",
"packaging",
"pyyaml",
"conda-souschef"
"conda-souschef",
]

[project.scripts]
Expand All @@ -33,6 +33,7 @@ testing = [
"pip",
]
dev = [
"orko[testing]",
"pre-commit",
]

Expand Down Expand Up @@ -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"
16 changes: 9 additions & 7 deletions src/orko/core/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand All @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down