feat: support CI artifact context injection and workflow_run trigger#2494
feat: support CI artifact context injection and workflow_run trigger#2494MahmoudHaouachi wants to merge 2 commits into
Conversation
PR Summary by QodoSupport workflow_run trigger and inject CI artifact context into PR tools
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
Context used 1. Truncation marker can exceed limit
|
|
Hey @MahmoudHaouachi, |
Hi @naorpeled , yes this sounds good, much simpler and removes redundancy |
|
Code review by qodo was updated up to the latest commit 19a1c0a |
|
Code review by qodo was updated up to the latest commit f3ad8fb |
|
Hey @MahmoudHaouachi, |
|
Code review by qodo was updated up to the latest commit 2fb424d |
|
Code review by qodo was updated up to the latest commit f2a6cd1 |
Hello @naorpeled, I'm through with Qodo's findings 👍 |
|
Code review by qodo was updated up to the latest commit a5f8e15 |
|
Code review by qodo was updated up to the latest commit 8493525 |
|
Code review by qodo was updated up to the latest commit 783cc86 |
|
Code review by qodo was updated up to the latest commit c0c2503 |
c0c2503 to
0fd5e76
Compare
|
Code review by qodo was updated up to the latest commit 0fd5e76 |
|
Code review by qodo was updated up to the latest commit 6ece4d4 |
6ece4d4 to
6a35570
Compare
|
Code review by qodo was updated up to the latest commit 6a35570 |
6a35570 to
5e9593a
Compare
|
Code review by qodo was updated up to the latest commit 5e9593a |
Add support for injecting CI-produced artifact content (test reports, terraform plans, build logs) into PR-Agent tool prompts via extra_instructions. - New module pr_agent/algo/artifacts.py with load_artifact(), format_artifact_content(), resolve_artifact_path() (confined to GITHUB_WORKSPACE), _read_and_truncate() - _inject_artifact_context() helper in github_action_runner.py called in all three dispatch paths (pull_request*, issue_comment, workflow_run) - action.yaml: artifact_path + artifact_instructions inputs - configuration.toml: [artifacts] section with enable, artifact_path, target_tools, max_artifact_size, artifact_instructions, artifact_label - 44 unit tests covering artifacts module and runner integration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5e9593a to
a378d84
Compare
|
Code review by qodo was updated up to the latest commit a378d84 |
- Use Path.is_relative_to() for workspace containment check (fixes root workspace edge case where GITHUB_WORKSPACE=/ produced "//" prefix) - Gate _inject_artifact_context() on is_pr in issue_comment handler - Upgrade log level for apply_repo_settings failure to warning - Normalize single quotes to double quotes per repo style Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Code review by qodo was updated up to the latest commit bea1201 |
|
Hello @naorpeled , when can you merge this ? because we want to start using soon in my team |
Missed your previous comment, sorry, will try to review asap |
Closes #2493
Summary
Adds two related enhancements that together enable a common CI/CD pattern: running PR-Agent after a prior workflow completes, with that workflow's artifacts injected as extra review context.
Changes
1.
pr_agent/algo/artifacts.py(new)Reads a local artifact file and formats its content for injection into tool prompts.
resolve_artifact_path— resolves relative/absolute paths, confined toGITHUB_WORKSPACE(rejects traversal outside workspace)_read_and_truncate— reads up tomax_artifact_sizecharacters without loading the full file into memoryformat_artifact_content(content, label, instructions)— wraps content with a header and instruction text (usesDEFAULT_ARTIFACT_INSTRUCTIONSif none provided)load_artifact()— orchestrates the above; no-op unless enabled andartifact_pathis set2.
pr_agent/servers/github_action_runner.pyArtifact injection block: reads
ARTIFACT_PATH/ARTIFACT_INSTRUCTIONSenv vars before event dispatch, callsload_artifact()once, and appends the result toextra_instructionsfor the configured target tools. Safe no-op whenARTIFACT_PATHis not set.workflow_runhandler: newelif GITHUB_EVENT_NAME == "workflow_run":branch. Extracts the PR URL fromworkflow_run.pull_requests[0].urland runs the same auto tools as thepull_requesthandler. Guards: skips non-pull_requestorigins and emptypull_requestsarrays (fork PRs).3.
action.yamlTwo new optional inputs with safe defaults:
artifact_path(default"") — path to artifact relative toGITHUB_WORKSPACEartifact_instructions(default"") — custom instructions telling the AI how to interpret the artifact; defaults to a sensible generic prompt when left empty4.
pr_agent/settings/configuration.tomlNew
[artifacts]section with all options (enable,artifact_path,artifact_instructions,artifact_label,target_tools,max_artifact_size).5. Tests
tests/unittest/test_artifacts.py(new, 21 tests) — covers path resolution, truncation, formatting, load gating, and security (path traversal rejection)tests/unittest/test_github_action_runner_core.py— 3 new tests forworkflow_run: runs tools, skips non-PR origin, skips emptypull_requests6.
github_action/entrypoint.shAdded
set -efor fail-fast behavior.Example: terraform plan review via workflow_run
Toggle / opt-out
artifact_pathdefaults to"", injection never runsartifact_pathin action inputs, or[artifacts] enable = true+artifact_pathin.pr_agent.tomlartifact_pathfrom action inputs, or[artifacts] enable = falseworkflow_runhandler only fires whenGITHUB_EVENT_NAME=workflow_run— existingpull_requestandissue_commentflows are completely unchanged