Skip to content
Closed
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
92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: Install project
run: poetry install --no-interaction

- name: Run linting with ruff
run: |
poetry run ruff check .

- name: Run type checking with mypy
run: |
poetry run mypy src/

- name: Run unit tests
run: |
poetry run pytest test/ -v --ignore=test/test_openai_integration.py

- name: Run integration tests
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
poetry run pytest test/test_openai_integration.py -v -m integration

integration-test:
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: test

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies
run: |
poetry install --no-interaction

- name: Run OpenAI integration tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
poetry run pytest test/test_openai_integration.py -v -m integration --tb=short
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,59 @@ This project includes the following development tools:
### Running Tests

```bash
# Run all tests
# Run all tests (excluding integration tests)
poetry run pytest

# Run tests with coverage
poetry run pytest --cov=openhands_playground

# Run only unit tests (excluding integration tests)
poetry run pytest -m "not integration"

# Run integration tests (requires OPENAI_API_KEY environment variable)
poetry run pytest -m integration

# Run all tests including integration tests
poetry run pytest --run-integration
```

#### Integration Tests

Integration tests require a real OpenAI API key and make actual API calls. These tests are marked with the `@pytest.mark.integration` decorator and are skipped by default unless:

1. The `OPENAI_API_KEY` environment variable is set
2. You explicitly run integration tests with `-m integration`

To run integration tests locally:

```bash
# Set your OpenAI API key
export OPENAI_API_KEY="your-api-key-here"

# Run integration tests
poetry run pytest -m integration
```

**Note**: Integration tests will consume OpenAI API credits, so use them sparingly during development.

#### GitHub Actions and Secrets

This repository includes a GitHub Actions workflow (`.github/workflows/ci.yml`) that:

1. Runs unit tests, linting, and type checking on every push and pull request
2. Runs integration tests only on pushes to the main branch using GitHub secrets

To set up the OpenAI API key as a GitHub secret:

1. Go to your repository on GitHub
2. Navigate to Settings → Secrets and variables → Actions
3. Click "New repository secret"
4. Name: `OPENAI_API_KEY`
5. Value: Your OpenAI API key
6. Click "Add secret"

The integration tests will then run automatically when code is pushed to the main branch, using the secret API key without exposing it in logs or code.

### Code Quality

```bash
Expand Down
Loading
Loading