Skip to content

CI on a clean machine, with a licence probe and a lint pass - #1

Merged
yamierick merged 1 commit into
mainfrom
ci/clean-machine-ci
Oct 22, 2026
Merged

yamierick merged 1 commit into
mainfrom
ci/clean-machine-ci

Conversation

@yamierick

Copy link
Copy Markdown
Contributor

Why

The code standard (Part 1 rule 6) requires tests that CI runs on a clean machine. This repo had 181 tests, but GitHub had never run any of them.

What

  • .github/workflows/ci.yml, adapted from code-standard/templates/, with two jobs:
    • suite: pytest, tools/check_notebooks.py, tools/check_seeds.py, then ruff check .
    • energy: the PyPSA tests, which need pandas 3
    • Both log pip freeze, so every run records what actually ran. No secrets are needed.
  • tests/conftest.py probes the Gurobi licence once.
    • CI only has the size-limited licence that ships with pip install gurobipy (2,000 variables).
    • The newsvendor scenario model is 3,002 variables, so the 7 tests that solve it skip on CI, with the reason printed. They run anywhere with a full licence.
  • ORTEACH_REQUIRE_PYPSA=1 makes the energy job fail if PyPSA won't import, instead of skipping everything and going green.
  • pyproject.toml: ruff added to dev; a new energy extra (pypsa, pandas 3); ruff excludes notebooks/.
  • Lint fixes: 14 cosmetic findings (unused imports, semicolons, one lambda, l as a variable name). No behaviour change.
  • README: a "What this is for" paragraph under the title, install lines, and a description of what CI runs and skips.

Evidence

  • Local gate: 181 passed; all 17 notebooks and 11 seeds clean; ruff clean.
  • Size-limited licence, simulated locally by hiding the licence file:
    • before this PR, 174 passed and the 7 newsvendor tests failed;
    • after it, the newsvendor tests skip (3 of 10 pass, 7 skip).
  • Both guards watched to fail:
    • the licence probe, by running with and without the licence;
    • the PyPSA requirement, using a stub that refuses to import.

The CI result for this PR is the last piece of evidence; I'll report it on this PR.

🤖 Generated with Claude Code

The standard's Part 1 rule 6 asks for tests that CI runs on a clean
machine. This repository had 181 tests and no CI at all; GitHub had never
run anything. This adds .github/workflows/ci.yml, adapted from
code-standard's templates/:

  suite   pytest, tools/check_notebooks.py, tools/check_seeds.py, ruff
  energy  the PyPSA half of tests/test_energy.py, in its own job because
          PyPSA 1.3 needs pandas 3

Both log `pip freeze`, so the resolved versions are recorded with every
run (rule 3: a range is not a record).

No secrets. CI has only the size-limited licence that `pip install
gurobipy` ships. Measured locally with the licence file hidden: 174 tests
pass and exactly 7 fail, all in test_newsvendor.py, because its scenario
model is 3,002 variables against a 2,000 limit. tests/conftest.py now asks
the solver once (one variable past the limit, error 10010) and skips only
tests marked needs_full_licence, with the reason printed by -rs. Watched
both ways: with the licence, 10/10 newsvendor tests run; with it hidden,
3 pass and 7 skip.

A job that exists to run the PyPSA tests must not go green by skipping
them. tests/test_energy.py now raises at collection when
ORTEACH_REQUIRE_PYPSA=1 and PyPSA does not import; the energy job sets it.
Watched to fail with PyPSA shadowed by a stub that refuses to import: 6
skips without the variable, a collection error with it.

pyproject.toml gains ruff in dev (pinned to 0.15.x, since new minors add
rules) and an `energy` extra (pypsa, pandas 3), plus [tool.ruff] excluding
notebooks, whose inline knobs and repetition are correct by Part 4. The
14 findings ruff reported were cosmetic: unused imports (none re-exported),
semicolon-joined statements, a lambda, and `l` as a name. No behaviour
changed.

README: a statement of what the library is for, under the title, which
until now came only after the citation block; install lines; and what CI
runs and skips.

Local gate on this commit: 181 passed, 17 notebooks and 11 seeds clean,
ruff clean.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yamierick

Copy link
Copy Markdown
Contributor Author

CI read for 229cd68: both jobs green.

  • suite: 168 passed, 13 skipped. The skips are the 6 PyPSA tests (they run in the energy job instead) and the 7 newsvendor tests on the size-limited licence, each with its reason printed. Notebook checklist: 17/17 clean. Seeds: 11/11. Ruff clean.
  • energy: 11 passed, 0 skipped, on pypsa 1.4.0 with ORTEACH_REQUIRE_PYPSA=1.
  • The run log records gurobipy 13.0.3 and pandas 3.1.0.

@yamierick
yamierick merged commit 8675ba4 into main Oct 22, 2026
2 checks passed
@yamierick
yamierick deleted the ci/clean-machine-ci branch October 22, 2026 18:56
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.

1 participant