Skip to content

Report exact installed YiiPress version - #133

Merged
samdark merged 3 commits into
masterfrom
fix/exact-installed-version
Aug 4, 2026
Merged

Report exact installed YiiPress version#133
samdark merged 3 commits into
masterfrom
fix/exact-installed-version

Conversation

@samdark

@samdark samdark commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • resolve and print the exact release tag before the shell installer downloads the binary
  • embed release tags in tagged builds and full commit SHAs in development artifacts
  • verify packaged versions across Linux, macOS, and Windows release workflows
  • document version reporting and cover installer/build configuration

Tests

  • make test tests/Unit/Packaging/InstallerTest.php tests/Unit/ApplicationInfoTest.php tests/Unit/Packaging/ConfigurationPackagingTest.php — passed, 39 tests and 595 assertions
  • make test tests/Unit/Packaging/ConfigurationPackagingTest.php tests/Unit/ApplicationInfoTest.php — passed, 32 tests and 488 assertions

The full local suite is currently affected by CRLF checkout line endings: executable tests fail with /usr/bin/env: php\r: No such file or directory.

Summary by CodeRabbit

Release Notes

  • New Features

    • Binaries now report their actual version or commit SHA instead of default placeholders
    • Installation script enhanced to resolve and verify checksums for the latest release
  • Documentation

    • Updated installation documentation to clarify version reporting across different package types

Copilot AI lite review requested due to automatic review settings August 4, 2026 15:25
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@samdark, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 8ab109d6-caad-464d-82a9-8dbc38ad548d

📥 Commits

Reviewing files that changed from the base of the PR and between b0ddfdb and 79858ae.

📒 Files selected for processing (9)
  • .github/workflows/package-static.yml
  • .github/workflows/release.yml
  • build/package-phar.php
  • install.sh
  • src/ApplicationInfo.php
  • tests/Console/ConsoleRunnerTest.php
  • tests/Unit/ApplicationInfoTest.php
  • tests/Unit/Packaging/ConfigurationPackagingTest.php
  • tests/Unit/Packaging/InstallerTest.php
📝 Walkthrough

Walkthrough

This PR embeds a Git commit SHA into packaged binaries and PHAR archives. ApplicationInfo gains a COMMIT constant and updated version-resolution logic. CI workflows verify binary version output instead of --help. install.sh resolves the latest release URL through checksum redirects.

Changes

Commit metadata propagation and version resolution

Layer / File(s) Summary
ApplicationInfo version resolution
src/ApplicationInfo.php, tests/Console/ConsoleRunnerTest.php, tests/Unit/ApplicationInfoTest.php
Adds the COMMIT constant, changes default VERSION to 'unknown', and updates version() fallback order. Tests updated to match.
PHAR commit injection
build/package-phar.php
Validates YIIPRESS_COMMIT format and replaces the COMMIT constant in src/ApplicationInfo.php when packaging.
Build and Docker wiring
Makefile, docker/Dockerfile
Makefile exports YIIPRESS_COMMIT from git rev-parse HEAD and passes it as a build argument. Dockerfile's phar-builder stage accepts COMPOSER_ROOT_VERSION and YIIPRESS_COMMIT build args for composer install and PHAR generation.
CI workflow version smoke tests
.github/workflows/package-static.yml, .github/workflows/release.yml, tests/Unit/Packaging/ConfigurationPackagingTest.php
Workflows pass commit and root-version values into builds. Linux, Windows, and macOS checks assert exact version output instead of --help. Packaging tests verify these workflow and Docker/PHAR argument changes.
Installer latest-release resolution
install.sh, docs/binaries-phar-docker.md, tests/Unit/Packaging/InstallerTest.php
install.sh downloads SHA256SUMS first, resolves the latest release URL and version through redirects, and uses that URL for the archive download. Docs and installer tests updated accordingly.

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

Sequence Diagram(s)

sequenceDiagram
  participant Workflow as CI Workflow
  participant Docker as docker/Dockerfile
  participant Phar as package-phar.php
  participant Binary as Packaged Binary

  Workflow->>Docker: build-arg YIIPRESS_COMMIT, COMPOSER_ROOT_VERSION
  Docker->>Phar: run with YIIPRESS_COMMIT env
  Phar->>Binary: embed COMMIT constant in ApplicationInfo.php
  Workflow->>Binary: run --version
  Binary-->>Workflow: report version matching release tag or commit SHA
