Skip to content

test: split main_test.py into one file per area - #354

Merged
shenxianpeng merged 2 commits into
mainfrom
refactor/split-tests
Nov 23, 2026
Merged

shenxianpeng merged 2 commits into
mainfrom
refactor/split-tests

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

First of two steps that split the action's code by area. This one moves only the tests; main.py is untouched.

Before vs after

Before After
main_test.py: 6,216 lines, 412 tests in one file tests/: one file per area of main.py, the largest 1,705 lines
File Lines What it tests
tests/inputs_test.py 239 inputs, their validation, the wiring from action.yml
tests/model_test.py 87 ScopeResult and the overall status
tests/context_test.py 674 the event, the PR and its commits (git or API)
tests/base_config_test.py 442 config-source: base
tests/cli_test.py 1,318 running the CLI and turning its JSON into scopes
tests/log_test.py 381 step log and annotations
tests/report_test.py 1,705 the Markdown report (job summary and PR comment)
tests/publish_test.py 959 job summary, result output, PR comment, AI label
tests/main_test.py 77 main()
tests/integration_test.py 291 the pinned commit-check, unmocked
tests/helpers.py 183 builders that several files share (make_check, fail_scope, ...)
tests/conftest.py 10 sets GITHUB_STEP_SUMMARY and puts the repo root on sys.path before main is imported

Each file is named after the module that the next PR moves that part of main.py into.

Nothing in a test changed

  • Every test class and helper is moved as is: all 96 top-level definitions parse to the same AST as before. A helper that only one file uses stays in that file.
  • The same 412 test IDs are collected before and after, and all pass.
  • main.py coverage is still 100%.

Other changes

  • CI runs pytest tests instead of pytest main_test.py, in both jobs.
  • name-tests-test skips tests/helpers.py, which has no tests. conftest.py is already exempt.

The next PR moves main.py's code into an action/ package and leaves main.py as the entrypoint. In the tests, it only changes the patch targets.

main_test.py had grown to 6,216 lines. Its 412 tests now live in tests/,
one file per area of main.py (inputs, commits, base config, checks,
step log, report, outputs, main, and the unmocked integration tests),
with the builders several files share in tests/helpers.py.

Nothing in a test changed: every class and helper is moved as is, the
same 412 tests run, and main.py stays at 100% coverage. CI now points
pytest at tests/.
@shenxianpeng
shenxianpeng requested a review from a team as a code owner November 23, 2026 20:10
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 10 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4b72a778-6c3d-4748-834a-5dcc754a85ac
Commits

Reviewing files that changed from the base of the PR and between da20b1b and e04ce40.

Files selected for processing: 15

  • .github/workflows/ci.yml
  • .pre-commit-config.yaml
  • main_test.py
  • tests/base_config_test.py
  • tests/cli_test.py
  • tests/conftest.py
  • tests/context_test.py
  • tests/helpers.py
  • tests/inputs_test.py
  • tests/integration_test.py
  • tests/log_test.py
  • tests/main_test.py
  • tests/model_test.py
  • tests/publish_test.py
  • tests/report_test.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@shenxianpeng shenxianpeng self-assigned this Nov 23, 2026
@github-actions

github-actions Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

✔ Commit Check passed

✔ Pull request: 2 passed
✔ Commits: 2 passed
✔ Author: 2 passed
✔ Branch: passed

All 7 checks
Pull request
  ✔ title        test: split main_test.py into one file per area
  ✔ description  no AI attribution
Commits
  ✔ 797ddc9      test: split main_test.py into one file per area
  ✔ e04ce40      test: name the test files after the modules they will cover
Author
  ✔ name         Xianpeng Shen
  ✔ email        3353385+shenxianpeng@users.noreply.github.com
Branch
  ✔ branch       refactor/split-tests

Checked by Commit Check 2.24.1 · Rules · Check before you push

@github-actions github-actions Bot added the ai-assisted Written with the help of an AI tool label Nov 23, 2026
@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (da20b1b) to head (e04ce40).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #354   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines         1257      1257           
=========================================
  Hits          1257      1257           
Flag Coverage Δ
unittests 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shenxianpeng shenxianpeng added maintenance Maintenance update and removed ai-assisted Written with the help of an AI tool labels Nov 23, 2026
@shenxianpeng shenxianpeng removed the maintenance Maintenance update label Nov 23, 2026 — with Claude
@shenxianpeng
shenxianpeng merged commit 1b6a524 into main Nov 23, 2026
21 checks passed
@shenxianpeng
shenxianpeng deleted the refactor/split-tests branch November 23, 2026 20:16
@shenxianpeng shenxianpeng added the maintenance Maintenance update label Nov 23, 2026 — with Claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Maintenance update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant