Skip to content

[#648] Create tophat-build-install skill for GitHub Actions artifact install via Tophat#665

Open
Thieurom wants to merge 5 commits intodevelopfrom
feature/648-create-tophat-build-install-agent-skill
Open

[#648] Create tophat-build-install skill for GitHub Actions artifact install via Tophat#665
Thieurom wants to merge 5 commits intodevelopfrom
feature/648-create-tophat-build-install-agent-skill

Conversation

@Thieurom
Copy link
Copy Markdown

@Thieurom Thieurom commented Apr 8, 2026

What happened 👀

  • Created tophat-build-install skill 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

    • Added a new GitHub Actions-based build and install skill that enables discovering, selecting, and deploying artifacts across platforms and devices.
  • Documentation

    • Added comprehensive skill documentation and public contract reference defining the artifact management workflow and integration behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

This PR introduces the tophat-build-install skill, enabling developers to install GitHub Actions artifacts via Tophat. It includes skill documentation, public contract specification, and five Python scripts for repository inference, artifact discovery, recipe generation, and Tophat invocation.

Changes

Cohort / File(s) Summary
Skill Documentation
skills/tophat-build-install/SKILL.md, skills/tophat-build-install/references/public-contract.md
Defines the skill's end-to-end control flow, input collection rules, artifact selection precedence, and public contract for Tophat recipe configuration and GitHub Actions provider behavior.
Artifact Discovery
skills/tophat-build-install/scripts/gha.py
Implements list-artifacts CLI command to query GitHub Actions artifacts via gh, supporting filtering by workflow run, branch, commit SHA, or PR reference. Handles API 404 fallback to enumerate recent workflow runs and filters expired artifacts.
Recipe Generation & Installation
skills/tophat-build-install/scripts/make_recipe.py, skills/tophat-build-install/scripts/install_artifact.py, skills/tophat-build-install/scripts/install_with_tophat.py
Provides three complementary CLI tools: recipe generation with provider parameter validation, artifact installation wrapper that builds and invokes recipes with colorized output, and Tophat CLI invocation with timeout-as-pending interpretation and artifact cleanup.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Suggested labels

type : feature

Suggested reviewers

  • minhnimble
  • roman-nimble
  • vnntsu
  • kevinhoangpq
  • patcharapon-j
  • nhgia

Poem

🐰 A skill hops forth to fetch and build,
From GitHub Actions artifacts spilled,
Through Tophat's gha provider it flows,
No stashing or branches—just installs the prose!
Artifacts listed, recipes made, installs deployed,
All in one bound—no developers annoyed! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: creating a new tophat-build-install skill for installing GitHub Actions artifacts via Tophat, with the issue number reference.
Description check ✅ Passed The PR description addresses the template's main sections with relevant information about what was created, insights about implementation complexity and testing scope, and proof-of-work video. However, it lacks detailed explanation of the solution approach and alternative approaches considered.
Linked Issues check ✅ Passed All acceptance criteria from issue #648 are met: owner/repo inference via git, GitHub Actions/gh CLI only, gha provider usage, explicit artifact_id install, non-expired artifact listing, expired artifact filtering, existing artifact preference, workflow triggering, and iOS simulator/device support.
Out of Scope Changes check ✅ Passed All changes are scoped to the new tophat-build-install skill directory: documentation, scripts for artifact listing/recipe creation/installation, and references. No modifications to unrelated components or out-of-scope files detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/648-create-tophat-build-install-agent-skill

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Thieurom Thieurom self-assigned this Apr 8, 2026
@Thieurom Thieurom force-pushed the feature/648-create-tophat-build-install-agent-skill branch 2 times, most recently from 100182c to e9eb621 Compare April 9, 2026 10:10
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
skills/tophat-build-install/scripts/gha.py (1)

169-209: Consider extracting duplicated artifact metadata patching logic.

The list_matching_run_artifacts and list_all_run_artifacts functions share identical logic for patching workflow_run metadata 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

📥 Commits

Reviewing files that changed from the base of the PR and between f874a7b and 2f877d8.

📒 Files selected for processing (6)
  • skills/tophat-build-install/SKILL.md
  • skills/tophat-build-install/references/public-contract.md
  • skills/tophat-build-install/scripts/gha.py
  • skills/tophat-build-install/scripts/install_artifact.py
  • skills/tophat-build-install/scripts/install_with_tophat.py
  • skills/tophat-build-install/scripts/make_recipe.py

Comment on lines +222 to +228
def artifact_matches(
artifact: dict[str, Any],
ref: str,
sha: str,
run_id: int | None,
platform: str,
) -> bool:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Image
Suggested change
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:

Copy link
Copy Markdown
Contributor

@ducbm051291 ducbm051291 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest LGTM

Copy link
Copy Markdown
Contributor

@thinh2k1310 thinh2k1310 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! The skill works as expected 💯
Image

Comment on lines +180 to +187
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: This block is duplicated in list_all_run_artifacts. Consider extracting to a helper function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create tophat-build-install skill for GitHub Actions artifact install via Tophat

3 participants