Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/script-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
chmod +x /usr/local/bin/yq

- name: Install test dependencies
run: uv pip install --system jsonschema==4.23.0 gitlint-core==0.19.1 PyYAML==6.0.3
run: uv pip install --system --group test

- name: Verify bundled scripts are up to date
run: make check-bundle
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ The agent never has direct write access to the repository. All mutations flow th

## Testing

Set up the Python test dependencies in a virtual environment:

```bash
uv venv .venv
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
uv pip install --python .venv/bin/python --group test
source .venv/bin/activate
```

Run all agent shell script test suites from the repo root:

```bash
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[dependency-groups]
test = [
"jsonschema==4.23.0",
"gitlint-core==0.19.1",
"PyYAML==6.0.3",
]
25 changes: 9 additions & 16 deletions scripts/post-fix-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ parse_script_test_args "$@"

FAILURES=0

# post-fix prepends ${HOME}/.local/bin to PATH, so a host-installed
Comment thread
ravelley marked this conversation as resolved.
Resolved
Comment thread
ravelley marked this conversation as resolved.
Resolved
# gitleaks/pre-commit would shadow the mocks; isolate HOME for the suite.
SUITE_HOME="$(mktemp -d)"
export HOME="${SUITE_HOME}"
Comment thread
ravelley marked this conversation as resolved.
Resolved
trap 'rm -rf "${SUITE_HOME}"' EXIT

# Git Data API calls from forge_push_branch are served from the bare remote
# by the mock gh scripts below.
export FAKE_GH_GIT_API="${SCRIPT_DIR}/test-fixtures/fake-gh-git-api.sh"
Expand Down Expand Up @@ -1911,14 +1917,9 @@ run_push_rebase_postfix() {
local human_instruction="${5:-}"
local conflict_strategy="${6:-}"
local exit_code=0
# post-fix puts ${HOME}/.local/bin first on PATH, so a host-installed
# pre-commit/gitleaks would shadow the mocks; isolate HOME per run.
local home_dir="${run_dir}/home"
mkdir -p "${home_dir}"
# shellcheck disable=SC2030,SC2031
(
cd "${run_dir}"
export HOME="${home_dir}"
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
export PATH="${mock_bin}:${PATH}"
export PUSH_TOKEN="fake-token"
export REPO_FULL_NAME="test-org/test-repo"
Expand Down Expand Up @@ -1997,10 +1998,6 @@ run_fix_push_retry_test() {
git -C "${base}/repo" add file.txt
git -C "${base}/repo" commit -q -m "fix: agent change"

# Isolate HOME so post-fix's PATH="${HOME}/.local/bin:${PATH}" cannot
# shadow this mock-bin with an unrelated `gh`/`git` from the developer host.
mkdir -p "${base}/home"

local mock_bin="${base}/mock-bin"
local push_log="${base}/push-calls.log"
mkdir -p "${mock_bin}"
Expand Down Expand Up @@ -2044,7 +2041,6 @@ MOCKEOF
unset MOCK_PUSH_FAIL
fi
export GITHUB_SIGNED_COMMITS=false
export HOME="${base}/home"
run_push_rebase_postfix "${base}" "${stdout_log}" "${mock_bin}"
) || exit_code=$?

Expand Down Expand Up @@ -6759,14 +6755,13 @@ run_prefix_budget_test() {
local expect_text="$6"
local labels_fail="${7:-}"
local base="${FIX_BUDGET_TMPDIR}/pre-${test_name}"
mkdir -p "${base}/workspace" "${base}/home"
mkdir -p "${base}/workspace"
local stdout_log="${base}/stdout.log"

local exit_code=0
# shellcheck disable=SC2030,SC2031
(
export PATH="${FIX_BUDGET_MOCK_BIN}:${PATH}"
export HOME="${base}/home"
export FULLSEND_FORGE="github"
export REPO_FULL_NAME="test-org/test-repo"
export PR_NUMBER="99"
Expand Down Expand Up @@ -6839,7 +6834,7 @@ run_prefix_budget_test "prefix-budget-label-read-failure-keeps-bot-cap" \
run_prefix_budget_gitlab_test() {
local test_name="prefix-budget-gitlab-blocks-bot-above-label"
local base="${FIX_BUDGET_TMPDIR}/pre-${test_name}"
mkdir -p "${base}/bin" "${base}/workspace" "${base}/home"
mkdir -p "${base}/bin" "${base}/workspace"
cat > "${base}/bin/curl" <<'MOCK'
#!/usr/bin/env bash
echo '{"labels":["area::api","fullsend-fix-budget/2"],"target_branch":"main","detailed_merge_status":"mergeable"}'
Expand All @@ -6850,7 +6845,6 @@ MOCK
# shellcheck disable=SC2030,SC2031
(
export PATH="${base}/bin:${PATH}"
export HOME="${base}/home"
export FULLSEND_FORGE="gitlab"
export CI_SERVER_HOST="gitlab.com"
export GITLAB_TOKEN="fake-token"
Expand Down Expand Up @@ -6887,7 +6881,7 @@ run_postfix_budget_test() {
local expect_summary="$5"
local expect_needs_human="$6"
local base="${FIX_BUDGET_TMPDIR}/post-${test_name}"
mkdir -p "${base}/repo" "${base}/home"
mkdir -p "${base}/repo"
git init -q -b main "${base}/repo"
git -C "${base}/repo" config user.email "test@example.com"
git -C "${base}/repo" config user.name "Test"
Expand All @@ -6901,7 +6895,6 @@ run_postfix_budget_test() {
(
cd "${base}"
export PATH="${FIX_BUDGET_MOCK_BIN}:${PATH}"
export HOME="${base}/home"
export GH_CALL_LOG="${gh_log}"
export PUSH_TOKEN="fake-token"
export REPO_FULL_NAME="test-org/test-repo"
Expand Down
Loading