Skip to content
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
4 changes: 3 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ jobs:

- run: uv run ruff check

- run: uv run mypy src
- run: uv run mypy src tests

- run: uv run pytest
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
A keyword library for Robot Framework intended to be used in combination with Robotmk.

## Keywords

```robotframework
*** Settings ***
Library RobotmkLibrary
```

| Keyword | Effect |
| --- | --- |
| `Monitor Subsequent Keyword Runtime discover_as=` | logs the marker that makes Checkmk discover the runtime of the next keyword, under its own name or the given one |

### Development

```sh
uv sync
uv run ruff format --diff
uv run ruff check
uv run mypy src
uv run pytest
```
23 changes: 22 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ authors = [
{ name = "Jörg Herbel", email = "joerg.herbel@checkmk.com" }
]
requires-python = ">=3.11"
dependencies = []
dependencies = [
"robotframework>=7.5.1",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, we only need this for testing, so we could add this as a dev dependency. I also checked the next PR, which implements the listener. Also there, we don't need it in production code. On the other hand, there is no point in using this package without this dependency and the fact that we use the V3 listener API certainly imposes some restriction. So I am fine with this, but again, please make sure Simon Meggle is as well.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I clarify with him. Sadly this dependency is somewhat implicit but real but I am also not super happy with it.

]

[build-system]
requires = ["hatchling"]
Expand All @@ -16,6 +18,7 @@ build-backend = "hatchling.build"
[dependency-groups]
dev = [
"mypy>=2.4.1",
"pytest>=9.2",
"ruff>=0.17.3",
]

Expand All @@ -30,6 +33,9 @@ ignore = [
"TC",
]

[tool.ruff.lint.per-file-ignores]
"tests/**" = ["PLR2004", "S101"]

[tool.mypy]
strict = true
enable_error_code = [
Expand All @@ -39,6 +45,21 @@ enable_error_code = [
]
disallow_any_expr = true
disallow_any_explicit = true
# Calls into these packages are untyped at their end, not ours.
untyped_calls_exclude = ["robot"]

[[tool.mypy.overrides]]
module = "tests.*"
# Robot Framework and the SDK hand the tests Any-typed values (run results, span ids).
disallow_any_expr = false

[[tool.mypy.overrides]]
module = "robot.*"
ignore_missing_imports = true

[tool.pytest.ini_options]
testpaths = ["tests"]
filterwarnings = ["error::UserWarning"]

[tool.hatch.build.targets.wheel]
packages = ["src/RobotmkLibrary"]
17 changes: 6 additions & 11 deletions src/RobotmkLibrary/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import logging
"""Keyword library for Robot Framework suites run by Robotmk.

logger = logging.getLogger(__name__)
``Library RobotmkLibrary`` imports the keywords, which live in
``RobotmkLibrary.keyword_monitoring``.
"""

from RobotmkLibrary.keyword_monitoring import monitor_subsequent_keyword_runtime

def monitor_subsequent_keyword_runtime(
*,
discover_as: str | None = None,
) -> None:
logger.info(
"The subsequent keyword will be discovered in Checkmk using its own name"
if discover_as is None
else f'The subsequent keyword will be discovered in Checkmk as: "{discover_as}"',
)
__all__ = ["monitor_subsequent_keyword_runtime"]
20 changes: 20 additions & 0 deletions src/RobotmkLibrary/keyword_monitoring/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Keywords for the runtime monitoring of the Checkmk test services."""

import logging

logger = logging.getLogger(__name__)


def monitor_subsequent_keyword_runtime(
*,
discover_as: str | None = None,
) -> None:
"""Log the marker that makes Checkmk discover the runtime of the next keyword."""
logger.info(
"The subsequent keyword will be discovered in Checkmk using its own name"
if discover_as is None
else f'The subsequent keyword will be discovered in Checkmk as: "{discover_as}"',
)


__all__ = ["monitor_subsequent_keyword_runtime"]
Empty file added tests/__init__.py
Empty file.
Empty file added tests/integration/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions tests/integration/test_library.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""The library as Robot Framework itself loads it."""

from robot.libdoc import LibraryDocumentation


def test_the_library_lists_the_runtime_keyword() -> None:
"""Library RobotmkLibrary exposes exactly the keyword monitoring keyword.

libdoc loads the package as Robot Framework does. Outcome: the keyword list
is Monitor Subsequent Keyword Runtime only.
"""
assert [
keyword.name for keyword in LibraryDocumentation("RobotmkLibrary").keywords
] == ["Monitor Subsequent Keyword Runtime"]
76 changes: 76 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading