-
Notifications
You must be signed in to change notification settings - Fork 2
feat(review): relay the engine's early-exit verdict, a machine-readable comment line, and the platform link in the progress comment #131
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ab75e35
feat(review): skip the engine when no analysed file changed, and end …
Svilen-Stefanov 16427fd
refactor(review): relay the engine's early-exit verdict instead of de…
Svilen-Stefanov c66b36f
fix(comment): call a review unchanged only when the engine's flag and…
Svilen-Stefanov 97bdf2e
chore(artifact): follow the engine's rename to structure_unchanged
Svilen-Stefanov 44ab297
feat(review): decide "no analysed file changed" from the two analyses…
Svilen-Stefanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| """The review artifact's metadata records how many analysed files changed, as the render step counted them.""" | ||
|
|
||
| import json | ||
| import os | ||
| import subprocess | ||
| import tempfile | ||
| import unittest | ||
| from pathlib import Path | ||
|
|
||
| ROOT = Path(__file__).resolve().parents[1] | ||
| BUILD_ARTIFACT = ROOT / "scripts" / "action" / "build-review-artifact.sh" | ||
|
|
||
|
|
||
| def _build(root: Path, **extra: str) -> tuple[dict, dict]: | ||
| head = root / "head.json" | ||
| head.write_text('{"components": ["head"]}', encoding="utf-8") | ||
| base = root / "base.json" | ||
| base.write_text('{"components": ["base"]}', encoding="utf-8") | ||
| output = root / "github-output" | ||
| output.write_text("", encoding="utf-8") | ||
| result = subprocess.run( | ||
| [str(BUILD_ARTIFACT)], | ||
| env={ | ||
| "PATH": os.environ["PATH"], | ||
| "RUNNER_TEMP": str(root), | ||
| "GITHUB_OUTPUT": str(output), | ||
| "ANALYSIS_PATH": str(head), | ||
| "BASE_ARTIFACT_NAME": "codeboarding-base-cfg-mergebasesha", | ||
| "BASE_ARTIFACT_ID": "4242", | ||
| "BASE_ANALYSIS_PATH": str(base), | ||
| "INLINE_BASE": "false", | ||
| "ANALYSIS_MODE": "incremental", | ||
| "BASE_SHA": "tip-sha", | ||
| "MERGE_BASE_SHA": "merge-base-sha", | ||
| "MERGE_BASE_RESOLVED": "true", | ||
| "HEAD_SHA": "head-sha", | ||
| "PR_NUMBER": "81", | ||
| "SEED_SOURCE": "pr-chain", | ||
| "CHAIN_DEPTH": "2", | ||
| **extra, | ||
| }, | ||
| capture_output=True, | ||
| text=True, | ||
| check=False, | ||
| ) | ||
| assert result.returncode == 0, result.stderr or result.stdout | ||
| metadata = json.loads((root / "cb-review-artifact" / "metadata.json").read_text(encoding="utf-8")) | ||
| outputs: dict[str, str] = {} | ||
| for line in output.read_text(encoding="utf-8").splitlines(): | ||
| key, _, value = line.partition("=") | ||
| outputs[key] = value | ||
| return metadata, outputs | ||
|
|
||
|
|
||
| class ReviewArtifactMetadataTests(unittest.TestCase): | ||
| def test_the_analysed_file_count_is_recorded_as_counted(self) -> None: | ||
| with tempfile.TemporaryDirectory() as tmp: | ||
| metadata, outputs = _build(Path(tmp), ANALYSED_FILES_CHANGED="0") | ||
| # A string, like every other `--arg` field the webview reads from this file. | ||
| self.assertEqual(metadata["analysed_files_changed"], "0") | ||
| self.assertEqual(set(outputs), {"artifact_dir"}) | ||
|
|
||
| def test_a_count_the_render_step_could_not_make_is_recorded_as_unknown(self) -> None: | ||
| with tempfile.TemporaryDirectory() as tmp: | ||
| metadata, _outputs = _build(Path(tmp)) | ||
| self.assertEqual(metadata["analysed_files_changed"], "unknown") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a PR deletes the last analysed source file, the head analysis legitimately has
"files": {}, but this condition treats that empty index as unavailable and returnsNone. The artifact and comment therefore reportanalysed_files_changed=unknowninstead of counting the removed files; similarly, a repository with no analysed files on either side never receives the zero-change verdict. Check whether thefilesfield is absent or invalid rather than whether its mapping is empty.Useful? React with 👍 / 👎.