GRM-54: Integrate tea Gitea CLI for API interactions #68

Merged
emil merged 0 commits from GRM-54-gitea-cli-integration into master 2026-06-22 07:04:59 +00:00
Owner

Summary

Integrates the tea Gitea CLI tool for Gitea API interactions in CI scripts, replacing direct HTTP API calls with a Python wrapper around the official CLI.

Changes

New Files

  • scripts/gitea_cli.py — Python wrapper around tea CLI with TeaCLI class for issues, labels, PRs, releases, reviews, and branches
  • tests/unit/test_gitea_cli.py — Comprehensive unit tests (100% coverage)

Modified Files

  • scripts/install_tools.py — Added tea CLI installation (v0.14.1); --tool option now supports multiple values
  • scripts/setup.py — Added _configure_tea_login() to configure tea login from .env REPO_TOKEN
  • scripts/ci/review_pr.py — Refactored to post reviews via tea pulls review instead of GiteaClient.create_review
  • scripts/ci/publish.py — Refactored to create releases via tea releases create instead of GiteaClient.create_release_idempotent
  • scripts/ci/notify_failure.py — Refactored to create issues via tea issues create with fallback to GiteaClient when tea is not installed
  • scripts/configure_repo.py — Refactored to create labels via tea labels create with fallback to GiteaClient; branch protection still uses GiteaClient (tea only supports basic protect/unprotect)
  • AGENTS.md — Documented tea CLI integration, updated PYTHONPATH table
  • .gitea/workflows/publish.yml — Install tea, configure login, use PYTHONPATH: .:src
  • .gitea/workflows/post-merge.yml — Updated notify_failure.py PYTHONPATH to .:src

Test Updates

  • All test files updated to mock TeaCLI instead of GiteaClient where applicable
  • New tests for _configure_tea_login() in test_setup.py
  • New test for multiple --tool option in test_install_tools.py
  • All 838 tests pass with 100% coverage

Design Decisions

  1. Fallback strategy: notify_failure.py and configure_repo.py fall back to GiteaClient when tea is not available or fails — this ensures robustness in CI environments where tea might not be installed
  2. No fallback for review_pr.py and publish.py: These scripts are only run in workflows where tea is explicitly installed, so no fallback is needed
  3. Branch protection stays on GiteaClient: tea only supports basic protect/unprotect, not the detailed config we need (status checks, required approvals, etc.)
  4. PYTHONPATH: .:src: Scripts that import from both gitea_runner_manager and scripts.gitea_cli need both paths

Closes GRM-54

## Summary Integrates the `tea` Gitea CLI tool for Gitea API interactions in CI scripts, replacing direct HTTP API calls with a Python wrapper around the official CLI. ## Changes ### New Files - `scripts/gitea_cli.py` — Python wrapper around `tea` CLI with `TeaCLI` class for issues, labels, PRs, releases, reviews, and branches - `tests/unit/test_gitea_cli.py` — Comprehensive unit tests (100% coverage) ### Modified Files - `scripts/install_tools.py` — Added `tea` CLI installation (v0.14.1); `--tool` option now supports multiple values - `scripts/setup.py` — Added `_configure_tea_login()` to configure tea login from `.env` `REPO_TOKEN` - `scripts/ci/review_pr.py` — Refactored to post reviews via `tea pulls review` instead of `GiteaClient.create_review` - `scripts/ci/publish.py` — Refactored to create releases via `tea releases create` instead of `GiteaClient.create_release_idempotent` - `scripts/ci/notify_failure.py` — Refactored to create issues via `tea issues create` with fallback to `GiteaClient` when tea is not installed - `scripts/configure_repo.py` — Refactored to create labels via `tea labels create` with fallback to `GiteaClient`; branch protection still uses `GiteaClient` (tea only supports basic protect/unprotect) - `AGENTS.md` — Documented tea CLI integration, updated PYTHONPATH table - `.gitea/workflows/publish.yml` — Install tea, configure login, use `PYTHONPATH: .:src` - `.gitea/workflows/post-merge.yml` — Updated `notify_failure.py` PYTHONPATH to `.:src` ### Test Updates - All test files updated to mock `TeaCLI` instead of `GiteaClient` where applicable - New tests for `_configure_tea_login()` in `test_setup.py` - New test for multiple `--tool` option in `test_install_tools.py` - All 838 tests pass with 100% coverage ## Design Decisions 1. **Fallback strategy**: `notify_failure.py` and `configure_repo.py` fall back to `GiteaClient` when tea is not available or fails — this ensures robustness in CI environments where tea might not be installed 2. **No fallback for `review_pr.py` and `publish.py`**: These scripts are only run in workflows where tea is explicitly installed, so no fallback is needed 3. **Branch protection stays on `GiteaClient`**: tea only supports basic protect/unprotect, not the detailed config we need (status checks, required approvals, etc.) 4. **`PYTHONPATH: .:src`**: Scripts that import from both `gitea_runner_manager` and `scripts.gitea_cli` need both paths Closes GRM-54
emil reviewed 2026-06-22 07:01:02 +00:00
emil left a comment
Author
Owner

Automated PR Review

  • Architecture compliance: OK
  • Best practices: OK
  • Security: OK
  • Documentation: OK
  • Tests: OK
  • Commit conventions: OK

No issues found by automated checks.


Manual review required: Before approving, review every category in
REVIEW_CHECKLIST.md and confirm with:

python3 scripts/ci/review_pr.py <PR> <owner/repo> \
  --event APPROVE --checklist-confirmed \
  --body "<substantive review summary>"
## Automated PR Review - Architecture compliance: OK - Best practices: OK - Security: OK - Documentation: OK - Tests: OK - Commit conventions: OK No issues found by automated checks. --- **Manual review required:** Before approving, review every category in [REVIEW_CHECKLIST.md](REVIEW_CHECKLIST.md) and confirm with: ```bash python3 scripts/ci/review_pr.py <PR> <owner/repo> \ --event APPROVE --checklist-confirmed \ --body "<substantive review summary>" ```
emil merged commit 28dc6dcf86 into master 2026-06-22 07:04:59 +00:00
emil deleted branch GRM-54-gitea-cli-integration 2026-06-22 07:04:59 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: oblachno-oss/grm#68