Skip to content
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
47 changes: 47 additions & 0 deletions .github/workflows/publish_garf_google_ads.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish to PyPI - garf-google-ads

on:
push:
branches:
- main
paths:
- 'libs/community/google/ads/**'
- '!libs/community/google/ads/*.md'

jobs:
publish:
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v4

- name: Get versions and check for change
id: version_check
run: |
PREV_VERSION=$(git show HEAD~1:libs/community/google/ads/garf_google_ads/__init__.py | grep -oE "__version__ = '([0-9]+\.[0-9]+\.[0-9]+)'" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
CURRENT_VERSION=$(grep -oE "__version__ = '([0-9]+\.[0-9]+\.[0-9]+)'" libs/community/google/ads/garf_google_ads/__init__.py | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')

if [[ "$CURRENT_VERSION" != "$PREV_VERSION" ]]; then
echo "Version change detected: $PREV_VERSION -> $CURRENT_VERSION"
echo "should_publish=true" >> $GITHUB_OUTPUT
echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
else
echo "No version change. Skipping publish."
echo "should_publish=false" >> $GITHUB_OUTPUT
fi

- name: Build the package
if: steps.version_check.outputs.should_publish == 'true'
run: uv build libs/community/google/ads/

- name: Publish to PyPI
if: steps.version_check.outputs.should_publish == 'true'
run: uv publish libs/community/google/ads/dist/*
34 changes: 34 additions & 0 deletions .github/workflows/test_garf_google_ads.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run tests for garf-google-ads

on:
workflow_dispatch:
pull_request:
branches: [main]
paths:
- 'libs/community/google/ads/garf_google_ads/**'

env:
UV_SYSTEM_PYTHON: 1

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.4"
enable-cache: true
- name: Install dependencies
run: |
uv pip install pytest
- name: Test ${{ matrix.library }}
run: |
cd libs/community/google/ads/
uv pip install -e .
pytest tests/unit
2 changes: 1 addition & 1 deletion libs/community/google/ads/garf_google_ads/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
'GoogleAdsApiReportFetcher',
]

__version__ = '0.0.1'
__version__ = '0.0.2'
23 changes: 16 additions & 7 deletions libs/community/google/ads/garf_google_ads/report_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ def fetch(
customer_ids_query: str | None = None,
**kwargs: str,
) -> garf_core.GarfReport:
"""Fetches data from Google Ads API.

Args:
query_specifiction: Query to execute.
args: Optional parameters to fine-tune the query.
account: Account(s) to get data from.
expand_mcc: Whether to perform account expansion (MCC to Account).
custom_ids_query: Query to reduce number of accounts based a condition.

Returns:
Fetched report for provided accounts.
"""
if isinstance(account, str):
account = account.split(',')
if not args:
Expand Down Expand Up @@ -102,14 +114,11 @@ def expand_mcc(
"""Performs Manager account(s) expansion to child accounts.

Args:
customer_ids:
Manager account(s) to be expanded.
customer_ids_query:
Garf query to limit the expansion only to accounts
satisfying the condition.
customer_ids: Manager account(s) to be expanded.
customer_ids_query: GAQL query used to reduce the number of customer_ids.

Returns:
All child accounts under provided customer_ids.
All child accounts under provided customer_ids.
"""
return self._get_customer_ids(
seed_customer_ids=customer_ids, customer_ids_query=customer_ids_query
Expand All @@ -127,7 +136,7 @@ def _get_customer_ids(
customer_ids_query: GAQL query used to reduce the number of customer_ids.

Returns:
All customer_ids from MCC satisfying the condition.
All customer_ids from MCC satisfying the condition.
"""
query = """
SELECT customer_client.id FROM customer_client
Expand Down
5 changes: 5 additions & 0 deletions libs/community/google/ads/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies = [
"garf-core",
"garf-io",
"google-ads",
"tenacity",
]
authors = [
{name = "Andrei Markin", email = "[email protected]"},
Expand Down Expand Up @@ -36,3 +37,7 @@ test = [
"pytest-cov",
"python-dotenv",
]

[[tool.uv.index]]
url = "https://pypi.org/simple"
default = true