Loading
sequenceDiagram
  participant User as install.sh
  participant Checksums as SHA256SUMS endpoint
  participant Release as Release URL

  User->>Checksums: request SHA256SUMS for latest
  Checksums-->>User: redirect to resolved release URL
  User->>User: derive version from resolved URL
  User->>Release: download archive from resolved URL
  Release-->>User: return packaged binary
Loading

Possibly related PRs

  • yiipress/engine#33: Extends the same packaging workflows, Makefile targets, Docker build stages, and packaging tests with commit/version metadata propagation.
  • yiipress/engine#131: Modifies install.sh and its installer tests; the main PR refines the latest-release URL and version resolution introduced there.
  • yiipress/engine#44: Modifies the same package-static and release workflows to build and validate distribution artifacts.

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: reporting the exact installed YiiPress version.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/exact-installed-version

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves YiiPress version reporting by resolving the exact release tag during installation, and by embedding reproducible version identifiers (release tags for tagged builds; full commit SHAs for development artifacts) into packaged outputs. It also tightens CI smoke tests to verify --version across Linux/macOS/Windows artifacts and documents the behavior.

Changes:

  • Resolve the effective GitHub release download URL for latest in install.sh so the installer prints the exact tag before downloading.
  • Rework ApplicationInfo::version() to prefer a stable Composer pretty version, otherwise fall back to an embedded commit SHA or Composer reference/placeholder.
  • Thread YIIPRESS_COMMIT/COMPOSER_ROOT_VERSION through Docker build + workflows, and update/extend unit tests to validate the new behavior.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Unit/Packaging/InstallerTest.php Extends the curl stub and assertions to verify the installer prints the resolved latest tag.
tests/Unit/Packaging/ConfigurationPackagingTest.php Updates workflow expectations to validate --version smoke tests and commit/tag propagation.
tests/Unit/ApplicationInfoTest.php Adjusts version expectations to allow release tags, commit SHAs, or unknown, and asserts default COMMIT behavior in tests.
tests/Console/ConsoleRunnerTest.php Updates console banner expectation to match new default version fallback behavior.
src/ApplicationInfo.php Implements new version resolution rules (stable tag first; otherwise commit/reference/unknown).
Makefile Exports YIIPRESS_COMMIT and passes it into Docker packaging builds.
install.sh Resolves latest to the final release URL and prints the exact version tag before downloading assets.
docs/binaries-phar-docker.md Documents installer/version reporting semantics for releases vs development artifacts.
docker/Dockerfile Adds build args/env wiring so PHAR packaging can embed commit and tagged builds can set root version.
build/package-phar.php Validates YIIPRESS_COMMIT and injects it into ApplicationInfo for packaged artifacts.
.github/workflows/release.yml Passes version/commit build args and changes smoke tests to assert exact --version output.
.github/workflows/package-static.yml Passes commit build arg and updates smoke tests to assert --version output in nightly builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ApplicationInfo.php Outdated
Comment thread build/package-phar.php Outdated
Comment thread build/package-phar.php

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5

🧹 Nitpick comments (1)
tests/Unit/Packaging/ConfigurationPackagingTest.php (1)

284-306: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add assertions for every platform version check.

The new PHPUnit assertions do not cover every changed workflow behavior. The package-static test checks the Linux build argument and only the Windows/macOS --version invocations. It does not check the inherited YIIPRESS_COMMIT value or the complete equality checks. The release test also omits the YIIPRESS_COMMIT Docker build argument and the complete Windows equality check.

Add exact assertions for these strings so a regression cannot remove commit propagation or weaken a smoke test while the PHPUnit test still passes.

Suggested assertions
+ self::assertStringContainsString('YIIPRESS_COMMIT: ${{ github.sha }}', $workflow);
+ self::assertStringContainsString(
+     'if ((./dist/windows-amd64/yiipress.exe --version) -ne "YiiPress $env:GITHUB_SHA")',
+     $workflow,
+ );
+ self::assertStringContainsString(
+     'test "$(./dist/macos-arm64/yiipress --version)" = "YiiPress ${GITHUB_SHA}"',
+     $workflow,
+ );
+ self::assertStringContainsString('YIIPRESS_COMMIT=${{ github.sha }}', $workflow);
+ self::assertStringContainsString(
+     'if ((./dist/windows-amd64/yiipress.exe --version) -ne "YiiPress $env:GITHUB_REF_NAME")',
+     $workflow,
+ );

