Skip to content

Shared lib: the changelogger section reader and the phar download - #34

Open
larodiel wants to merge 1 commit into
mainfrom
shared-release-libs
Open

larodiel wants to merge 1 commit into
mainfrom
shared-release-libs

Conversation

@larodiel

@larodiel larodiel commented Nov 16, 2026 •

Copy link
Copy Markdown

Summary

Two helpers move into .github/lib so the release actions share them instead of each carrying a copy: the reader for the changelogger section of package.json, and the phar download.

Changes

  • lib/changelogger.js: readChangeloggerSection(text) returns the changelogger section, or null when package.json is missing, is not JSON or has no section object, the cases where the changelogger runs on its defaults. release-prep reads its versioning strategy through it.
  • lib/phar.js: downloadPhar() downloads a phar into the runner's temp directory, reuses it in a later step of the same job, checks an optional sha512 on every call, and deletes the file when the download or the check fails. lib/pup.js downloads pup through it; generate-pot (Add generate-pot: the POT file from WP-CLI, and whether a string changed #25) downloads wp-cli through it.
  • Tests for both under tests/lib/.

How to test

  1. Run npm test.

Secrets and variables

None.

Summary by CodeRabbit

  • Chores

    • Release preparation now handles missing or invalid changelog settings with the semver default.
    • Downloaded tool files are reused when nonempty, and configured SHA-512 checks apply to both new and reused files. Failed downloads or checksum checks remove the file and report an error.
  • Tests

    • Added coverage for changelog settings, download reuse, checksum failures, and download errors.

@larodiel larodiel self-assigned this Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The release-prep action now uses a shared parser for changelogger configuration. PHAR existence checks, downloads, retries, checksum validation, and cleanup move into a shared helper. The pup module delegates to that helper. Tests cover parser inputs and PHAR reuse and failures.

Changes: Changelogger Section Parsing

Layer / File(s) Summary
Parse and use the changelogger section
.github/lib/changelogger.js, .github/actions/release-prep/release-prep.js, tests/lib/changelogger.test.js
Adds a shared parser that returns a valid changelogger object or null. The release-prep action uses it to select the versioning strategy. Tests cover valid, absent, invalid, and unsupported section values.

PHAR Download Handling

Layer / File(s) Summary
Implement and test PHAR handling
.github/lib/phar.js, tests/lib/phar.test.js
Adds shared checks for nonempty PHAR files and download handling with retries. The helper verifies nonempty SHA-512 values for reused and new files and removes files after download or checksum errors. Tests cover reuse and failures.
Delegate pup downloads to the shared helper
.github/lib/pup.js
Replaces local PHAR checks and download logic with calls to the shared helper. Removes the local pharExists export.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related PRs

Suggested reviewers: glaubersilva, d4mation, pauloiankoski

Merge Risk: Minimal · up to 55d2c

The change moves shared release helpers into a common library and keeps their behavior the same. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names two real changes in the PR: the new shared changelogger section reader (readChangeloggerSection) and the shared phar download helper (downloadPhar). Both are present in the summary and…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names two real changes in the PR: the new shared changelogger section reader (readChangeloggerSection) and the shared phar download helper (downloadPhar). Both are present in the summary and objectives. The title is specific and accurate, though it is a fragment rather than a full sentence and does not state why the code moved into a shared library.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 443bd769-6c2d-4ced-87f9-5bf1f2cce544
Commits

Reviewing files that changed from the base of the PR and between 2a409f7 and 55d2c1e.

Files selected for processing: 6

  • .github/actions/release-prep/release-prep.js
  • .github/lib/changelogger.js
  • .github/lib/phar.js
  • .github/lib/pup.js
  • tests/lib/changelogger.test.js
  • tests/lib/phar.test.js

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 6 remain after this review.

@larodiel
larodiel added this pull request to stack #35 November 16, 2026 18:11
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