Skip to content

ci: add integration test workflow #201

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

Merged
merged 9 commits into from
Jun 11, 2025
Merged
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
62 changes: 62 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Secure Integration test

on:
pull_request_target:
types: [opened, synchronize, labeled, unlabled, reopened]

jobs:
check-access-and-checkout:
runs-on: ubuntu-latest
permissions:
id-token: write
pull-requests: read
contents: read
steps:
- name: Check PR labels and author
id: check
uses: actions/github-script@v7
with:
script: |
const pr = context.payload.pull_request;

const labels = pr.labels.map(label => label.name);
const hasLabel = labels.includes('approved-for-integ-test')
if (hasLabel) {
core.info('PR contains label approved-for-integ-test')
return
}

const isOwner = pr.author_association === 'OWNER'
if (isOwner) {
core.info('PR author is an OWNER')
return
}

core.setFailed('Pull Request must either have label approved-for-integ-test or be created by an owner')
- name: Configure Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.STRANDS_INTEG_TEST_ROLE }}
aws-region: us-east-1
mask-aws-account-id: true
- name: Checkout base branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }} # Pull the commit from the forked repo
persist-credentials: false # Don't persist credentials for subsequent actions
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install --no-cache-dir hatch
- name: Run integration tests
env:
AWS_REGION: us-east-1
AWS_REGION_NAME: us-east-1 # Needed for LiteLLM
id: tests
run: |
hatch test tests-integ


4 changes: 1 addition & 3 deletions src/strands/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ def find_normalized_tool_name() -> Optional[str]:
# all tools that can be represented with the normalized name
if "_" in name:
filtered_tools = [
tool_name
for (tool_name, tool) in tool_registry.items()
if tool_name.replace("-", "_") == name
tool_name for (tool_name, tool) in tool_registry.items() if tool_name.replace("-", "_") == name
]

if len(filtered_tools) > 1:
Expand Down
4 changes: 1 addition & 3 deletions src/strands/telemetry/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@

from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter

# See https://github.com/open-telemetry/opentelemetry-python/issues/4615 for the type ignore
from opentelemetry.sdk.resources import Resource # type: ignore[attr-defined]
from opentelemetry.sdk.resources import Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter, SimpleSpanProcessor
from opentelemetry.trace import StatusCode
Expand Down
4 changes: 2 additions & 2 deletions tests-integ/test_bedrock_guardrails.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@pytest.fixture(scope="module")
def boto_session():
return boto3.Session(region_name="us-west-2")
return boto3.Session(region_name="us-east-1")


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -142,7 +142,7 @@ def test_guardrail_output_intervention_redact_output(bedrock_guardrail, processi
guardrail_stream_processing_mode=processing_mode,
guardrail_redact_output=True,
guardrail_redact_output_message=REDACT_MESSAGE,
region_name="us-west-2",
region_name="us-east-1",
)

agent = Agent(
Expand Down
6 changes: 6 additions & 0 deletions tests-integ/test_mcp_client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import base64
import os
import threading
import time
from typing import List, Literal

import pytest
from mcp import StdioServerParameters, stdio_client
from mcp.client.sse import sse_client
from mcp.client.streamable_http import streamablehttp_client
Expand Down Expand Up @@ -101,6 +103,10 @@ def test_can_reuse_mcp_client():
assert any([block["name"] == "echo" for block in tool_use_content_blocks])


@pytest.mark.skipif(
condition=os.environ.get("GITHUB_ACTIONS") == 'true',
reason="streamable transport is failing in GitHub actions, debugging if linux compatibility issue"
)
def test_streamable_http_mcp_client():
server_thread = threading.Thread(
target=start_calculator_server, kwargs={"transport": "streamable-http", "port": 8001}, daemon=True
Expand Down
2 changes: 1 addition & 1 deletion tests-integ/test_model_litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@pytest.fixture
def model():
return LiteLLMModel(model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0")
return LiteLLMModel(model_id="bedrock/anthropic.claude-3-7-sonnet-20250219-v1:0")


@pytest.fixture
Expand Down