diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d3dee93d..069e5633 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,9 @@ jobs: - name: Run unittest tests with coverage run: | pytest --cov=autogpt --without-integration --without-slow-integration --cov-report term-missing --cov-branch --cov-report xml --cov-report term - + pytest --cov=autogpt tests/integration/goal_oriented --cov-report term-missing --cov-branch --cov-report xml --cov-report term + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Generate coverage report run: | coverage report diff --git a/.github/workflows/goal_oriented_tasks.yml b/.github/workflows/goal_oriented_tasks.yml deleted file mode 100644 index 816b64ff..00000000 --- a/.github/workflows/goal_oriented_tasks.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Goal Oriented Tasks - -on: - push: - branches: - - master - pull_request: - branches: - - master - -jobs: - build: - runs-on: ubuntu-latest - - strategy: - matrix: - python-version: ['3.10'] - - steps: - - name: Check out repository - uses: actions/checkout@v3 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: Generate coverage report - run: | - coverage run --source=autogpt -m pytest -s -k tests/integration/goal_oriented - env: - OPENAI_API_KEY: 'dummy_api_key' diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..36233c18 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,5 @@ +from dotenv import load_dotenv + +load_dotenv() + +# Your other pytest configurations and fixtures diff --git a/tests/integration/goal_oriented/decorators.py b/tests/integration/goal_oriented/decorators.py new file mode 100644 index 00000000..9f35fc33 --- /dev/null +++ b/tests/integration/goal_oriented/decorators.py @@ -0,0 +1,14 @@ +import os +import pytest + + +def requires_openai_api_key(func): + def wrapper(*args, **kwargs): + if not os.environ.get('OPENAI_API_KEY'): + pytest.skip( + "Environment variable 'OPENAI_API_KEY' is not set, skipping the test." + ) + else: + return func(*args, **kwargs) + + return wrapper diff --git a/tests/integration/goal_oriented/test_write_file.py b/tests/integration/goal_oriented/test_write_file.py index 033c783b..55c51f20 100644 --- a/tests/integration/goal_oriented/test_write_file.py +++ b/tests/integration/goal_oriented/test_write_file.py @@ -13,6 +13,7 @@ from autogpt.memory import get_memory # from autogpt.prompt import Prompt from autogpt.workspace import WORKSPACE_PATH +from tests.integration.goal_oriented.decorators import requires_openai_api_key from tests.integration.goal_oriented.vcr_helper import before_record_request current_file_dir = os.path.dirname(os.path.abspath(__file__)) @@ -27,8 +28,11 @@ my_vcr = vcr.VCR( CFG = Config() +@requires_openai_api_key @pytest.mark.integration_test def test_write_file() -> None: + # Your test code here + # if file exist file_name = "hello_world.txt"