Skip to content

[CI] Add unit tests for rock_tagging.py (build_plan, execute_plan, convert_to_ssh, get_submodule_url_map) #66

Description

@amd-chiranjeevi

Context

PR #51 added scripts/rock_tagging.py, which automates annotated-tag creation and GitHub
release publishing for TheRock and all tracked ROCm submodules. The current test plan is
fully manual (dry-run inspection, option verification). This issue tracks adding automated
unit tests so the logic can be verified in CI without cloning real repos or pushing real tags.

What needs to be done

Add a test file scripts/tests/test_rock_tagging.py using unittest and unittest.mock.
All subprocess calls must be mocked — no network access, no real git operations.

Tests to implement

convert_to_ssh

  • HTTPS GitHub URL → correct git@github.com: SSH form
  • Already-SSH URL → returned unchanged
  • Non-GitHub URL → returned unchanged

get_submodule_url_map

  • Missing .gitmodules → returns {}
  • Valid .gitmodules with multiple submodules → returns correct path→URL mapping
  • git config --get-regexp failure → returns {}
  • Submodule with no URL entry → that entry is skipped, others returned

build_plan

  • Happy path: mocked clone + submodule status + .gitmodules → correct dict[str, RepoInfo] including TheRock itself
  • Non-ROCm submodule URLs are filtered out
  • --exclude-list entries are skipped
  • Existing cached clone is reused (no second clone)
  • --force-clone deletes and reclones when cache dir is not a valid git repo
  • Missing fetch_sources.py → falls back to git submodule update

execute_plan

  • Tag created and pushed for each repo in plan
  • Pre-existing tag → creation skipped, component counted as success
  • Remote setup failure → component counted as failed, loop continues
  • gh release create called with correct tarball assets for mono-repos (rocm-libraries, rocm-systems)
  • gh release create failure → component counted as failed, not as succeeded
    (regression test for the double-counting bug fixed in Add release tag and GitHub release automation script for TheRock and ROCm submodules #51)
  • Dry-run mode → no push, no gh release create, correct [DRY RUN] log

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions