Skip to content

feat: updated common.mk to include setup and self-update#15

Open
rebEllieous wants to merge 3 commits into
mainfrom
feature/13-update-stale-common.mk
Open

feat: updated common.mk to include setup and self-update#15
rebEllieous wants to merge 3 commits into
mainfrom
feature/13-update-stale-common.mk

Conversation

@rebEllieous
Copy link
Copy Markdown
Contributor

@rebEllieous rebEllieous commented May 20, 2026

What

Closes #13

Why

common.mk was only re-downloaded when it was missing or explicitly deleted. If dev-kit updated the file, consuming repos would silently continue using a stale version until someone manually removed it. This was especially fragile because the logic had to be duplicated in every consuming repo.

Testing

Manually triggered on solar and: confirmed common.mk is re-fetched when content differs and skipped when content is unchanged
Confirmed the 1h rate-limit works: .common.mk-checked prevents redundant network calls within the window
make update-common-mk-bootstrap ran successfully, rewrote the old two-line recipe in-place

Summary by CodeRabbit

  • New Features

    • Build tooling now performs periodic self-checks and will refresh the cached build script when a new version is detected.
    • Added a bootstrap target that initializes the build setup by fetching and placing the required build script and recording its version.
  • Chores

    • Improved initialization stability and robust handling of local build script state.
  • Documentation

    • Updated README snippet showing the new bootstrap and version-tracking usage.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Warning

Rate limit exceeded

@rebEllieous has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 50 minutes and 32 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e0fb1c5b-b2b4-4467-91ae-9580299aa2bc

📥 Commits

Reviewing files that changed from the base of the PR and between 88f1475 and d58fa17.

📒 Files selected for processing (1)
  • common.mk
📝 Walkthrough

Walkthrough

This PR adds automatic self-update detection and refresh to common.mk. It captures the file path early, adds a bootstrap target to rewrite include rules for safe download and bookkeeping, and implements hourly/version-triggered checks that fetch remote common.mk, compare SHA256, and refresh or fallback on failure.

Changes

common.mk Self-Update Mechanism

Layer / File(s) Summary
Path capture foundation
common.mk
_COMMON_MK_PATH is set early from MAKEFILE_LIST to anchor later self-update operations to the correct file instance.
Bootstrap update target
common.mk, README.md
update-common-mk-bootstrap rewrites the including project's common.mk: rule via awk into a bootstrap recipe that downloads to a temp file, moves it into place, writes .common.mk-version, and touches .common.mk-checked. README snippet updated to show the two-step fetch and marker files.
Periodic self-update checking
common.mk
DEV_KIT_VERSION (default main) and _COMMON_MK_SELF_UPDATE implement hourly staleness checks and version-change detection: fetch remote, compare SHA256 with local _COMMON_MK_PATH, delete local file to trigger Make remake on mismatch, or continue with cached version on fetch failure while warning to stderr.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I nibble lines and guard the make,
I fetch and hash for every break.
If versions drift or storms arise,
I swap the file and clear old ties.
A little hop — your build stays awake.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main changes: adding setup and self-update functionality to common.mk for automatic version management.
Description check ✅ Passed The description provides a clear explanation of the problem, solution, and testing performed, matching the template structure with What, Why, and Testing sections.
Linked Issues check ✅ Passed The code changes successfully implement the acceptance criterion: common.mk is now automatically replaced when the upstream version changes via the self-update mechanism and bootstrap target.
Out of Scope Changes check ✅ Passed All changes are directly related to issue #13: common.mk modifications for self-update logic and README updates documenting the new bootstrap approach.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/13-update-stale-common.mk

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
common.mk (1)

257-261: ⚡ Quick win

Verify the hash command on non-GNU developer machines.

sha256sum is not available by default on macOS. Because these calls run during $(shell ...) evaluation under bash -e, a missing binary can abort parsing before the cached fallback path is reached. If Darwin is in the support matrix, add a shasum -a 256 or openssl dgst -sha256 fallback here.

🤖 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 `@common.mk` around lines 257 - 261, The two sha256sum calls used to compute
remote and local_hash (remote=$$(sha256sum .common.mk-download | cut -d' ' -f1);
local_hash=$$(sha256sum '$(_COMMON_MK_PATH)' ...)) are not portable to macOS;
replace them with a portable hash lookup: detect an available tool (sha256sum ||
shasum -a 256 || openssl dgst -sha256) into a HASH_CMD variable or small shell
helper and normalize its output so the existing cut -d' ' -f1 extraction still
works (for example transform shasum or openssl output to "HASH  FILENAME"
format), then use that HASH_CMD to compute remote and local_hash so parsing
under bash -e won't abort on Darwin.
🤖 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 `@common.mk`:
- Around line 251-265: When the fetched remote file matches the local hash
(inside the if branch comparing "$$remote" and "$$local_hash"), persist the
current DEV_KIT_VERSION by writing "$(DEV_KIT_VERSION)" into .common.mk-version
in addition to removing .common.mk-download and touching .common.mk-checked;
update the block that handles the hash match so it sets .common.mk-version
(using the same variable as used earlier), so subsequent runs do not treat the
version as stale even when the file content is identical.
- Around line 223-239: The update-common-mk-bootstrap target currently always
reports success even if the awk script never matches the /^common\.mk:$$/
pattern; modify the recipe so it detects whether awk performed a replacement and
fails if not—e.g. have the awk script set an exit status or write a marker when
it rewrites, and then check that marker (or compare Makefile.tmp to Makefile)
before mv; if no change was made, remove Makefile.tmp and exit non-zero so
update-common-mk-bootstrap fails instead of printing "Updated common.mk:
bootstrap in Makefile".

---

Nitpick comments:
In `@common.mk`:
- Around line 257-261: The two sha256sum calls used to compute remote and
local_hash (remote=$$(sha256sum .common.mk-download | cut -d' ' -f1);
local_hash=$$(sha256sum '$(_COMMON_MK_PATH)' ...)) are not portable to macOS;
replace them with a portable hash lookup: detect an available tool (sha256sum ||
shasum -a 256 || openssl dgst -sha256) into a HASH_CMD variable or small shell
helper and normalize its output so the existing cut -d' ' -f1 extraction still
works (for example transform shasum or openssl output to "HASH  FILENAME"
format), then use that HASH_CMD to compute remote and local_hash so parsing
under bash -e won't abort on Darwin.
🪄 Autofix (Beta)

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

Run ID: ce470898-9507-4982-9062-d8eb5d74d762

📥 Commits

Reviewing files that changed from the base of the PR and between 3111815 and f86ee0f.

📒 Files selected for processing (1)
  • common.mk

Comment thread common.mk
Comment thread common.mk
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@common.mk`:
- Around line 264-265: Replace the hard-coded sha256sum invocation used to
compute remote and local_hash with a portable detection/fallback: detect
available checksum tool (prefer sha256sum, then shasum -a 256, then openssl dgst
-sha256) and use the detected command to compute the digests for remote=$$(...)
and local_hash=$$(...) so the self-update comparison works on macOS and other
systems without sha256sum.
🪄 Autofix (Beta)

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

Run ID: 9a0e4e09-e228-4ddf-8d6c-0adadd353d03

📥 Commits

Reviewing files that changed from the base of the PR and between f86ee0f and 88f1475.

📒 Files selected for processing (2)
  • README.md
  • common.mk

Comment thread common.mk Outdated
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.

common.mk is not automatically re-downloaded if local version is outdated

2 participants