15 Commits

Author SHA1 Message Date
George Weale 74e7167d13 fix(ci): run the update-constraints hook in check mode
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 962546379
2026-08-10 21:28:52 -07:00
Xuan Yang 942b38df34 feat: enforce unit guide requirement for new Python files
Update check_new_py_files.sh pre-commit check to enforce that all newly added Python source files require a corresponding unit guide in docs/guides/.

Allows authors to bypass the check when appropriate by adding a NO_UNIT_GUIDE tag to the commit message or changelist description.

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 960581639
2026-08-06 17:05:02 -07:00
Amy Wu 75c773ed9d feat: Publish companion constraints-3.11.txt and constraints-3.12.txt file for transitive dependency protection (4 day buffer to protect from supply chain attack)
For example, use pip install google-adk -c constraints-3.12.txt

PiperOrigin-RevId: 954863904
2026-07-27 15:33:06 -07:00
Anas Khan 13e311b0e4 chore: add codespell pre-commit hook to catch typos
Merge https://github.com/google/adk-python/pull/6406

Add a codespell hook to catch typos automatically.
Fix existing typos flagged by codespell.

PiperOrigin-RevId: 952416492
2026-07-22 17:13:05 -07:00
George Weale c91fc752a5 fix: exclude scripts/ from pre-commit compliance checks
scripts/compliance_checks.py documents and matches the very patterns it
forbids, so the compliance-checks hook (which scanned every .py file)
flagged itself and failed on every PR running pre-commit on all files.
Skip the dev-only scripts/ directory. Also clears pre-existing pyink and
end-of-file drift surfaced by the same all-files run.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 940618068
2026-06-30 13:10:51 -07:00
Shangjie Chen 8a7656b857 refactor(ci): Consolidate compliance checks into pre-commit hook
Move custom file compliance checks (logger pattern, future annotations,
cli imports, mTLS endpoints) from GHA inline bash scripts to a unified
python script (compliance_checks.py) and expose it as a local pre-commit hook.
Remove the compliance-check job from CI workflow.

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 940081615
2026-06-29 15:59:28 -07:00
Milen Kovachev 3cbcefce9f chore: add missing Apache 2.0 license headers
Merge https://github.com/google/adk-python/pull/6155

**Please ensure you have read the [contribution guide](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) before creating a pull request.**

### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**
N/A

**2. Or, if no issue exists, describe the change:**

**Problem:**
The repository is missing Apache 2.0 license headers across 155 files. This is required by Google OSPO.

**Solution:**
Prepended the standard Apache 2.0 open-source license header to all flagged files. The copyright year was dynamically assigned based on each file's first commit year in git history.

### Testing Plan

_Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes._

**Unit Tests:**

- [ ] I have added or updated unit tests for my change.
- [x] All unit tests pass locally.

_Please include a summary of passed `pytest` results._
N/A - This PR only adds comments (license headers) to the top of files and contains zero functional code changes. No new tests are needed, and existing tests should pass as-is.

**Manual End-to-End (E2E) Tests:**
N/A - No functional code was changed.

### Checklist

- [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [x] I have performed a self-review of my own code.
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have added tests that prove my fix is effective or that my feature works.
- [x] New and existing unit tests pass locally with my changes.
- [ ] I have manually tested my changes end-to-end.
- [ ] Any dependent changes have been merged and published in downstream modules.

### Additional context

Co-authored-by: Shangjie Chen <deanchen@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/6155 from milenvk:fix-missing-licenses d2a264b9a812fd997daf975ec37996e6b4b7a042
PiperOrigin-RevId: 936165783
2026-06-22 11:37:57 -07:00
Wei (Jack) Sun 7cae06e001 chore: Adopt ruff for unused-import enforcement
Merge https://github.com/google/adk-python/pull/6097

## Summary

Adopts **ruff** to enforce unused-import (F401) hygiene going forward, so dead imports are caught automatically instead of relying on IDE highlights. (The bulk one-time cleanup already landed in #6095; this is just the tooling.)

- `[tool.ruff]` in `pyproject.toml`: select `F401`, exempt `__init__.py` (intentional public re-exports), and exclude four files that hardcode `googleapis.com` URLs so cleanup doesn't trip the `check-file-contents` mTLS policy.
- ruff pre-commit hook scoped to `src/`.
- `scripts/run_precommit_checks.py` (the no-git standalone runner) learns the ruff hook, passing `--force-exclude` so excludes are honored on explicit file args.
- Pin `ruff` in the dev extra to match the hook version.

## Test plan

- [x] `ruff check src/` passes (excludes honored)
- [x] pre-commit ruff hook runs green
- [x] standalone runner check/fix modes verified

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/6097 from google:chore/adopt-ruff-f401 b0636523926d02f12af4b86cff2b1a1bb94af150
PiperOrigin-RevId: 931304052
2026-06-12 13:28:02 -07:00
Wei (Jack) Sun b170f7bdf5 chore(dev): add standalone pre-commit check script
Merge https://github.com/google/adk-python/pull/6084

## Summary

Adds `scripts/run_precommit_checks.py` to run the `.pre-commit-config.yaml` checks **without** the `pre-commit` framework, which requires a git repository and so cannot run in environments such as a piper checkout that has no `.git`.

- Parses `.pre-commit-config.yaml` so the file lists, global/per-hook `exclude` and `files` patterns, and `args` all come from the config — only the hook-id → CLI command mapping (and each hook's implicit file-type/text filter) is maintained in the script.
- Defaults to fixing in place; pass `--check` to verify only (CI behavior).
- Limits the walk to `src`/`tests`/`contributing`/`pyproject.toml` and never follows symlinks, so `.venv`, build artifacts, and out-of-repo code (e.g. a symlinked `a2a`) are never touched.
- Skips binary files for text fixers, and batches arguments to stay under the OS arg limit.
- `scripts/run_precommit.sh` is a thin wrapper that prefers an already-synced interpreter (`.venv` / active venv) before falling back to `uv run`.
- Adds the standalone lint tools to the `dev` extra (capped at the next major) so `uv sync --extra dev` provides everything the script needs.

## Test plan

- [ ] `scripts/run_precommit.sh --check` passes on a clean tree
- [ ] `scripts/run_precommit.sh` (default fix mode) does not modify binaries (images/PDFs) or `.venv`
- [ ] Runs from any directory; PATH args are repo-root-relative
- [ ] `addlicense` / `check-new-py-prefix` degrade gracefully when unavailable / git-only

Co-authored-by: Wei Sun (Jack) <weisun@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/6084 from google:chore/dev-precommit-script fa3863332f9acf824df2a3ad3b923141d7838f5d
PiperOrigin-RevId: 930799785
2026-06-11 16:27:47 -07:00
Shangjie Chen 0337d19c47 chore: sync Google internal changes to GitHub (#6022) 2026-06-08 15:11:24 -07:00
Sasha Sobran 162279358c chore: switch main to v2.0.0 GA (transition to v2)
Co-authored-by: Bo Yang <ybo@google.com>
Co-authored-by: Wei Sun (Jack) <weisun@google.com>
Co-authored-by: George Weale <gweale@google.com>
Co-authored-by: Swapnil Agarwal <swapnilag@google.com>
Co-authored-by: Xuan Yang <xygoogle@google.com>
Co-authored-by: Shangjie Chen <deanchen@google.com>
Co-authored-by: Yifan Wang <wanyif@google.com>
Co-authored-by: Kathy Wu <wukathy@google.com>
2026-05-19 02:01:33 +00:00
Shangjie Chen 533776e005 chore: Switch to pre-commit and cleanup redundant tools
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 905187116
2026-04-24 13:13:42 -07:00
Shangjie Chen 45ae084ca2 chore: Align pyproject.toml metadata, dependency ordering, and isort rules for better environment consistency
- Revert non-standard src imports and fix formatting/import order across tests and samples to satisfy CI checks.
- Remove check-added-large-files as there are pre-existing large js / sample files
- Add allow-multiple-documents to support Kubernetes manifest that have multiple YAML in one file

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 905085090
2026-04-24 09:53:53 -07:00
Shangjie Chen d935df59e6 chore: Add pre-commit hooks for code formatting and licensing
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 904636630
2026-04-23 14:25:32 -07:00
Shangjie Chen 71f8c5b420 ADK changes
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 904570357
2026-04-23 12:02:27 -07:00