Skip to content

Add unit tests and GitHub Actions CI workflow#1

Merged
gregorkrz merged 3 commits intomainfrom
cursor/setup-dev-environment-84fb
Apr 8, 2026
Merged

Add unit tests and GitHub Actions CI workflow#1
gregorkrz merged 3 commits intomainfrom
cursor/setup-dev-environment-84fb

Conversation

@gregorkrz
Copy link
Copy Markdown
Owner

@gregorkrz gregorkrz commented Apr 8, 2026

Summary

Adds a comprehensive test suite (87 unit tests) and a GitHub Actions CI workflow for automated testing on every push/PR to main.

Tests added (tests/)

Module Tests What's covered
test_jetfinder.py 20 PseudoJet properties/addition, NPHistory, NPPseudoJets, anti-kt jet finding, Lorentz/cosine distance matrices, HDBSCAN clustering
test_object_cond.py 30 calc_eta_phi, huber loss, safe_index, assert_no_nans, isin, reincrementalize, get_clustering_np/get_clustering, scatter_counts_to_indices
test_dataset.py 18 spherical_to_cartesian, renumber_clusters, TensorCollection, to_tensor, EventPFCands kinematics
test_utils.py 11 get_path with env vars/fallback, import_module with temp files

GitHub Actions CI (.github/workflows/tests.yml)

  • Triggers on push/PR to main
  • Python 3.10, CPU-only PyTorch 2.5.0
  • Installs all dependencies (matching the Dockerfile approach)
  • Runs ruff check --select E9,F63,F7,F82 for syntax/fatal errors
  • Runs pytest tests/ -v --tb=short

Also includes

  • AGENTS.md with Cursor Cloud development environment instructions

Local test run

All 87 tests pass:

============================== 87 passed in 1.50s ==============================
Open in Web Open in Cursor 

cursoragent and others added 2 commits April 8, 2026 05:39
Co-authored-by: Gregor Kržmanc <gregor.krzmanc@cern.ch>
- 87 unit tests across 4 test modules:
  - test_jetfinder: PseudoJet, NPHistory, NPPseudoJets, anti-kt clustering,
    distance matrices (Lorentz, cosine), HDBSCAN clustering
  - test_object_cond: calc_eta_phi, huber loss, isin, reincrementalize,
    get_clustering (numpy & torch), scatter_counts_to_indices, safe_index
  - test_dataset: spherical_to_cartesian, renumber_clusters, TensorCollection,
    to_tensor, EventPFCands kinematics
  - test_utils: get_path with env vars and fallback, import_module

- GitHub Actions workflow (.github/workflows/tests.yml):
  - Runs on push/PR to main
  - Python 3.10, CPU-only PyTorch 2.5.0
  - Ruff lint check (syntax errors) + pytest

Co-authored-by: Gregor Kržmanc <gregor.krzmanc@cern.ch>
@cursor cursor bot changed the title Add AGENTS.md with Cursor Cloud development environment instructions Add unit tests and GitHub Actions CI workflow Apr 8, 2026
…in deprecated code

Co-authored-by: Gregor Kržmanc <gregor.krzmanc@cern.ch>
@gregorkrz gregorkrz marked this pull request as ready for review April 8, 2026 05:55
@gregorkrz gregorkrz merged commit fe1993a into main Apr 8, 2026
2 checks passed
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ca19d05. Configure here.


- name: Lint with ruff
run: |
ruff check --select E9,F63,F7 --output-format=github tests/
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI ruff check missing F82 undefined-name rule

Medium Severity

The ruff check command in the CI workflow is missing the F82 rule from its --select argument. This means the CI won't catch NameError-class bugs (e.g., undefined names), which are valuable lint checks that were intended for enforcement.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ca19d05. Configure here.

Comment thread tests/test_jetfinder.py
basicjetfinder,
find_closest_jets,
inclusive_jets,
add_step_to_history,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused imports of untested functions in test file

Low Severity

inclusive_jets and add_step_to_history are imported from src.jetfinder.basicjetfinder but never used in any test. This creates the misleading impression that these functions have dedicated test coverage when they don't (they're only exercised indirectly via basicjetfinder).

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ca19d05. Configure here.

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