Skip to content

Commit 00de08e

Browse files
authored
Merge branch 'packit:main' into mkyral-ewa
2 parents 6405aa1 + cc301ad commit 00de08e

31 files changed

+1091
-317
lines changed

Containerfile.c10s

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ RUN dnf -y install --allowerasing \
3838
sed \
3939
gawk \
4040
rsync \
41+
python3-tabulate \
4142
&& dnf clean all
4243

4344
RUN pip3 install --no-cache-dir \
@@ -46,7 +47,9 @@ RUN pip3 install --no-cache-dir \
4647
openinference-instrumentation-beeai \
4748
arize-phoenix-otel \
4849
redis \
49-
specfile
50+
specfile \
51+
pytest \
52+
pytest-asyncio
5053

5154
# Create user
5255
RUN useradd -m -G wheel beeai

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ run-triage-agent-standalone:
2727
-e MOCK_JIRA=$(MOCK_JIRA) \
2828
triage-agent
2929

30-
31-
30+
.PHONY: run-triage-agent-e2e-tests
31+
run-triage-agent-e2e-tests:
32+
$(COMPOSE_AGENTS) run --rm \
33+
-e MOCK_JIRA="true" \
34+
-e DRY_RUN=$(DRY_RUN) \
35+
triage-agent-e2e-tests
3236

3337
.PHONY: run-rebase-agent-c9s-standalone
3438
run-rebase-agent-c9s-standalone:

README-agents.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ Three agents process tasks through Redis queues:
1919
- **Modify JIRA issues** (add comments, update fields, apply labels)
2020
- **Create GitLab merge requests** and push commits
2121

22+
## Jira mocking
23+
24+
If you clone testing Jira files from
25+
`[email protected]:jotnar-project/testing-jiras.git`
26+
you can use them to work with instead of real Jira server.
27+
28+
Example:
29+
30+
`make run-triage-agent-standalone JIRA_ISSUE=RHEL-15216 MOCK_JIRA=true`
31+
32+
If used together with `DRY_RUN`, the agents won't edit the Jira files,
33+
otherwise they will.
34+
35+
Example:
36+
37+
`make run-triage-agent-standalone JIRA_ISSUE=RHEL-15216 DRY_RUN=true MOCK_JIRA=true`
38+
2239
## Setup
2340

2441
### Required API Tokens & Authentication

