-
Notifications
You must be signed in to change notification settings - Fork 213
Add support for EXTENSIONS_REF environment variable #2607
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
juanmichelini
merged 10 commits into
main
from
openhands/allow-extensions-branch-selection
Apr 9, 2026
+105
−3
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2c8fa42
Add support for EXTENSIONS_REF environment variable
openhands-agent b03fcb3
Add extensions_branch parameter to run-eval workflow
openhands-agent 810a05c
Merge main into openhands/allow-extensions-branch-selection
openhands-agent ec22083
Merge branch 'main' into openhands/allow-extensions-branch-selection
juanmichelini 490f9f3
Merge branch 'main' into openhands/allow-extensions-branch-selection
juanmichelini 9af4731
Fix line too long in test_extensions_ref.py
openhands-agent 46a057d
Fix test to verify branch passed to update_skills_repository
openhands-agent 9e88123
Merge branch 'main' into openhands/allow-extensions-branch-selection
juanmichelini d088cfa
Merge branch 'main' into openhands/allow-extensions-branch-selection
juanmichelini 41dce05
Fix test isolation using subprocess to avoid env pollution
openhands-agent 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| """Tests for EXTENSIONS_REF environment variable support. | ||
|
|
||
| These tests use subprocess to run each test in an isolated Python process, | ||
| avoiding module state pollution that would affect other tests. | ||
| """ | ||
|
|
||
| import subprocess | ||
| import sys | ||
|
|
||
|
|
||
| def _run_in_subprocess(test_code: str, env_extra: dict | None = None) -> None: | ||
| """Run test code in a subprocess with the given environment variables.""" | ||
| import os | ||
|
|
||
| env = os.environ.copy() | ||
| if env_extra: | ||
| env.update(env_extra) | ||
|
|
||
| result = subprocess.run( | ||
| [sys.executable, "-c", test_code], | ||
| env=env, | ||
| capture_output=True, | ||
| text=True, | ||
| ) | ||
| if result.returncode != 0: | ||
| raise AssertionError( | ||
| f"Subprocess test failed:\nstdout: {result.stdout}\nstderr: {result.stderr}" | ||
| ) | ||
|
|
||
|
|
||
| def test_extensions_ref_default(): | ||
| """PUBLIC_SKILLS_BRANCH should default to 'main' when EXTENSIONS_REF is not set.""" | ||
| code = """ | ||
| import os | ||
| if "EXTENSIONS_REF" in os.environ: | ||
| del os.environ["EXTENSIONS_REF"] | ||
| from openhands.sdk.context.skills.skill import PUBLIC_SKILLS_BRANCH | ||
| assert PUBLIC_SKILLS_BRANCH == "main", ( | ||
| f"Expected 'main' but got '{PUBLIC_SKILLS_BRANCH}'" | ||
| ) | ||
| """ | ||
| _run_in_subprocess(code) | ||
|
|
||
|
|
||
| def test_extensions_ref_custom_branch(): | ||
| """PUBLIC_SKILLS_BRANCH should use EXTENSIONS_REF when set.""" | ||
| code = """ | ||
| from openhands.sdk.context.skills.skill import PUBLIC_SKILLS_BRANCH | ||
| assert PUBLIC_SKILLS_BRANCH == "feature-branch", ( | ||
| f"Expected 'feature-branch' but got '{PUBLIC_SKILLS_BRANCH}'" | ||
| ) | ||
| """ | ||
| _run_in_subprocess(code, {"EXTENSIONS_REF": "feature-branch"}) | ||
|
|
||
|
|
||
| def test_extensions_ref_with_load_public_skills(): | ||
| """load_public_skills should respect EXTENSIONS_REF environment variable.""" | ||
| code = """ | ||
| from unittest import mock | ||
| from openhands.sdk.context.skills.skill import ( | ||
| PUBLIC_SKILLS_BRANCH, | ||
| load_public_skills, | ||
| ) | ||
| assert PUBLIC_SKILLS_BRANCH == "test-branch", ( | ||
| f"Expected 'test-branch' but got '{PUBLIC_SKILLS_BRANCH}'" | ||
| ) | ||
| with mock.patch( | ||
| "openhands.sdk.context.skills.skill.update_skills_repository" | ||
| ) as mock_update: | ||
| mock_update.return_value = None | ||
| load_public_skills() | ||
| mock_update.assert_called_once() | ||
| call_args = mock_update.call_args | ||
| # branch is 2nd positional arg: (repo_url, branch, cache_dir) | ||
| assert call_args[0][1] == "test-branch", ( | ||
| f"Expected branch='test-branch' but got {call_args[0][1]}" | ||
| ) | ||
| """ | ||
| _run_in_subprocess(code, {"EXTENSIONS_REF": "test-branch"}) | ||
|
|
||
|
|
||
| def test_extensions_ref_empty_string(): | ||
| """Empty EXTENSIONS_REF should fall back to 'main'.""" | ||
| code = """ | ||
| from openhands.sdk.context.skills.skill import PUBLIC_SKILLS_BRANCH | ||
| # Empty string returns empty string per os.environ.get behavior | ||
| assert PUBLIC_SKILLS_BRANCH == "", ( | ||
| f"Expected '' but got '{PUBLIC_SKILLS_BRANCH}'" | ||
| ) | ||
| """ | ||
| _run_in_subprocess(code, {"EXTENSIONS_REF": ""}) |
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.
Uh oh!
There was an error while loading. Please reload this page.