Skip to content

add tool to synchronize add-on repository with latest addonTemplate - #46

Open
abdel792 wants to merge 3 commits into
nvaccess:masterfrom
abdel792:syncAddon
Open

add tool to synchronize add-on repository with latest addonTemplate#46
abdel792 wants to merge 3 commits into
nvaccess:masterfrom
abdel792:syncAddon

Conversation

@abdel792

@abdel792 abdel792 commented Aug 4, 2026

Copy link
Copy Markdown

Link to issue number:

Replaces #41.

Summary of the issue:

While upgrading an existing add-on using standard Git commands remains fully supported, some add-on developers prefer an automated and dedicated tool to streamline the process. Manual step-by-step migration of metadata (from buildVars.py to pyproject.toml) and file merges can require extra care and verification. Providing an automated script offers a convenient alternative for developers who wish to perform these updates quickly and with built-in AST-based metadata handling.

Description of developer facing changes:

  • Introduces syncAddonWithTemplate.py at the repository root as an automated alternative to Git-based manual upgrades for add-on developers.
  • Protects template-specific files, including .github/workflows/unitTests.yml and tests/, ensuring they are excluded from add-on synchronization.
  • Excludes both syncAddonWithTemplate.py and the tests/ directory from static analysis in pyproject.toml (ruff and pyright).
  • Adds a dedicated unit test suite for the synchronization logic (tests/unit/test_syncAddonWithTemplate.py).
  • Updates documentation for updating existing add-ons and executing unit tests.

Description of development approach:

  • Synchronization Engine Creation: Implemented syncAddonWithTemplate.py using an AST-aware approach to seamlessly migrate legacy buildVars.py metadata or modern AddonInfo setups into pyproject.toml. It supports timestamped backups, custom exclusions via .addonmergeignore, and includes .github/workflows/unitTests.yml in PROTECTED_ELEMENTS.
  • Linter Exclusion Rules: Configured pyproject.toml to exclude syncAddonWithTemplate.py and tests/ from ruff and pyright checks.
  • Verification Suite & Execution Order: Created a dedicated unit test suite (tests/unit/test_syncAddonWithTemplate.py) using unittest and tempfile, utilizing a load_tests hook to guarantee deterministic test execution order.
  • Documentation Integration: Updated technical guides to detail CLI usage, available options, and unit testing commands.

Testing strategy:

Validated the synchronization script and unit test suite locally using uv:

  1. Executed syncAddonWithTemplate.py across various CLI modes:
    • Standard Mode (inside add-on repo, -ad is optional):
uv run python syncAddonWithTemplate.py
  • External Directory Mode:
uv run python /path/to/syncAddonWithTemplate.py -ad /path/to/my-nvda-addon
  • Dry Run Simulation:
uv run python syncAddonWithTemplate.py --dry-run
  1. Verified that backup folders (<addon>_bak_<timestamp>) were generated, .addonmergeignore rules were respected, and protected elements (including .github/workflows/unitTests.yml and tests/) were not pushed to target add-on repositories.
  2. Executed the unit test suite via unittest:
uv run python -m unittest -v tests/unit/test_syncAddonWithTemplate.py

Confirmed all tests passed successfully.
4. Confirmed ruff and pyright ignore syncAddonWithTemplate.py and tests/.

Known issues with pull request:

None.


Code Review Checklist

  • Testing: Tested manually across diverse execution paths and validated via local unit tests. Steps to reproduce are detailed in the testing strategy.
  • Compatibility: Developer-facing infrastructure tool; introduces no breaking changes to existing repository behaviors.
  • Documentation: Technical developer documentation has been explicitly updated.
  • UX of all users considered: Not applicable (Developer-facing infrastructure tool only).
  • Security precautions taken: Not applicable (Runs locally in isolated temporary directories during development).

Introduces the syncAddonWithTemplate.py automation tool to streamline
synchronizing add-on metadata and infrastructure with upstream template
updates.

Detailed changes:
- Added `syncAddonWithTemplate.py` at repository root to handle AST-aware
  merging of buildVars.py and pyproject.toml configuration.
- Configured `PROTECTED_ELEMENTS` in the sync script to prevent overwriting
  template-specific files (e.g., `.github/workflows/unitTests.yml` and `tests/`).
- Added `.addonmergeignore` support for defining project-specific file
  exclusion rules during synchronization.
- Added dependencies for the sync tool to `pyproject.toml`.
- Added `tests/unit/test_syncAddonWithTemplate.py` to validate metadata
  parsing, AST transformations, TOML formatting, and execution ordering.
- Updated `pyproject.toml` to exclude `syncAddonWithTemplate.py` alongside
  the `tests/` directory from ruff and pyright checks.
- Updated `docs/managementFromGit/updatingExistingAddons.md` with full usage
  instructions, CLI flags, and execution modes for the sync script.
- Updated `docs/unitTesting.md` with guidelines for running unit tests
  locally using unittest and uv.
Update testFormatAuthorList in test_syncAddonWithTemplate.py to assert
that empty author email keys are omitted rather than expecting an
empty string, matching syncAddonWithTemplate.py behavior.
…umentation

Update description of testFormatAuthorList to document that empty email fields
are omitted for PEP 621 compliance.
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