Skip to content
Open
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
124 changes: 124 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Unified CI Workflow for ADK Python
#
# This workflow consolidates and replaces the following legacy workflows:
# - isort.yml (replaced by lint job's isort check)
# - python-unit-tests.yml (replaced by test job)
#
# The following workflows are intentionally kept separate:
# - mypy.yml: Manual-triggered multi-Python-version type checking
# - pyink.yml: Separate formatting check
# - Various release/* workflows: Release automation
# - Triaging/monitoring workflows: Project maintenance

name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Create virtual environment and install dependencies
run: |
uv venv .venv
source .venv/bin/activate
uv sync --all-extras
uv pip install ruff mypy build

- name: Run ruff lint check
run: |
source .venv/bin/activate
ruff check src/ tests/ --no-fix

- name: Run isort check
run: |
source .venv/bin/activate
isort --check src/ tests/ contributing/

- name: Run pyink format check
run: |
source .venv/bin/activate
pyink --check --diff --config pyproject.toml src/ tests/ contributing/

- name: Run mypy type check (transitional, to be removed by 2026-07-19)
continue-on-error: true
run: |
source .venv/bin/activate
mypy src/ --config-file pyproject.toml

test:
name: Test (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- name: Checkout code
uses: actions/checkout@v6

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

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Create virtual environment and install test dependencies
run: |
uv venv .venv
source .venv/bin/activate
uv sync --extra test

- name: Run unit tests with pytest
run: |
source .venv/bin/activate
pytest tests/unittests \
--ignore=tests/unittests/artifacts/test_artifact_service.py \
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py \
-v

build:
name: Build Package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"

- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Build the package
run: |
uv build

- name: Verify built artifacts
run: |
ls -la dist/
69 changes: 0 additions & 69 deletions .github/workflows/isort.yml

This file was deleted.

53 changes: 0 additions & 53 deletions .github/workflows/python-unit-tests.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.11
hooks:
- id: ruff
name: ruff-lint
args: [--fix]

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort-imports

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.15.0
hooks:
- id: mypy
name: mypy-type-check
args: [--config-file=pyproject.toml]
additional_dependencies:
- pydantic>=2.12.0
- typing-extensions>=4.5
exclude: ^(tests/|contributing/samples/)

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
name: trailing-whitespace-fixer
exclude_types: [markdown]
- id: end-of-file-fixer
name: end-of-file-fixer
- id: check-yaml
name: check-yaml-syntax
- id: check-toml
name: check-toml-syntax
- id: check-added-large-files
name: check-added-large-files
args: [--maxkb=1000]

- repo: local
hooks:
- id: pyink-format
name: pyink-format
entry: pyink --config pyproject.toml
language: system
types: [python]
34 changes: 32 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,43 @@ part before or alongside your code PR.
./autoformat.sh
```

7. **Build the wheel file:**
7. **Set up pre-commit hooks (recommended):**

The project uses pre-commit hooks to automate code quality checks.
Install and enable them with:

```shell
uv pip install pre-commit
pre-commit install
```

This will set up the following hooks that run automatically on every commit:
- `ruff`: Lint checking and automatic fixes (using configured rules)
- `isort`: Import organization (Google style)
- `pyink`: Code formatting (Google style, 2-space indent, 80 char line length)
- `mypy`: Type checking (**transitional state: currently allowed to fail, will be enforced by 2026-07-19**)
- `trailing-whitespace`: Removes trailing whitespace
- `end-of-file-fixer`: Ensures files end with a newline
- `check-yaml`: Validates YAML syntax
- `check-toml`: Validates TOML syntax
- `check-added-large-files`: Prevents adding large files (>1MB)

To manually run all hooks on all files:

```shell
pre-commit run --all-files
```

**Hook version management:** Run `pre-commit autoupdate` quarterly to update hooks
to their latest stable versions.

8. **Build the wheel file:**

```shell
uv build
```

8. **Test the locally built wheel file:** Have a simple testing folder setup as
9. **Test the locally built wheel file:** Have a simple testing folder setup as
mentioned in the
[quickstart](https://google.github.io/adk-docs/get-started/quickstart/).

Expand Down
Loading