As per coding guidelines, **/*Test.php: For each piece of code add a test using phpunit.

Also applies to: 459-470

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/Unit/Packaging/ConfigurationPackagingTest.php` around lines 284 - 306,
Update the workflow assertions in the affected packaging tests, including the
corresponding release-test section, to cover every platform version check and
exact equality condition. Add exact string assertions for inherited
YIIPRESS_COMMIT propagation, the Linux build argument, the complete Windows and
macOS version invocations/equality checks, and the release Docker
YIIPRESS_COMMIT argument, using the existing PHPUnit assertion style.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@install.sh`:
- Around line 62-69: The latest-version branch derives version from curl’s final
URL, which may include a query string and produce an invalid tag. Update the
latest resolution logic in install.sh to resolve the GitHub release tag before
downloading SHA256SUMS or the archive, using redirect Location parsing or the
releases API; ensure release_url and version contain only the canonical release
path/tag without query parameters.

In `@src/ApplicationInfo.php`:
- Around line 19-23: Update the version validation in the ApplicationInfo
version-resolution logic to reject Composer development aliases ending in
“-dev”, including values such as “1.0.x-dev”, before returning $version.
Preserve acceptance of valid release versions and the existing fallback order
through COMMIT, InstalledVersions::getReference('yiipress/engine'), and
self::VERSION.

In `@tests/Console/ConsoleRunnerTest.php`:
- Line 23: Update the assertion in ConsoleRunnerTest to derive the expected
version from ApplicationInfo::version(), or establish deterministic Composer
metadata with an empty COMMIT before invoking the console runner; preserve the
existing output assertion while avoiding a hardcoded “YiiPress unknown” value.

In `@tests/Unit/ApplicationInfoTest.php`:
- Around line 17-18: Update the version assertion in the ApplicationInfo version
test to anchor the regular expression at the end, ensuring the complete value
matches only a semantic version, 40-character commit hash, or “unknown”; add
exact assertions for fallback values where applicable.

In `@tests/Unit/Packaging/InstallerTest.php`:
- Around line 46-59: Update the mock curl handling in the InstallerTest fixture
so the %{url_effective} response appends a representative query string after the
asset filename, such as signed CDN parameters. Extend the installer assertions
to verify it still extracts the correct version and downloads the expected asset
URL when the effective URL has trailing query parameters.

---

Nitpick comments:
In `@tests/Unit/Packaging/ConfigurationPackagingTest.php`:
- Around line 284-306: Update the workflow assertions in the affected packaging
tests, including the corresponding release-test section, to cover every platform
version check and exact equality condition. Add exact string assertions for
inherited YIIPRESS_COMMIT propagation, the Linux build argument, the complete
Windows and macOS version invocations/equality checks, and the release Docker
YIIPRESS_COMMIT argument, using the existing PHPUnit assertion style.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 820429e3-48a4-4996-ae73-4764c0aac457

📥 Commits

Reviewing files that changed from the base of the PR and between b31e8dc and b0ddfdb.

📒 Files selected for processing (12)
  • .github/workflows/package-static.yml
  • .github/workflows/release.yml
  • Makefile
  • build/package-phar.php
  • docker/Dockerfile
  • docs/binaries-phar-docker.md
  • install.sh
  • src/ApplicationInfo.php
  • tests/Console/ConsoleRunnerTest.php
  • tests/Unit/ApplicationInfoTest.php
  • tests/Unit/Packaging/ConfigurationPackagingTest.php
  • tests/Unit/Packaging/InstallerTest.php

Comment thread install.sh
Comment thread src/ApplicationInfo.php Outdated
Comment thread tests/Console/ConsoleRunnerTest.php Outdated
Comment thread tests/Unit/ApplicationInfoTest.php Outdated
Comment thread tests/Unit/Packaging/InstallerTest.php
@samdark
samdark merged commit e745778 into master Aug 4, 2026
13 checks passed
@samdark
samdark deleted the fix/exact-installed-version branch August 4, 2026 17:01
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.

2 participants