diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4a29d4d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,73 @@ +name: CI + +on: + pull_request: + branches: [ main ] + push: + branches: [ main ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install black nox + - name: Run lint + run: nox -s lint + + tests: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.11", "3.12", "3.13"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install nox + - name: Run tests + run: nox -s tests-${{ matrix.python-version }} + + smoke-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install nox . + - name: Run smoke tests + run: nox -s smoke_tests + + llm-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install nox . google-genai + - name: Run LLM tests + env: + GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} + run: nox -s llm_tests diff --git a/ads_mcp/utils.py b/ads_mcp/utils.py index 2cdd939..497fa11 100644 --- a/ads_mcp/utils.py +++ b/ads_mcp/utils.py @@ -62,8 +62,6 @@ def _get_login_customer_id() -> str | None: def _get_googleads_client() -> GoogleAdsClient: - # Use this line if you have a google-ads.yaml file - # client = GoogleAdsClient.load_from_storage() args = { "credentials": _create_credentials(), "developer_token": _get_developer_token(), @@ -80,21 +78,18 @@ def _get_googleads_client() -> GoogleAdsClient: return client -_googleads_client = _get_googleads_client() - - def get_googleads_service(serviceName: str) -> GoogleAdsServiceClient: - return _googleads_client.get_service( + return _get_googleads_client().get_service( serviceName, interceptors=[MCPHeaderInterceptor()] ) def get_googleads_type(typeName: str): - return _googleads_client.get_type(typeName) + return _get_googleads_client().get_type(typeName) def get_googleads_client(): - return _googleads_client + return _get_googleads_client() def format_output_value(value: Any) -> Any: diff --git a/tests/utils_test.py b/tests/utils_test.py index c0737a2..d0cc507 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -28,7 +28,6 @@ class TestUtils(unittest.TestCase): def test_format_output_value(self): """Tests that output values are formatted correctly.""" - client = utils.get_googleads_client() self.assertEqual( utils.format_output_value( CampaignStatusEnum.CampaignStatus.ENABLED