Skip to content

Commit d7d460c

Browse files
jpr5t
authored andcommitted
ci(showcase/validate): harden python-unit-tests pip install (CR6)
- Add `--only-binary :all:` to the pip install in showcase_validate.yml's python-unit-tests job, mirroring the hardening already in the aimock-e2e sibling workflow. This job runs on EVERY PR automatically without a trusted-commenter gate, so the broader exposure deserves the same wheel-only install defense against PR-controlled setup.py hooks. - Drop the unconditional per-package requirements.txt install. Today's tests are stdlib-only (+ typing_extensions fallback path); installing the full CrewAI graph on every PR run was a ~30-60s tax with no benefit. Install only pytest + typing_extensions. Comment documents the upgrade path for future tests that need package runtime deps. - Drop the now-unused pip cache on setup-python (keyed on a never-used requirements.txt would be pure overhead).
1 parent 05367c3 commit d7d460c

1 file changed

Lines changed: 19 additions & 29 deletions

File tree

.github/workflows/showcase_validate.yml

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -407,32 +407,32 @@ jobs:
407407
uses: actions/setup-python@v5
408408
with:
409409
python-version: ${{ matrix.python-version }}
410-
# Cache pip so the CrewAI-class heavy transitive dep trees don't
411-
# reinstall from scratch every PR run. Keyed on every package
412-
# requirements.txt in the matrix so a single drift invalidates.
413-
cache: "pip"
414-
cache-dependency-path: showcase/packages/*/requirements.txt
410+
# No pip cache: today's tests install only pytest + typing_extensions
411+
# (see "Install minimal test deps" below). Caching would key on a
412+
# never-used `requirements.txt` and add overhead for no benefit.
413+
# Re-add `cache: "pip"` + `cache-dependency-path` if per-package
414+
# requirements.txt installs return (see comment in that step).
415415

416-
- name: Install pytest
417-
run: python -m pip install --quiet pytest
416+
- name: Install minimal test deps
417+
# Today's python unit tests (`test_aimock_toggle.py`) are stdlib-only
418+
# except for the `typing_extensions` fallback path exercised on 3.10.
419+
# Installing each package's full `requirements.txt` (CrewAI graph etc.)
420+
# on every PR is a ~30-60s tax that buys nothing for stdlib-only tests.
421+
# Install only pytest + typing_extensions here.
422+
#
423+
# If a future `tests/python/` adds cases that import package runtime
424+
# deps (e.g. imports `crewai` or `litellm`), that package's test must
425+
# install its own `requirements.txt` in an explicit step OR the loop
426+
# below should gain a marker file (e.g. `tests/python/requirements.txt`)
427+
# that triggers per-package install. Do NOT regress to installing every
428+
# package's full requirements.txt unconditionally.
429+
run: python -m pip install --quiet pytest typing_extensions
418430

419431
- name: Run showcase package Python unit tests
420432
# Keep scope narrow: only showcase/packages/*/tests/python/ directories
421433
# (not e2e, not langgraph which has its own runtime). Each package has
422434
# its own conftest.py that wires up import paths; we cd into the pkg
423435
# dir so those apply.
424-
#
425-
# Install each package's requirements.txt (when present) so pytest
426-
# collection does not fail on transitive imports. Today the crewai-crews
427-
# unit tests only touch aimock_toggle.py (stdlib-only), but future tests
428-
# may exercise modules that pull in package deps — paying the install
429-
# cost per-package is cheap and keeps this job future-proof.
430-
#
431-
# pip install is a HARD FAIL (no `|| warn`): hiding a broken
432-
# requirements.txt behind a warning means a package ships a PR green
433-
# while its runtime deps are unresolvable. The only acceptable
434-
# "skipped install" case is when requirements.txt doesn't exist,
435-
# which we handle via the `-f` guard below.
436436
run: |
437437
set -euo pipefail
438438
failed=0
@@ -443,16 +443,6 @@ jobs:
443443
found=$((found + 1))
444444
pkg=$(basename "$pkg_dir")
445445
echo "--- pytest: $pkg ---"
446-
if [ -f "${pkg_dir}requirements.txt" ]; then
447-
echo "installing ${pkg}/requirements.txt"
448-
if ! python -m pip install --quiet -r "${pkg_dir}requirements.txt"; then
449-
echo "::error file=${pkg_dir}requirements.txt::pip install failed for $pkg"
450-
failed=1
451-
# Skip running pytest against a package whose deps failed —
452-
# the pytest output would be a confusing collection error.
453-
continue
454-
fi
455-
fi
456446
(cd "$pkg_dir" && python -m pytest tests/python/ -v) || failed=1
457447
done
458448
if [ "$found" -eq 0 ]; then

0 commit comments

Comments
 (0)