Skip to content

ci: fix uv sync flag and bandit install so CI actually runs#1

Open
abhicris wants to merge 1 commit intocryptuon:mainfrom
abhicris:fix/ci-uv-sync-extra-dev
Open

ci: fix uv sync flag and bandit install so CI actually runs#1
abhicris wants to merge 1 commit intocryptuon:mainfrom
abhicris:fix/ci-uv-sync-extra-dev

Conversation

@abhicris
Copy link
Copy Markdown

Problem

Every CI run on main since v0.1.0 has failed — but not because of real code issues. Two workflow bugs are short-circuiting the jobs before any check actually executes.

1. Lint / Type Check / Test jobs — uv sync --dev is a no-op

The workflow runs:

- name: Install dependencies
  run: uv sync --dev

But pyproject.toml declares dev tooling under [project.optional-dependencies]:

[project.optional-dependencies]
dev = [
    "pytest>=8.0",
    "pytest-asyncio>=0.23",
    "pytest-cov>=4.1",
    "ruff>=0.1",
    "mypy>=1.8",
]

In modern uv, --dev targets [dependency-groups]. With [project.optional-dependencies] you need --extra dev. Result: ruff, pytest, and mypy never land in the venv, and every lint run dies with:

error: Failed to spawn: `ruff`
  Caused by: No such file or directory (os error 2)
Process completed with exit code 2.

(See run 24428772293 — and every CI run before it.)

The sibling workflow .github/workflows/docs.yml already uses the correct pattern: uv sync --extra docs. This PR brings ci.yml in line.

2. Security Scan job — no venv exists when uv pip install runs

- name: Install bandit
  run: uv pip install bandit
- name: Run bandit security check
  run: uv run bandit -r src/polybot/ -ll -x tests/ -f json -o bandit-report.json

Fails with:

error: No virtual environment found; run `uv venv` to create an environment, or pass `--system` to install into a non-virtual environment
Process completed with exit code 2.

The fix is to drop the two-step install+run and use uvx, which is purpose-built for one-shot tool invocations and doesn't need a project venv.

Fix

  • ci.yml: uv sync --devuv sync --extra dev in the lint, type-check, and test jobs.
  • ci.yml security job: replace uv pip install bandit + uv run bandit ... with a single uvx --from bandit bandit ... step.

Diff is 11 lines, one file.

Verification

Locally, against this branch:

$ uv sync --extra dev
 + ruff==0.14.10
 + pytest-asyncio==1.3.0
 + pytest-cov==7.0.0
 + mypy==1.18.2
 ...

$ uv run ruff --version
ruff 0.14.10      # was: error: Failed to spawn: `ruff`

$ uvx --from bandit bandit -r src/polybot/ -ll -x tests/ -f json -o /tmp/bandit-report.json
[json] INFO JSON output written to file: /tmp/bandit-report.json
# exit 0, 41KB report

Note for maintainers

Once CI actually runs, ruff check will surface real findings (the repo has ~1700 lint errors and 66 files flagged by ruff format --check). That's pre-existing — outside the scope of this PR. This PR just removes the infra failures that have been masking them. Consider it a precondition for any lint-cleanup PR that follows.

kcolbchain / Abhishek Krishna

The lint/type-check/test jobs call `uv sync --dev`, but polybot
declares dev tooling under `[project.optional-dependencies]` (not
`[dependency-groups]`), so `--dev` is a no-op and `ruff`/`pytest`
never land in the venv. Result: every lint run fails with
`error: Failed to spawn: 'ruff'` before a single check executes.
Switch those three jobs to `uv sync --extra dev`, matching the
pattern already used by `docs.yml` (`uv sync --extra docs`).

The security job separately fails with `No virtual environment
found; run 'uv venv' to create an environment, or pass '--system'`
because `uv pip install bandit` runs before any venv exists.
Replace the two-step install+run with `uvx --from bandit bandit ...`,
which is purpose-built for one-shot tool invocations and drops the
step entirely.

Verified locally:
  uv sync --extra dev        # installs ruff 0.14.10, pytest, mypy
  uv run ruff --version      # ruff 0.14.10 (was: failed to spawn)
  uvx --from bandit bandit   # writes bandit-report.json, exit 0

After this PR the jobs will surface their real signal (ruff lint
errors, pytest results) rather than masking them behind env setup
failures.

— [kcolbchain](https://kcolbchain.com) / [Abhishek Krishna](https://abhishekkrishna.com)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants