[#648] Create tophat-build-install skill for GitHub Actions artifact install via Tophat#665
[#648] Create tophat-build-install skill for GitHub Actions artifact install via Tophat#665
Conversation
📝 WalkthroughWalkthroughThis PR introduces the Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant CLI as install_artifact.py
participant GitRepo as Git Repository
participant GH as gh CLI
participant Recipe as make_recipe.py
participant Tophat as tophatctl
User->>CLI: Request artifact install (repo, artifact ID, platform)
CLI->>GitRepo: Infer owner/repo from remotes
GitRepo-->>CLI: owner/repo
CLI->>Recipe: Generate Tophat recipe (gha provider params)
Recipe-->>CLI: Recipe JSON (temp file)
CLI->>Tophat: Invoke install_recipe (recipe path)
Tophat->>GH: Fetch artifact metadata
GH-->>Tophat: Artifact data
Tophat->>Tophat: Download & install artifact
Tophat-->>CLI: Install status (installed/pending/failed)
CLI->>CLI: Print colorized output
CLI->>CLI: Cleanup temp recipe (unless --keep-recipe)
CLI-->>User: Installation result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
100182c to
e9eb621
Compare
e9eb621 to
2f877d8
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
skills/tophat-build-install/scripts/gha.py (1)
169-209: Consider extracting duplicated artifact metadata patching logic.The
list_matching_run_artifactsandlist_all_run_artifactsfunctions share identical logic for patchingworkflow_runmetadata onto artifacts (lines 181-187 and 201-207). This could be extracted into a small helper.♻️ Optional: Extract shared patching logic
+def patch_artifact_workflow_run(artifact: dict[str, Any], run: dict[str, Any]) -> None: + workflow_run = artifact.get("workflow_run") or {} + if "head_branch" not in workflow_run and run.get("headBranch"): + workflow_run["head_branch"] = run.get("headBranch") + if "head_sha" not in workflow_run and run.get("headSha"): + workflow_run["head_sha"] = run.get("headSha") + artifact["workflow_run"] = workflow_run + + def list_matching_run_artifacts(repo: str, ref: str, sha: str) -> list[dict[str, Any]]: artifacts: list[dict[str, Any]] = [] for run in list_runs(repo, ref=ref): if not workflow_run_matches_ref(run, ref=ref, sha=sha): continue run_id = run.get("databaseId") if not run_id: continue for artifact in list_run_artifacts(repo, int(run_id)): - workflow_run = artifact.get("workflow_run") or {} - if "head_branch" not in workflow_run and run.get("headBranch"): - workflow_run["head_branch"] = run.get("headBranch") - if "head_sha" not in workflow_run and run.get("headSha"): - workflow_run["head_sha"] = run.get("headSha") - artifact["workflow_run"] = workflow_run + patch_artifact_workflow_run(artifact, run) artifacts.append(artifact) return artifacts🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@skills/tophat-build-install/scripts/gha.py` around lines 169 - 209, Both list_matching_run_artifacts and list_all_run_artifacts duplicate the same logic that patches workflow_run metadata onto each artifact; extract that into a small helper (e.g., patch_workflow_run_metadata(artifact: dict, run: dict) or _apply_workflow_run_metadata) that takes the artifact and the corresponding run, merges/sets "head_branch" and "head_sha" into artifact["workflow_run"] as currently done, and then call this helper from both list_matching_run_artifacts and list_all_run_artifacts to remove the duplicated lines and keep behavior identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@skills/tophat-build-install/scripts/gha.py`:
- Around line 169-209: Both list_matching_run_artifacts and
list_all_run_artifacts duplicate the same logic that patches workflow_run
metadata onto each artifact; extract that into a small helper (e.g.,
patch_workflow_run_metadata(artifact: dict, run: dict) or
_apply_workflow_run_metadata) that takes the artifact and the corresponding run,
merges/sets "head_branch" and "head_sha" into artifact["workflow_run"] as
currently done, and then call this helper from both list_matching_run_artifacts
and list_all_run_artifacts to remove the duplicated lines and keep behavior
identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 756bb19b-4bd7-416a-80b7-04f0b63fc85e
📒 Files selected for processing (6)
skills/tophat-build-install/SKILL.mdskills/tophat-build-install/references/public-contract.mdskills/tophat-build-install/scripts/gha.pyskills/tophat-build-install/scripts/install_artifact.pyskills/tophat-build-install/scripts/install_with_tophat.pyskills/tophat-build-install/scripts/make_recipe.py
| def artifact_matches( | ||
| artifact: dict[str, Any], | ||
| ref: str, | ||
| sha: str, | ||
| run_id: int | None, | ||
| platform: str, | ||
| ) -> bool: |
There was a problem hiding this comment.
I suggest removing the platform check from artifact matching here. Our GitHub Actions artifacts are named as v{version}({build})-{TAG_TYPE} and do not include iOS or Android builds, so this filter will exclude valid builds. The platform can still be kept as a Tophat recipe hint, but it should not be used to narrow artifact selection.
| def artifact_matches( | |
| artifact: dict[str, Any], | |
| ref: str, | |
| sha: str, | |
| run_id: int | None, | |
| platform: str, | |
| ) -> bool: | |
| def artifact_matches( | |
| artifact: dict[str, Any], | |
| ref: str, | |
| sha: str, | |
| run_id: int | None, | |
| ) -> bool: |
| for artifact in list_run_artifacts(repo, int(run_id)): | ||
| workflow_run = artifact.get("workflow_run") or {} | ||
| if "head_branch" not in workflow_run and run.get("headBranch"): | ||
| workflow_run["head_branch"] = run.get("headBranch") | ||
| if "head_sha" not in workflow_run and run.get("headSha"): | ||
| workflow_run["head_sha"] = run.get("headSha") | ||
| artifact["workflow_run"] = workflow_run | ||
| artifacts.append(artifact) |
There was a problem hiding this comment.
Optional: This block is duplicated in list_all_run_artifacts. Consider extracting to a helper function.
tophat-build-installskill for GitHub Actions artifact install via Tophat #648What happened 👀
tophat-build-installskill for GitHub Actions artifact install via Tophat.Insight 📝
I iterated to refine the scripts a few times, but they still look complex and intimidating. Also, I only tested with Codex; it would be appreciated if anyone could help validate the skill with other agent models, too, such as Claude, Copilot, etc. 🙏
Proof Of Work 📹
Install to simulator (Tested with Codex CLI with my old toy project)
Screen.Recording.2026-04-10.at.09.32.45.mp4
Summary by CodeRabbit
Release Notes
New Features
Documentation