Skip to content

ci(unit-tests): cap the size of files tests write on every pytest step (#1969) - #1973

Merged
JarryShaw merged 2 commits into
mainfrom
ci/1969-file-size-caps
Oct 20, 2026
Merged

JarryShaw merged 2 commits into
mainfrom
ci/1969-file-size-caps

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • ci — workflows or build tooling

Description of your pull request and other information

Caps every file a test writes at 2 GiB, on every pytest and unittest step of unit-tests.yml (#1969). #1372 once wrote a 6 GB out.json per run.

  • util/cap_file_size.py sets RLIMIT_FSIZE (soft and hard), restores SIGXFSZ's default action, and execs the command. Exit codes and continue-on-error are unchanged, and a breach raises File too large.
  • The cap applies to test, integration, pypcap-parity (and their KTLO twins), the engine cells, unittest-ordering, project-tests and gate. project-tests drops its own ulimit -f, so the limit lives in one place.
  • tests/project/test_file_size_caps_1969.py fails on any uncapped test command, and exercises the script at a small limit.
  • workflows.rst gains a "File Size Caps" section.

cron-python-versions.yml's single unittest run is outside this PR's scope and stays uncapped.

Closes #1969

#1969)

- Add util/cap_file_size.py: sets RLIMIT_FSIZE, soft and hard, to 2 GiB
  (keeping a lower hard limit), restores SIGXFSZ's default and execs the
  command, so a write past the cap fails with `File too large`.
- Run every pytest and unittest command in unit-tests.yml through it: test,
  integration, pypcap-parity and their KTLO twins, the engine cells,
  unittest-ordering, project-tests and gate. project-tests drops its own
  `ulimit -f`, so the limit lives in one place.
- Pin it in tests/project/test_file_size_caps_1969.py: a test command without
  the script fails, and the script is run against a small limit.
- The step stubs in the tier guard and the #1732 pin hand the script to the
  real interpreter, so they still record the capped command.
- Describe the caps on the workflows page.

Closes #1969
@JarryShaw JarryShaw added ci Pull requests that change CI or workflow configuration (ci: subject prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 20, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 20, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 340fd411c. A Sonnet review ran the wrapper on 3.8.20 and 3.10.21. It sets 2 GiB soft and hard limits, keeps a lower existing hard limit, raises Errno 27 for a Python writer, and kills dd with SIGXFSZ. Every unit-tests.yml job is on Ubuntu, so resource exists everywhere. setrlimit can only fail loudly, never run uncapped silently. execvp keeps exit codes and pids, so continue-on-error and coverage are unaffected. Every pytest, unittest, coverage run and run_unittest_leg command is capped, and removing the cap from any of three steps trips the pin. actionlint reports nothing new.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 20, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

NEEDS CHANGES at 340fd411c. The Python 3.15 coverage leg fails in Report coverage, though every test passed (4296 passed). The #1387 guard reports controller ['2516', '8683'], 2 xdist workers, missing data: ['8683']. main's coverage leg passes, so this PR adds a second process whose command line looks like the coverage controller. It is probably a test whose fake python now runs the real util/cap_file_size.py, which then exec's a coverage run --rcfile=.github/coverage.toml line with coverage active and no data saved. A follow-up commit will find which test it is and fix it at the root, without weakening the guard.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: good-to-go Cross-review at the current head says ready; CI state is separate labels Oct 20, 2026
…ontroller (#1969)

- The python stubs in the tier guard and the #1732 pin handed
  util/cap_file_size.py to the real interpreter. On the coverage leg that
  process was measured, logged its `coverage run --rcfile` argv as a second
  controller and exec'd before saving, so the #1387 guard failed.
- The stubs now exec the capped command themselves, as the script does,
  with no real interpreter; each module gains a test that the real one is
  not started for it.

Refs #1969
@JarryShaw JarryShaw added review: running A cross-review is in flight against the current head - no verdict yet and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Oct 20, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 94593673a. The Sonnet delta review confirmed that the stub fix leaves one coverage controller and preserves the recorded argv. Both regression tests fail on the old stubs. Merging is still gated on CI.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 90.07% (unit tier, Python 3.15, 94593673a, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 2 20 2 96.77%
pcapkit/const 19597 881 2618 867 92.11%
pcapkit/corekit 2505 70 792 36 96.54%
pcapkit/dumpkit 276 3 100 3 98.40%
pcapkit/foundation 2916 164 1016 34 93.59%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17411 224 4580 189 98.10%
pcapkit/toolkit 872 177 298 8 77.18%
pcapkit/utilities 522 2 158 4 99.12%
pcapkit/vendor 4431 2341 1018 156 43.64%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 217224e into main Oct 20, 2026
58 checks passed
@JarryShaw
JarryShaw deleted the ci/1969-file-size-caps branch October 20, 2026 04:02
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 20, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 20, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Pull requests that change CI or workflow configuration (ci: subject prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ci(unit-tests): cap the size of files tests write on every pytest step

1 participant