Skip to content

ci: gate cacti.pot updates on i18n diff instead of regenerating - #53

Merged
cigamit merged 1 commit into
developfrom
ci/i18n-pot-gate
Oct 5, 2026
Merged

cigamit merged 1 commit into
developfrom
ci/i18n-pot-gate

Conversation

@TheWitness

Copy link
Copy Markdown
Member

What

Replaces the Verify translation template is up to date CI step. It no longer
regenerates locales/po/cacti.pot with locales/build_gettext.sh and compares
it (ignoring POT-Creation-Date). Instead it inspects the pull request diff and
requires that locales/po/cacti.pot be part of the PR whenever the translatable
strings actually change.

Why

The old check coupled CI to an exact gettext/xgettext toolchain: a different
GNU gettext version reorders or re-wraps the template and the step fails even
when no translatable string changed. The real intent is simply "if you changed
i18n strings, regenerate and commit the template".

How

New script tests/bin/check-i18n-pot.php:

  • Diffs the branch against the PR base SHA (same approach as
    tests/bin/patch-coverage.php).
  • Flags a change when any added/removed line contains one of the Cacti i18n
    calls that build_gettext.sh feeds to xgettext
    (__ __n __x __xn __esc __esc_n __esc_x __esc_xn __date __gettext), limited to
    the files that feed the template (find . -maxdepth 2 -name '*.php').
  • A pure re-indent or move of an existing i18n line is not treated as a
    change (the added/removed i18n lines are compared as sets).
  • If i18n strings changed and locales/po/cacti.pot is not in the PR, the
    step fails with the list of offending files; otherwise it passes.

The step now runs on pull_request events only.

Testing

Validated locally against real branch diffs: adding an __() call without a pot
update fails; adding it with the pot update passes; a non-i18n change passes; a
pure re-indent of an i18n line passes; deleting a template-feeding PHP file that
contained __() without a pot update fails.

The "Verify translation template is up to date" step regenerated
locales/po/cacti.pot with locales/build_gettext.sh and compared it
(ignoring POT-Creation-Date). That couples the check to an exact
gettext/xgettext toolchain and fails on unrelated version drift.

Replace it with tests/bin/check-i18n-pot.php, which inspects the pull
request diff: if any changed line adds, removes, or edits a Cacti i18n
call (__(), __n(), __esc(), ... the same keywords build_gettext.sh
feeds xgettext) in a file that feeds the template, then
locales/po/cacti.pot must also be part of the pull request. The check
fails only when that pot update is missing.

The step now runs only on pull_request events and diffs against the
PR base SHA, mirroring the existing patch-coverage.php approach.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The line-based detector can miss multiline translation changes and report false positives for non-message edits.

Review effort: Balanced
Findings: None

What changed in this PR

Replaces gettext regeneration in CI with a diff-based check requiring POT updates when translatable strings change.

Changes:

  • Adds a PHP script to detect i18n-related diff changes.
  • Runs the check for pull requests using the base SHA.
File Description
tests/​bin/​check-i18n-pot.php Implements diff-based POT validation.
.github/​workflows/​plugin-ci-workflow.yml Integrates validation into pull-request CI.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cigamit
cigamit merged commit d8c7b8d into develop Oct 5, 2026
6 checks passed
@cigamit
cigamit deleted the ci/i18n-pot-gate branch October 5, 2026 17:09
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.

3 participants