Skip to content

Commit

Permalink
test: Amazon Bedrock - skip integration tests from forks (#801)
Browse files Browse the repository at this point in the history
* try skipping integration tests from forks

* make it work on windows

* skip mistral tests when HF token is not set

* add windows step

* separate unit and int tests

* refinement

* format
  • Loading branch information
anakin87 authored Jun 11, 2024
1 parent 4821ff3 commit eb0722b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/amazon_bedrock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,23 @@ jobs:
if: matrix.python-version == '3.9' && runner.os == 'Linux'
run: hatch run docs

- name: AWS authentication
- name: Run unit tests
id: unit-tests
run: hatch run cov -m "not integration"

# Do not authenticate on pull requests from forks
- name: AWS authentication
if: github.event.pull_request.head.repo.full_name == github.repository
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_CI_ROLE_ARN }}

- name: Run tests
id: tests
run: hatch run cov
# Do not run integration tests on pull requests from forks
- name: Run integration tests
if: github.event.pull_request.head.repo.full_name == github.repository
id: integration-tests
run: hatch run cov -m "integration"

- name: Nightly - run unit tests with Haystack main branch
if: github.event_name == 'schedule'
Expand Down
8 changes: 8 additions & 0 deletions integrations/amazon_bedrock/tests/test_chat_generator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Optional, Type

import pytest
Expand Down Expand Up @@ -182,6 +183,13 @@ def test_prepare_body_with_custom_inference_params(self) -> None:
assert body == expected_body


@pytest.mark.skipif(
not os.environ.get("HF_API_TOKEN", None),
reason=(
"To run this test, you need to set the HF_API_TOKEN environment variable. The associated account must also "
"have requested access to the gated model `mistralai/Mistral-7B-Instruct-v0.1`"
),
)
class TestMistralAdapter:
def test_prepare_body_with_default_params(self) -> None:
layer = MistralChatAdapter(generation_kwargs={})
Expand Down

0 comments on commit eb0722b

Please sign in to comment.