Skip to content

Commit e30e76c

Browse files
committed
test: add manual trigger for perfomance tests for PR with label performance
1 parent 39593ae commit e30e76c

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

.github/workflows/release_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
performance-tests:
2222
runs-on: ubuntu-latest
23-
if: "contains(github.event.pull_request.labels.*.name, 'autorelease: pending')"
23+
if: "contains(github.event.pull_request.labels.*.name, 'autorelease: pending') || contains(github.event.pull_request.labels.*.name, 'performance')"
2424
steps:
2525
- uses: actions/checkout@v4
2626
- uses: astral-sh/setup-uv@v4

src/robocop/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "7.2.0" # x-release-please-version
1+
__version__ = "7.3.0" # x-release-please-version

src/robocop/source_file.py

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,6 @@
2020
from robocop.config import Config
2121

2222

23-
def _get_model_with_optional_lang(get_model_func: Callable, source: Path, lang: Languages) -> File:
24-
"""
25-
Get Robot file tokenised model with optional language option.
26-
27-
Language option was added in more recent Robot version and we need this code for backward compatibility.
28-
"""
29-
if LANG_SUPPORTED:
30-
return get_model_func(source, lang=lang)
31-
return get_model_func(source)
32-
33-
34-
def get_model_with_lang(source: Path, lang: Languages | None) -> File:
35-
if "__init__" in source.name:
36-
return _get_model_with_optional_lang(get_init_model, source, lang)
37-
if source.suffix == ".resource":
38-
return _get_model_with_optional_lang(get_resource_model, source, lang)
39-
return _get_model_with_optional_lang(get_model, source, lang)
40-
41-
4223
@dataclass
4324
class SourceFile:
4425
"""
@@ -55,10 +36,23 @@ class SourceFile:
5536
path: Path
5637
config: Config
5738
_model: File | None = None
58-
source_lines: list[str] | None = None
39+
_source_lines: list[str] | None = None
5940

6041
@property
6142
def model(self) -> File:
6243
if self._model is None:
63-
self._model = get_model_with_lang(self.path, self.config.languages)
44+
self._model = self._load_model()
6445
return self._model
46+
47+
def _load_model(self) -> File:
48+
"""Determine the correct model loader based on file type and loads it."""
49+
if "__init__" in self.path.name:
50+
loader: Callable = get_init_model
51+
elif self.path.suffix == ".resource":
52+
loader: Callable = get_resource_model
53+
else:
54+
loader: Callable = get_model
55+
56+
if LANG_SUPPORTED:
57+
return loader(self.path, lang=self.config.languages)
58+
return loader(self.path)

tests/performance/generate_reports.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,18 @@
1616
from jinja2 import Environment, FileSystemLoader
1717

1818
from robocop import __version__
19-
from robocop.config_manager import ConfigManager
2019
from robocop.formatter.formatters import FORMATTERS
21-
from robocop.linter.utils.version_matching import Version
2220
from robocop.run import check_files, format_files
2321
from tests import working_directory
2422

23+
try:
24+
from robocop.config_manager import ConfigManager
25+
from robocop.version_handling import Version
26+
except ImportError: # < 7.3.0
27+
from robocop.config import ConfigManager
28+
from robocop.linter.utils.misc import Version
29+
30+
2531
LINTER_TESTS_DIR = Path(__file__).parent.parent / "linter"
2632
TEST_DATA = Path(__file__).parent / "test_data"
2733
ROBOCOP_VERSION = Version(__version__)

0 commit comments

Comments
 (0)