Skip to content

Refactor/CI: Separate viz scripts and add test infrastructure#3

Merged
JacksonFergusonDev merged 9 commits into
mainfrom
modules
Jan 30, 2026
Merged

Refactor/CI: Separate viz scripts and add test infrastructure#3
JacksonFergusonDev merged 9 commits into
mainfrom
modules

Conversation

@JacksonFergusonDev

Copy link
Copy Markdown
Owner

Refactor Visualization Scripts and Add CI Infrastructure

Summary

This PR refactors the project structure to separate library logic (src/) from imperative scripts (scripts/), specifically targeting visualization tools. It also introduces a formal CI pipeline using GitHub Actions (via uv) and adds basic smoke testing to prevent circular import regressions.

Changes

🏗️ Refactoring & Architecture

  • Moved src/generate_svg.py to scripts/visualization/joyplot.py: Converted the hardcoded script into a reusable CLI tool with argparse.
  • Decoupled Diagnostics: Split src/diagnostics.py into pure logic (Layer 3) and moved the UI/Plotting code (plot_health_check) to src/plots.py (Layer 4). This allows the diagnostics logic to run in headless environments.
  • Refactored Spectrum Analysis: Moved the visualization logic from scripts/analysis/spectrum.py into src/viz.py as analyze_signal_plot(), making the script a thin wrapper around the library.

🧪 Testing & CI

  • Added CI Workflow: Created .github/workflows/ci.yml to run linting (Ruff) and tests (Pytest) on macOS and Ubuntu (Python 3.13).
  • Added Smoke Test: Created tests/test_imports.py to verify the package dependency graph is acyclic and importable.
  • Configured Tools: Updated pyproject.toml with configuration for Ruff (targeting py313) and Pytest (test discovery).
  • Documentation: Added tests/README.md to document the testing strategy.

🧹 Maintenance

  • Linting Fixes: Resolved unused variables, line length violations, and ambiguous variable names in:
    • scripts/capture/master_transfer.py
    • scripts/visualization/render_scope_video.py
    • power-regulator-12v-to-9v/schematic/schematic.py

How to Test

  1. Run Tests: uv run pytest
  2. Run Linter: uv run ruff check .

…dd CLI args

- Moves src/generate_svg.py to scripts/visualization/joyplot.py to separate
  imperative scripts from library code.
- Replaces hardcoded file paths and constants with argparse CLI arguments.
- Adds standard boilerplate for path handling.
- Adds tests/test_imports.py to verify that the 'src' package
  can be imported without circular dependency errors.
- Moves plot_health_check() from src/diagnostics.py to src/plots.py to
  keep diagnostics.py pure logic (Layer 3) and plots.py pure UI (Layer 4).
- Removes matplotlib dependency from diagnostics.py to allow headless execution.
- Updates src/plots.py imports to include config.
- Moves the visualization logic from scripts/analysis/spectrum.py into
  src/viz.py as a reusable function `analyze_signal_plot()`.
- Flattens scripts/analysis/spectrum.py to remove the `analyze_file`
  wrapper, making `main()` call the library function directly.
- Adds [tool.ruff] configuration for Python 3.13.
- Adds [tool.pytest.ini_options] to locate tests in the subfolder
  and ensure src/ is importable.
- Creates .github/workflows/ci.yml to run tests and linting on push/PR.
- Configures matrix for macOS/Ubuntu and Python 3.13.
- Uses uv for fast dependency management.
- scripts/capture/master_transfer.py:
    - Replace unused 'osc' variable with '_' in context managers.
    - Update deprecated diagnostics.plot_health_check() call to plots.plot_health_check().
- scripts/visualization/render_scope_video.py:
    - Rename ambiguous variable 'l' to 'glow_line'.
    - Wrap long comment for ffmpeg presets.
- power-regulator/schematic.py:
    - Shorten long comment to satisfy line length limit.
@JacksonFergusonDev JacksonFergusonDev merged commit bb2b97e into main Jan 30, 2026
2 checks passed
@JacksonFergusonDev JacksonFergusonDev deleted the modules branch January 30, 2026 01:23
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