Two small follow-ups to the PR #2433 → #2436 → #2439 incident chain. 1) `import inbox # noqa: F401` in workspace/a2a_mcp_server.py was misleading — `inbox` IS used (at the bridge wiring inside main()). F401 means "imported but unused", which would mask a real future F401 if the usage is removed. Drop the noqa, keep the explanatory block comment about the rewriter's `import X` → `import mr.X as X` expansion (and the `import X as Y` → `import mr.X as X as Y` trap the comment exists to prevent re-introducing). 2) scripts/test_build_runtime_package.py — 17 unit tests covering `rewrite_imports()` and `build_import_rewriter()` in scripts/build_runtime_package.py. Until now the function had zero coverage despite the entire wheel build depending on it. Tests pin: bare-import aliasing, dotted-import preservation, indented imports, from-imports (simple + dotted + multi-symbol + block), the `import X as Y` rejection added in PR #2436 (with comment- stripping + indented + comma-not-alias edge cases), allowlist anchoring (`a2a` ≠ `a2a_tools`), and end-to-end reproduction of the PR #2433 failing pattern + the #2436 fix pattern. 3) Wire scripts/test_*.py into CI by adding a second discover pass to test-ops-scripts.yml. Top-level scripts/ tests live alongside their target file (parallels the scripts/ops/ test layout); the existing scripts/ops/ pass keeps running because scripts/ops/ has no __init__.py so a single discover from scripts/ root doesn't recurse. Two passes is simpler than retrofitting namespace packages. Path filter widened from `scripts/ops/**` to `scripts/**` so PRs touching the build script trigger the new tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
51 lines
1.9 KiB
YAML
51 lines
1.9 KiB
YAML
name: Ops Scripts Tests
|
|
|
|
# Runs the unittest suite for scripts/ on every PR + push that touches
|
|
# anything under scripts/. Kept separate from the main CI so a script-only
|
|
# change doesn't trigger the heavier Go/Canvas/Python pipelines.
|
|
#
|
|
# Discovery: `unittest discover` from the scripts/ root walks recursively,
|
|
# so both `scripts/test_*.py` and `scripts/ops/test_*.py` are picked up.
|
|
# Tests should sit alongside the code they test (see
|
|
# scripts/ops/test_sweep_cf_decide.py for the pattern; scripts/
|
|
# test_build_runtime_package.py for the rewriter coverage).
|
|
|
|
on:
|
|
push:
|
|
branches: [main, staging]
|
|
paths:
|
|
- 'scripts/**'
|
|
- '.github/workflows/test-ops-scripts.yml'
|
|
pull_request:
|
|
branches: [main, staging]
|
|
paths:
|
|
- 'scripts/**'
|
|
- '.github/workflows/test-ops-scripts.yml'
|
|
merge_group:
|
|
types: [checks_requested]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test:
|
|
name: Ops scripts (unittest)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
|
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
with:
|
|
python-version: '3.11'
|
|
- name: Run scripts/ unittests (build_runtime_package, …)
|
|
# Top-level scripts/ tests live alongside their target file
|
|
# (e.g. scripts/test_build_runtime_package.py exercises
|
|
# scripts/build_runtime_package.py). discover from scripts/
|
|
# picks up only top-level test_*.py because scripts/ops/ has
|
|
# no __init__.py — that's intentional, so we run two passes.
|
|
working-directory: scripts
|
|
run: python -m unittest discover -t . -p 'test_*.py' -v
|
|
- name: Run scripts/ops/ unittests (sweep_cf_decide, …)
|
|
working-directory: scripts/ops
|
|
run: python -m unittest discover -p 'test_*.py' -v
|