Skip to content

Commit

Permalink
Reusable workflow for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ViStefan committed Nov 26, 2024
1 parent 81807d4 commit a8c429a
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 94 deletions.
54 changes: 7 additions & 47 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,15 @@ concurrency:
cancel-in-progress: true

jobs:
pre-test:
uses: ./.github/workflows/integration_test_workflow.yml

test:
environment: integration_test
strategy:
max-parallel: 1
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

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

- name: Install poetry
run: pip install -U poetry

- name: Configure poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry config installer.parallel true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Load test cache
uses: actions/cache@v4
with:
path: tests/itest_cache
key: tests-itest-cache
restore-keys: |
test-itest-cache
- name: Install extra dependencies
run: poetry run pip install -r requirements-extra.txt

- name: Install dependencies
run: poetry install --no-interaction --all-extras

- name: Run integration tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TIKTOKEN_CACHE_DIR: tests/itest_cache/tiktoken_cache
run: poetry run python tests/run_integration_tests.py --os ${{ runner.os }}
uses: ./.github/workflows/integration_test_workflow.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
52 changes: 5 additions & 47 deletions .github/workflows/integration_test_minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,12 @@ concurrency:

jobs:
test:
environment: integration_test
strategy:
max-parallel: 1
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

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

- name: Install poetry
run: pip install -U poetry

- name: Configure poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry config installer.parallel true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Load test cache
uses: actions/cache@v4
with:
path: tests/itest_cache
key: tests-itest-cache
restore-keys: |
test-itest-cache
- name: Install extra dependencies
run: poetry run pip install -r requirements-extra.txt

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

- name: Run integration tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TIKTOKEN_CACHE_DIR: tests/itest_cache/tiktoken_cache
run: poetry run python tests/run_integration_tests.py --minimal-only --os ${{ runner.os }}
uses: ./.github/workflows/integration_test_workflow.yml
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
minimal-only: true
76 changes: 76 additions & 0 deletions .github/workflows/integration_test_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Integration test workflow

on:
workflow_call:
inputs:
os:
default: ubuntu-latest
type: string
python-version:
default: "3.10"
type: string
minimal-only:
default: false
type: boolean

jobs:
integration_test:
environment: integration_test
runs-on: ${{ inputs.os }}
steps:
- uses: actions/checkout@v4

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

- name: Install poetry
run: pip install -U poetry

- name: Configure poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
poetry config installer.parallel true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Load test cache
uses: actions/cache@v4
with:
path: tests/itest_cache
key: integration-tests-cache
restore-keys: |
integration-tests-cache
- name: Install extra dependencies
run: poetry run pip install -r requirements-extra.txt

- name: Install minimal dependencies
if: inputs.minimal_only == 'true'
run: poetry install --no-interaction

- name: Install dependencies
if: inputs.minimal_only == 'false'
run: poetry install --no-interaction --all-extras

- name: Run minimal integration tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TIKTOKEN_CACHE_DIR: tests/itest_cache/tiktoken_cache
if: inputs.minimal_only == 'true'
run: poetry run python tests/run_integration_tests.py --minimal-only --os ${{ runner.os }}

- name: Run integration tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
TIKTOKEN_CACHE_DIR: tests/itest_cache/tiktoken_cache
if: inputs.minimal_only == 'false'
run: poetry run python tests/run_integration_tests.py --os ${{ runner.os }}

0 comments on commit a8c429a

Please sign in to comment.