SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
CI: Use github token during CI operations (#412)
Kilian Lieret6791e9a38fa8
diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yamlindex 25f08790..32ab08d4 100644--- a/.github/workflows/pytest.yaml+++ b/.github/workflows/pytest.yaml@@ -1,6 +1,9 @@name: Pytest+env:+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}+on:push:branches:diff --git a/tests/test_run.py b/tests/test_run.pyindex 2365cc09..9b663ae0 100644--- a/tests/test_run.py+++ b/tests/test_run.py@@ -1,4 +1,5 @@import json+import osfrom pathlib import Pathimport subprocessfrom typing import Any, Dict@@ -22,8 +23,7 @@ def test_run_cli_help():@pytest.fixturedef open_pr_hook_init_for_sop():hook = OpenPRHook()- hook._token = ""- hook._env = None+ hook._token = os.environ.get("GITHUB_TOKEN", "")hook._data_path = "https://github.com/klieret/swe-agent-test-repo/issues/1"hook._open_pr = Truehook._skip_if_commits_reference_issue = Truediff --git a/tests/test_utils.py b/tests/test_utils.pyindex 24c72cc4..8c5edb4f 100644--- a/tests/test_utils.py+++ b/tests/test_utils.py@@ -1,8 +1,12 @@import hashlib+import osimport subprocessimport pytestfrom sweagent.environment.utils import InvalidGithubURL, format_trajectory_markdown, _MARKDOWN_TRAJECTORY_EMOJI_MAPPING, get_instances, is_github_repo_url, remove_triple_backticks, parse_gh_repo_url, parse_gh_issue_url, is_github_issue_url, get_associated_commit_urls++_TOKEN = {"token": os.environ.get("GITHUB_TOKEN", "")}+def test_format_trajectory_markdown(test_trajectory):formatted = format_trajectory_markdown(test_trajectory["trajectory"])assert formatted.startswith("<details>")@@ -63,13 +67,14 @@ def test_get_associated_commit_urls():assoc = get_associated_commit_urls(org="princeton-nlp",repo="SWE-agent",- issue_number="41"+ issue_number="41",+ token=os.environ.get("GITHUB_TOKEN", ""))assert len(assoc) > 0def test_get_instance_gh_issue():- instance = get_instances("https://github.com/klieret/swe-agent-test-repo/issues/1")[0]+ instance = get_instances("https://github.com/klieret/swe-agent-test-repo/issues/1", **_TOKEN)[0]compare_with = {'repo': 'klieret/swe-agent-test-repo','instance_id': 'klieret__swe-agent-test-repo-i1',@@ -92,6 +97,7 @@ def test_get_instance_gh_issue_local_repo(tmp_path):instance = get_instances(file_path="https://github.com/klieret/swe-agent-test-repo/issues/1",repo_path=str(tmp_path / "swe-agent-test-repo"),+ **_TOKEN)[0]compare_with = {'repo': str(tmp_path.resolve() / "swe-agent-test-repo"),@@ -129,6 +135,7 @@ def test_get_instance_gh_issue_gh_repo(tmp_path):instance = get_instances(file_path="https://github.com/klieret/swe-agent-test-repo/issues/1",repo_path="https://github.com/princeton-nlp/SWE-agent",+ **_TOKEN)[0]compare_with = {'repo': "princeton-nlp/SWE-agent",@@ -146,6 +153,7 @@ def test_get_instance_text_issue_gh_repo(tmp_path):instance = get_instances(file_path="text://this is a test",repo_path="https://github.com/princeton-nlp/SWE-agent",+ **_TOKEN)[0]compare_with = {'repo': "princeton-nlp/SWE-agent",@@ -162,4 +170,4 @@ def test_load_instances(test_data_path, caplog):test_data_sources = test_data_path / "data_sources"examples = list(test_data_sources.iterdir())for example in examples:- get_instances(file_path=str(example))\ No newline at end of file+ get_instances(file_path=str(example), **_TOKEN)\ No newline at end of file