-
Notifications
You must be signed in to change notification settings - Fork 0
WIP #67
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
WIP #67
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| name: Integration Tests | ||
|
|
||
| on: | ||
| # Run on pushes to main branch | ||
| push: | ||
| branches: | ||
| - main | ||
| # Run on pull requests | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| # Allow manual trigger | ||
| workflow_dispatch: | ||
| # Optional: Run nightly | ||
vbvictor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # schedule: | ||
| # - cron: '0 2 * * *' # 2 AM UTC daily | ||
vbvictor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| jobs: | ||
| integration-test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| # Only run if INTEGRATION_TEST_TOKEN secret is set | ||
| if: ${{ secrets.INTEGRATION_TEST_TOKEN }} | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| pip install pytest | ||
|
|
||
| - name: Install GitHub CLI | ||
| run: | | ||
| type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y) | ||
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | ||
| sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg | ||
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | ||
| sudo apt update | ||
| sudo apt install gh -y | ||
|
|
||
| - name: Configure Git | ||
| run: | | ||
| git config --global user.name "ACP Integration Test" | ||
| git config --global user.email "[email protected]" | ||
|
|
||
| - name: Run integration tests | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.INTEGRATION_TEST_TOKEN }} | ||
| # Override these if your test repos are different | ||
| # ACP_TEST_ORG: acp-integration-test | ||
| # ACP_TEST_REPO: test-repo | ||
| # ACP_TEST_UPSTREAM: upstream-repo | ||
| # ACP_TEST_FORK_OWNER: test-user | ||
| run: | | ||
| pytest test_integration.py -v -m integration --tb=short | ||
|
|
||
| - name: Upload test results | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: integration-test-results | ||
| path: | | ||
| .pytest_cache/ | ||
| test-results/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| # Quick Start: Integration Tests | ||
|
|
||
| Simple guide to run integration tests with your test repository. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 1. ✅ Test repository created: `vbvictor/acp-integrational-testing` | ||
| 2. ✅ GitHub personal access token with `repo` scope | ||
| 3. ✅ `gh` CLI installed and authenticated | ||
|
|
||
| ## Step 1: Authenticate GitHub CLI | ||
|
|
||
| ```bash | ||
| gh auth login | ||
| # Follow prompts to authenticate | ||
| ``` | ||
|
|
||
| ## Step 2: Set Your GitHub Token | ||
|
|
||
| ```bash | ||
| export GITHUB_TOKEN=$(gh auth token) | ||
| ``` | ||
|
|
||
| Or use your personal token directly: | ||
| ```bash | ||
|
Check failure on line 25 in QUICKSTART_INTEGRATION.md
|
||
| export GITHUB_TOKEN="ghp_your_token_here" | ||
| ``` | ||
|
|
||
| ## Step 3: Run Integration Tests | ||
|
|
||
| ```bash | ||
| # Run all integration tests | ||
| pytest -m integration -v | ||
|
|
||
| # Run specific test | ||
| pytest test_integration.py::TestIntegrationNonFork::test_create_pr_interactive_non_fork -v -m integration | ||
|
|
||
| # Run with detailed output | ||
| pytest -m integration -v -s | ||
| ``` | ||
|
|
||
| ## What the Tests Do | ||
|
|
||
| 1. **test_create_pr_interactive_non_fork**: | ||
| - Clones your test repo | ||
| - Makes a change to `test_file.txt` | ||
| - Runs `acp pr` in interactive mode (`-i`) | ||
| - Verifies branch created | ||
| - Cleans up the branch | ||
|
|
||
| 2. **test_create_pr_non_fork**: | ||
| - Clones your test repo | ||
| - Makes a change | ||
| - Runs `acp pr` to auto-create PR with `gh` | ||
| - Verifies PR created | ||
| - Closes the PR and cleans up | ||
|
|
||
| 3. **test_verbose_output**: | ||
| - Tests verbose mode (`-v` flag) | ||
| - Verifies expected output messages | ||
|
|
||
| 4. **test_commit_with_hook**: | ||
| - Creates a pre-commit hook | ||
| - Verifies it runs successfully | ||
|
|
||
| ## Expected Output | ||
|
|
||
| ``` | ||
|
Check failure on line 68 in QUICKSTART_INTEGRATION.md
|
||
| test_integration.py::TestIntegrationNonFork::test_create_pr_interactive_non_fork PASSED | ||
| test_integration.py::TestIntegrationNonFork::test_create_pr_non_fork PASSED | ||
| test_integration.py::TestIntegrationVerbose::test_verbose_output PASSED | ||
| test_integration.py::TestIntegrationHooks::test_commit_with_hook PASSED | ||
|
|
||
| 4 passed in 15.23s | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### "GITHUB_TOKEN not set" | ||
|
Check failure on line 79 in QUICKSTART_INTEGRATION.md
|
||
| ```bash | ||
|
Check failure on line 80 in QUICKSTART_INTEGRATION.md
|
||
| echo $GITHUB_TOKEN # Should print your token | ||
| export GITHUB_TOKEN="your_token" | ||
| ``` | ||
|
|
||
| ### "Clone failed" | ||
|
Check failure on line 85 in QUICKSTART_INTEGRATION.md
|
||
| Make sure the repo exists: | ||
| ```bash | ||
|
Check failure on line 87 in QUICKSTART_INTEGRATION.md
|
||
| gh repo view vbvictor/acp-integrational-testing | ||
| ``` | ||
|
|
||
| ### Authentication errors | ||
|
Check failure on line 91 in QUICKSTART_INTEGRATION.md
|
||
| Re-authenticate: | ||
| ```bash | ||
|
Check failure on line 93 in QUICKSTART_INTEGRATION.md
|
||
| gh auth login | ||
| gh auth status | ||
| ``` | ||
|
|
||
| ### Tests leave branches | ||
|
Check failure on line 98 in QUICKSTART_INTEGRATION.md
|
||
| Clean up manually: | ||
| ```bash | ||
|
Check failure on line 100 in QUICKSTART_INTEGRATION.md
|
||
| # List branches | ||
| gh api repos/vbvictor/acp-integrational-testing/git/refs | grep acp | ||
|
|
||
| # Delete a branch | ||
| gh api -X DELETE repos/vbvictor/acp-integrational-testing/git/refs/heads/acp/vbvictor/123456 | ||
| ``` | ||
|
|
||
| ## Using Different Repository | ||
|
|
||
| If you want to use a different test repository: | ||
|
|
||
| ```bash | ||
| export ACP_TEST_REPO_FULL="your-username/your-test-repo" | ||
| pytest -m integration -v | ||
| ``` | ||
|
|
||
| ## Next Steps | ||
|
|
||
| Once these tests pass: | ||
| 1. ✅ Your `acp` tool works with real GitHub! | ||
| 2. You can add more test scenarios | ||
| 3. Later: set up fork testing (requires forking a repo) | ||
| 4. Later: add CI/CD (GitHub Actions) | ||
|
|
||
| ## Quick Commands | ||
|
|
||
| ```bash | ||
| # Run tests | ||
| export GITHUB_TOKEN=$(gh auth token) | ||
| pytest -m integration -v | ||
|
|
||
| # Clean up all test branches | ||
| gh api repos/vbvictor/acp-integrational-testing/git/refs \ | ||
| | jq -r '.[] | select(.ref | contains("acp/")) | .ref' \ | ||
| | while read ref; do | ||
| gh api -X DELETE "repos/vbvictor/acp-integrational-testing/git/$ref" | ||
| done | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Dockerfile for running acp integration tests | ||
| # | ||
| # Build: docker build -f docker/Dockerfile.integration -t acp-integration-test . | ||
| # Run: docker run --rm -e GITHUB_TOKEN=$GITHUB_TOKEN acp-integration-test | ||
|
|
||
| FROM python:3.11-slim | ||
|
|
||
| # Install system dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| git \ | ||
| curl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Install GitHub CLI | ||
| RUN curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
| && chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \ | ||
| && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ | ||
| && apt-get update \ | ||
| && apt-get install -y gh \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Set up working directory | ||
| WORKDIR /app | ||
|
|
||
| # Copy requirements (if any) and install Python dependencies | ||
| COPY requirements*.txt* ./ | ||
| RUN pip install --no-cache-dir pytest || true | ||
|
|
||
| # Copy application code | ||
| COPY acp.py . | ||
| COPY test_integration.py . | ||
| COPY test_acp.py . | ||
|
|
||
| # Set git configuration | ||
| RUN git config --global user.name "ACP Integration Test" \ | ||
| && git config --global user.email "[email protected]" | ||
|
|
||
| # Run integration tests by default | ||
| CMD ["pytest", "test_integration.py", "-v", "-m", "integration", "--tb=short"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Docker Setup for ACP Integration Tests | ||
|
|
||
| This directory contains Docker configuration for running ACP integration tests in an isolated environment. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ```bash | ||
| # Set your GitHub token | ||
| export GITHUB_TOKEN="your_github_token" | ||
|
|
||
| # Run tests with Docker Compose | ||
| docker-compose -f docker/docker-compose.integration.yml up --build | ||
| ``` | ||
|
|
||
| ## Files | ||
|
|
||
| - **Dockerfile.integration**: Docker image with Python, git, and gh CLI | ||
| - **docker-compose.integration.yml**: Compose configuration for easy test execution | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Building the Image | ||
|
|
||
| ```bash | ||
| docker build -f docker/Dockerfile.integration -t acp-integration-test . | ||
| ``` | ||
|
|
||
| ### Running Tests | ||
|
|
||
| **With Docker:** | ||
| ```bash | ||
| docker run --rm \ | ||
| -e GITHUB_TOKEN="$GITHUB_TOKEN" \ | ||
| -e ACP_TEST_ORG="your-test-org" \ | ||
| -e ACP_TEST_FORK_OWNER="your-username" \ | ||
| acp-integration-test | ||
| ``` | ||
|
|
||
| **With Docker Compose:** | ||
| ```bash | ||
| # Run all tests | ||
| docker-compose -f docker/docker-compose.integration.yml up | ||
|
|
||
| # Run specific test | ||
| docker-compose -f docker/docker-compose.integration.yml run --rm integration-test \ | ||
| pytest test_integration.py::TestIntegrationNonFork -v | ||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| - `GITHUB_TOKEN` (required): Your GitHub personal access token | ||
| - `ACP_TEST_ORG` (optional): Test organization name (default: acp-integration-test) | ||
| - `ACP_TEST_REPO` (optional): Non-fork test repo (default: test-repo) | ||
| - `ACP_TEST_UPSTREAM` (optional): Upstream repo for fork tests (default: upstream-repo) | ||
| - `ACP_TEST_FORK_OWNER` (optional): Fork owner username (default: test-user) | ||
|
|
||
| ## Development | ||
|
|
||
| The docker-compose setup mounts source files as read-only volumes, so you can edit code locally and re-run tests without rebuilding: | ||
|
|
||
| ```bash | ||
| # Edit acp.py or test_integration.py locally | ||
| vim acp.py | ||
|
|
||
| # Re-run tests (no rebuild needed) | ||
| docker-compose -f docker/docker-compose.integration.yml run --rm integration-test | ||
| ``` | ||
|
|
||
| For more information, see [docs/INTEGRATION_TESTING.md](../docs/INTEGRATION_TESTING.md). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| version: '3.8' | ||
|
|
||
| services: | ||
| integration-test: | ||
| build: | ||
| context: .. | ||
| dockerfile: docker/Dockerfile.integration | ||
| environment: | ||
| # Pass GitHub token from host environment | ||
| - GITHUB_TOKEN=${GITHUB_TOKEN} | ||
| # Optionally override test repository configuration | ||
| - ACP_TEST_ORG=${ACP_TEST_ORG:-acp-integration-test} | ||
| - ACP_TEST_REPO=${ACP_TEST_REPO:-test-repo} | ||
| - ACP_TEST_UPSTREAM=${ACP_TEST_UPSTREAM:-upstream-repo} | ||
| - ACP_TEST_FORK_OWNER=${ACP_TEST_FORK_OWNER:-test-user} | ||
| volumes: | ||
| # Mount source code for development | ||
| - ../acp.py:/app/acp.py:ro | ||
| - ../test_integration.py:/app/test_integration.py:ro | ||
| command: pytest test_integration.py -v -m integration --tb=short |
Uh oh!
There was an error while loading. Please reload this page.