agents/backport_agent.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
LogInputSchema,
3838
LogOutputSchema,
3939
Task,
40+
BackportData,
41+
ErrorData,
4042
)
4143
from common.utils import redis_client, fix_await
4244
from constants import I_AM_JOTNAR, CAREFULLY_REVIEW_CHANGES
@@ -68,7 +70,6 @@
6870
GitPatchCreationTool,
6971
GitPreparePackageSources,
7072
)
71-
from triage_agent import BackportData, ErrorData
7273
from utils import (
7374
check_subprocess,
7475
get_agent_execution_config,
@@ -313,11 +314,13 @@ def get_fix_build_error_prompt() -> str:
313314
314315
The package built successfully before your patches were added - the spec file and build configuration are correct.
315316
Your task is to fix this build error by improving the patches - NOT by modifying the spec file.
317+
This includes BOTH compilation errors AND test failures during the check section.
316318
Make ONE attempt to fix the issue - you will be called again if the build still fails.
317319
318320
Follow these steps:
319321
320322
STEP 1: Analyze the build error
323+
- Identify if it's a compilation error (undefined symbols, headers) or test failure (in check section)
321324
- Identify what's missing: undefined functions, types, macros, symbols, headers, or API changes
322325
- Look for patterns like "undefined reference", "implicit declaration", "undeclared identifier", etc.
323326
- Note the specific names of missing symbols
@@ -366,6 +369,13 @@ def get_fix_build_error_prompt() -> str:
366369
- Cherry-pick some commits, then manually adapt code where needed
367370
- Use the upstream repo as a reference while writing your own backport
368371
372+
SPECIAL CONSIDERATIONS FOR TEST FAILURES:
373+
- Tests validate the fix - they MUST pass
374+
- If tests use missing functions/helpers: backport ONLY the minimal necessary test helpers
375+
(search upstream history for test utility commits and cherry-pick or manually add them)
376+
- If tests fail due to API changes: adapt test code to work with older APIs
377+
- NEVER skip or disable tests - fix them instead
378+
369379
STEP 4: Regenerate the patch
370380
- After making your fixes (cherry-picked or manual), regenerate the patch file
371381
- Use `generate_patch_from_commit` tool with the PATCHED_BASE commit
@@ -401,10 +411,11 @@ def get_fix_build_error_prompt() -> str:
401411
- Work in the EXISTING {{local_clone}}-upstream directory (don't clone again)
402412
- NEVER modify the spec file - build failures are caused by incomplete patches, not spec issues
403413
- The ONLY dist-git file you can modify is {{jira_issue}}.patch (by regenerating it from upstream repo)
404-
- Fix build errors by adding missing prerequisites/dependencies to your patches in upstream repo
414+
- Fix build errors (compilation AND test failures) by adding missing prerequisites/dependencies to your patches in upstream repo
415+
- For test failures: backport minimal necessary test helpers/functions to make tests pass
405416
- You can freely explore, edit, cherry-pick, and commit in the upstream repo - it's your workspace
406417
- Use the upstream repo as a rich source of information and examples
407-
- Be creative and pragmatic - the goal is a working build, not perfect git history
418+
- Be creative and pragmatic - the goal is a working build with passing tests, not perfect git history
408419
- Make ONE solid attempt to fix the issue - if the build fails, report the error clearly
409420
- Your work will persist in the upstream repo for the next attempt if needed
410421

agents/build_agent.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def get_instructions() -> str:
3434
using the `download_artifacts` tool to the current directory. If there are no log files,
3535
just return the error message. Otherwise, start with `builder-live.log` and try to identify
3636
the build failure. If not found, try the same with `root.log`. Summarize the findings
37-
and return them as `error`. If the build failed due to a build timeout, set `is_timeout` to `true` in your output.
37+
and return them as `error`. If the build failed due to a build timeout, set `is_timeout` to `true`
38+
in your output. Remove the downloaded *.log.gz files, if any.
3839
3940
General instructions:
4041

agents/log_agent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def get_instructions() -> str:
4646
and a line referencing the Jira issue. Use "- Resolves: <JIRA_ISSUE>" unless
4747
the spec file has historically used a different style.
4848
49+
IMPORTANT: The changelog entry should focus on user-facing changes only. Do not mention
50+
technical packaging details such as added/removed patches, changed BuildRequires,
51+
or other spec file modifications that are not visible to end users.
52+
4953
4. Generate a title for commit message and merge request. It should be descriptive
5054
but shouldn't be longer than 80 characters.
5155

agents/metrics_middleware.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from datetime import datetime
2+
3+
from beeai_framework.context import (
4+
RunContextStartEvent,
5+
RunContextFinishEvent,
6+
RunMiddlewareProtocol,
7+
RunContext
8+
)
9+
from beeai_framework.emitter import EmitterOptions, EventMeta
10+
from beeai_framework.emitter.utils import create_internal_event_matcher
11+
12+
13+
class MetricsMiddleware(RunMiddlewareProtocol):
14+
def __init__(self) -> None:
15+
self.start_time: datetime | None = None
16+
self.end_time: datetime | None = None
17+
self.tool_calls: int = 0
18+
19+
def bind(self, ctx: RunContext) -> None:
20+
ctx.emitter.on(
21+
create_internal_event_matcher("start", ctx.instance),
22+
self._on_run_context_start,
23+
EmitterOptions(is_blocking=True, priority=1),
24+
)
25+
ctx.emitter.on(
26+
create_internal_event_matcher("finish", ctx.instance),
27+
self._on_run_context_finish,
28+
EmitterOptions(is_blocking=True, priority=1),
29+
)
30+
31+
async def _on_run_context_start(self, event: RunContextStartEvent, meta: EventMeta) -> None:
32+
self.start_time = datetime.now()
33+
34+
async def _on_run_context_finish(self, event: RunContextFinishEvent, meta: EventMeta) -> None:
35+
self.end_time = datetime.now()
36+
37+
@property
38+
def duration(self) -> float:
39+
if self.start_time and self.end_time:
40+
return (self.end_time - self.start_time).total_seconds()
41+
return 0
42+
43+
def get_metrics(self) -> dict[str, float]:
44+
return {"duration": self.duration}

agents/package_update_steps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pydantic import BaseModel, Field
55
from pathlib import Path
66

7-
from common.constants import JiraLabels
7+
from common.constants import JiraLabels, GITLAB_MR_CHECKLIST
88
from common.config import load_rhel_config
99
from common.models import LogOutputSchema
1010

@@ -143,6 +143,7 @@ async def create_merge_request_checklist(state, next_step, dry_run, gateway_tool
143143
await tasks.run_tool(
144144
"create_merge_request_checklist",
145145
merge_request_url=state.merge_request_url,
146+
note_body=GITLAB_MR_CHECKLIST,
146147
available_tools=gateway_tools,
147148
)
148149
logger.info(f"Created checklist for MR {state.merge_request_url}")

agents/tasks.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
from common.models import LogOutputSchema, CachedMRMetadata
1111
from common.utils import is_cs_branch
12-
from constants import BRANCH_PREFIX, JIRA_COMMENT_TEMPLATE
13-
from utils import check_subprocess, run_subprocess, run_tool, mcp_tools
14-
from tools.specfile import UpdateReleaseTool
12+
from agents.constants import BRANCH_PREFIX, JIRA_COMMENT_TEMPLATE
13+
from agents.utils import check_subprocess, run_subprocess, run_tool, mcp_tools
14+
from agents.tools.specfile import UpdateReleaseTool
1515

1616
logger = logging.getLogger(__name__)
1717

@@ -29,7 +29,8 @@ async def fork_and_prepare_dist_git(
2929
repository = f"https://gitlab.com/redhat/{namespace}/rpms/{package}"
3030
fork_url = await run_tool("fork_repository", repository=repository, available_tools=available_tools)
3131
local_clone = working_dir / package
32-
shutil.rmtree(local_clone, ignore_errors=True)
32+
if local_clone.is_dir():
33+
shutil.rmtree(local_clone, ignore_errors=False)
3334
if not is_cs_branch(dist_git_branch):
3435
await run_tool(
3536
"create_zstream_branch",
@@ -50,7 +51,8 @@ async def fork_and_prepare_dist_git(
5051
if with_fedora:
5152
try:
5253
fedora_clone = working_dir / f"{package}-fedora"
53-
shutil.rmtree(fedora_clone, ignore_errors=True)
54+
if fedora_clone.is_dir():
55+
shutil.rmtree(fedora_clone, ignore_errors=False)
5456
await check_subprocess(
5557
["git", "clone", "--single-branch", "--branch", "rawhide", f"https://src.fedoraproject.org/rpms/{package}", f"{package}-fedora"],
5658
cwd=working_dir,

agents/tests/e2e/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import Generator
2+
3+
4+
import pytest
5+
6+
7+
@pytest.hookimpl(wrapper=True)
8+
def pytest_terminal_summary(
9+
terminalreporter: pytest.TerminalReporter, exitstatus, config: pytest.Config
10+
) -> Generator:
11+
yield
12+
metrics = config.stash.get("metrics", None)
13+
14+
if metrics:
15+
terminalreporter.write_sep("=", "Metrics")
16+
terminalreporter.write_line(metrics, flush=True)

0 commit comments

Comments
 (0)