Skip to content

Global mutable state encapsulation: UPDATES/add_or_update contracts. #29

Description

@AuraMindNest

Problem

Translation workflows scattered mutable global state (UPDATES and add_or_update) across workflow YAML and shell scripts, with no shared initialization, validation, or write contracts. Direct array mutation made duplicate entries possible and left Weblate payload assembly (trigger_weblate) duplicated inline in the workflow.

Acceptance Criteria

  • UPDATES and add_or_update are initialized via init_translation_state / init_add_or_update_lang in all workflows and tests
  • Submodule names are recorded only through record_submodule_update and record_add_or_update_submodule, with deduplication and name validation
  • trigger_weblate lives in translation.sh, validates add_or_update before POST, and accepts lang_code as a parameter
  • Bats tests cover validation, deduplication, and Weblate skip/fail paths for the new state API

Implementation Notes

  • lib.sh documents and owns the translation state contract: UPDATES (ordered, deduplicated submodule basenames) and add_or_update (lang_code → space-separated names for Weblate)
  • is_valid_submodule_name enforces basename-only names matching ^[a-z][a-z0-9._-]*$; invalid writes surface via phase_err
  • trigger_weblate was lifted from start-translation.yml into translation.sh, parameterized with lang_code instead of relying on a workflow-scoped $LANG_CODE

References

  • .github/workflows/assets/lib.sh
  • .github/workflows/assets/translation.sh
  • .github/workflows/add-submodules.yml
  • .github/workflows/start-translation.yml
  • tests/helpers/common.bash
  • tests/test_lib.bats

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions