Skip to content

feat: portable GH_AW_HOME for self-hosted runner support#19744

Open
Mossaka wants to merge 17 commits intomainfrom
portable-gh-aw-home
Open

feat: portable GH_AW_HOME for self-hosted runner support#19744
Mossaka wants to merge 17 commits intomainfrom
portable-gh-aw-home

Conversation

@Mossaka
Copy link
Collaborator

@Mossaka Mossaka commented Mar 5, 2026

Summary

  • Replace all hardcoded /opt/gh-aw/ paths with a GH_AW_HOME environment variable (defaults to /opt/gh-aw, falls back to $RUNNER_TEMP/gh-aw on self-hosted runners)
  • setup.sh auto-detects a writable path and exports GH_AW_HOME to $GITHUB_ENV for all subsequent steps
  • Shell contexts use ${GH_AW_HOME:-/opt/gh-aw}/..., JS require() uses (process.env.GH_AW_HOME || '/opt/gh-aw') + '/...'
  • All 165 lock files recompiled with new path patterns

Why: GitHub-hosted runners allow writing to /opt/, but self-hosted runners typically don't — requiring admins to sudo mkdir -p /opt/gh-aw && sudo chmod 777 /opt/gh-aw. This change makes gh-aw work out of the box on both.

Security: $RUNNER_TEMP/gh-aw is NOT mounted into the AWF agent container (only $GITHUB_WORKSPACE and /tmp are writable to the agent), so the security model is preserved.

Test plan

  • make build succeeds
  • make test-unit — all tests pass (updated 36 test files + 3 golden fixtures)
  • make test-js — all 209 JS test files pass (4928 tests)
  • make golint-incremental BASE_REF=HEAD — 0 issues
  • make recompile — all 165 lock files regenerated
  • Verified compiled .lock.yml files use $GH_AW_HOME patterns correctly
  • Smoke test on GitHub-hosted runner (backward compat: default /opt/gh-aw still works)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 5, 2026 18:21
Mossaka and others added 6 commits March 5, 2026 18:57
Add OpenCode as a new agentic engine supporting provider-agnostic AI
coding with BYOK (Bring Your Own Key) and full MCP Gateway + API proxy
support.

New engine features:
- Provider-agnostic: supports Anthropic, OpenAI, Google, Groq, etc.
- Dynamic domain allowlists based on model provider prefix
- API proxy on port 10004 (default: Anthropic routing)
- MCP Gateway integration with opencode.jsonc converter
- Headless CI mode via `opencode run -q`
- Auto-configured permissions to prevent CI hanging
- 22 unit tests covering all engine methods
- Smoke test workflow (5 tests)

Files: opencode_engine.go, opencode_mcp.go, opencode_engine_test.go,
convert_gateway_config_opencode.sh, smoke-opencode.md/.lock.yml

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add comprehensive external-facing documentation for the OpenCode engine:
- New guide: docs/src/content/docs/guides/opencode.md (460 lines)
  - Quick start, auth/providers, network security, MCP support
  - Example workflows, engine comparison, known limitations
- Update engines.md: add OpenCode to available agents list
- Update auth.mdx: add OpenCode authentication reference
- Update network.md: add OpenCode domain config + dynamic provider docs
- Update astro.config.mjs: add sidebar link

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix BaseEngine struct changes (llmGatewayPort field, remove
  supportsFirewall, remove UsesAPIProxy from AWFCommandConfig)
- Bump DefaultFirewallVersion to v0.23.1 which includes port 10004
  for OpenCode API proxy (gh-aw-firewall#1055)
- Recompile smoke-opencode.lock.yml with v0.23.1
- Fix test: use constants.OpenCodeLLMGatewayPort assertion

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
OpenCode v1.2.14 does not support -q/--quiet flag. The `run` subcommand
accepts the message as a positional argument directly. Discovered from
smoke test failure where the CLI printed usage and exited with code 1.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Mossaka Mossaka added the smoke label Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

❌ Tool validation failed! Agent Container Smoke Test detected missing tools: failed

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Mossaka and others added 3 commits March 5, 2026 19:28
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
OpenCode phones home to opencode.ai during initialization (telemetry/
config). Without this domain in the allowlist, Squid blocks the request
and OpenCode fails silently with exit code 0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…xpansion

Re-applies all GH_AW_HOME portable path changes that were silently reverted
during the merge with main. Also fixes a critical bug where job-level env
vars using shell expansion syntax were not expanded by GitHub Actions
${{ env.X }} expressions (used by upload-artifact).

Key fixes:
- Move GH_AW_SAFE_OUTPUTS/CONFIG_PATH/TOOLS_PATH from job-level env to
  $GITHUB_ENV (set in "Create gh-aw temp directory" step after setup.sh
  sets GH_AW_HOME)
- Re-apply JsRequireGhAw() for all require() patterns
- Re-apply GhAwHome shell expansion for all bash run: blocks
- Re-apply DefaultGhAwMount with shell expansion
- Update golden files and test expectations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Mossaka Mossaka force-pushed the portable-gh-aw-home branch from 192debf to 42c1f84 Compare March 5, 2026 19:49
Mossaka and others added 2 commits March 5, 2026 19:54
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@pelikhan
Copy link
Contributor

pelikhan commented Mar 6, 2026

@copilot recompile, review code and simplify if possible (by compile resolved value and avoid repeating magic string)

Copy link
Contributor

Copilot AI commented Mar 6, 2026

@pelikhan I've opened a new pull request, #19793, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 2 commits March 5, 2026 19:34
…constants (#19793)

* Initial plan

* Initial plan: use GhAwHome/GhAwHomeJS/JsRequireGhAw constants everywhere

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

* refactor: replace magic GH_AW_HOME path strings with constants/helpers

Replace all raw occurrences of `(process.env.GH_AW_HOME || '/opt/gh-aw')`
and `${GH_AW_HOME:-/opt/gh-aw}` in non-test Go source files with the
constants and helper defined in setup_action_paths.go:
- `GhAwHomeJS` for JavaScript expressions
- `GhAwHome` for shell expressions
- `JsRequireGhAw(relativePath)` for JS require() calls

22 source files updated. Generated output is byte-for-byte identical.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
Copy link
Contributor

pelikhan commented Mar 6, 2026

@copilot fix build wasm

Copy link
Contributor

Copilot AI commented Mar 6, 2026

@pelikhan I've opened a new pull request, #19798, to work on those changes. Once the pull request is ready, I'll request review from you.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

Hey @Mossaka 👋 — thanks for this ambitious PR! The work on self-hosted runner support (GH_AW_HOME) is a real quality-of-life improvement, and the OpenCode engine integration looks well thought-out with solid test coverage.

That said, there are a couple of things to address before this is ready:

⚠️ Unfocused diff — two unrelated features in one PR

This PR bundles together two distinct features:

  1. GH_AW_HOME portability — replacing hardcoded /opt/gh-aw/ paths with a ${GH_AW_HOME:-/opt/gh-aw} shell expression across pkg/workflow/setup_action_paths.go, prompt_constants.go, 165 lock files, and the setup.sh auto-detection logic.
  2. OpenCode engine integration — a brand-new engine in pkg/workflow/opencode_engine.go (+303 lines), pkg/workflow/opencode_mcp.go (+71 lines), pkg/workflow/opencode_engine_test.go (+369 lines), pkg/workflow/domains.go (+73 lines), and a new changeset entry (patch-add-opencode-engine.md).

These are independent, reviewable changes. Mixing them makes it hard for reviewers to reason about correctness of either feature in isolation, and harder to revert one without the other if an issue comes up.

🔲 Smoke test not yet complete

The test plan has one unchecked item: "Smoke test on GitHub-hosted runner (backward compat: default /opt/gh-aw still works)". The existing smoke label confirms this is still pending.


Suggested split

PR Scope
PR A GH_AW_HOME portability — setup_action_paths.go, prompt_constants.go, shell/JS constants, recompiled lock files
PR B OpenCode engine — opencode_engine.go, opencode_mcp.go, tests, domains.go allowlists, changeset

If you'd like a hand splitting and validating this, you can assign the prompt below to your coding agent:

Split PR #19744 in the github/gh-aw repo into two focused PRs:

**PR A — GH_AW_HOME portability (self-hosted runner support)**
Cherry-pick only the changes related to replacing hardcoded /opt/gh-aw paths:
- pkg/workflow/setup_action_paths.go (GhAwHome / GhAwHomeJS constants)
- pkg/workflow/prompt_constants.go (promptsDir change)
- All .github/workflows/*.lock.yml files (path pattern updates)
- actions/setup/sh/*.sh scripts that export GH_AW_HOME
- Any GH_AW_HOME-related test changes
- Rerun `make recompile` to regenerate lock files from the updated source

**PR B — OpenCode engine integration**
Cherry-pick only the changes related to the new OpenCode engine:
- pkg/workflow/opencode_engine.go (new file)
- pkg/workflow/opencode_mcp.go (new file)
- pkg/workflow/opencode_engine_test.go (new file)
- pkg/workflow/domains.go (allowlist additions)
- pkg/workflow/agentic_engine.go (engine registration, if any)
- .changeset/patch-add-opencode-engine.md
- Any OpenCode-specific documentation under docs/src/

For each PR:
1. Create a new branch from main
2. Cherry-pick the relevant commits or selectively stage the files
3. Run `make agent-finish` to verify build, tests, lint, and recompile pass
4. Ensure the PR description includes a complete test plan with all items checked
5. For PR A, confirm backward-compat smoke test on a GitHub-hosted runner passes before marking ready

Generated by Contribution Check ·

@pelikhan
Copy link
Contributor

pelikhan commented Mar 6, 2026

@copilot merge main and recompile

Copy link
Contributor

Copilot AI commented Mar 6, 2026

@pelikhan I've opened a new pull request, #19817, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

@copilot define an environment variable on the job level to avoid repeating the macro everywhere

Copy link
Contributor

Copilot AI commented Mar 6, 2026

@pelikhan I've opened a new pull request, #19823, to work on those changes. Once the pull request is ready, I'll request review from you.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants