Skip to content

Conversation

@aarmoa
Copy link

@aarmoa aarmoa commented Jul 25, 2025

  • added a Makefile action to assist in the tag process for subfolders

Summary by CodeRabbit

  • New Features

    • Added an automated process to create and push Git tags for multiple subdirectories with a single command.
    • Introduced support for tagging subdirectories with versioned tags based on a provided tag argument.
  • Chores

    • Improved Makefile to streamline release management for subdirectory modules.

@aarmoa aarmoa requested a review from maxim-inj July 25, 2025 14:19
@coderabbitai
Copy link

coderabbitai bot commented Jul 25, 2025

Walkthrough

The Makefile was updated to introduce automated Git tagging for multiple subdirectories using new tag-client and tag-subdirs phony targets. These targets require a TAG argument, fetch tags from origin, create prefixed tags for the client and subdirectories, push them to the remote repository, and include error handling and usage messages.

Changes

File Change Summary
Makefile Added SUBDIR_PREFIXES variable; introduced tag-client and tag-subdirs phony targets for creating and pushing git tags with prefixing and error handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

In the meadow of code, a rabbit hops with glee,
Tagging each subdir, as tidy as can be.
With prefixes in paw, and Makefile in sight,
It stamps out new tags, from morning till night.
"Push and fetch," it cheers, "my work is complete—
For every module, a versioned treat!"
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/add_tagging_script

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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 (2)
Makefile (2)

17-19: Expose SUBDIR_PREFIXES for caller override

Hard-coding the list reduces flexibility for downstream repos or forks that have additional / fewer sub-modules.
Consider allowing a caller override (default fallback keeps current behaviour):

-# Subdirectories for tagging
-SUBDIR_PREFIXES := api core errors store x/circuit x/evidence x/feegrant x/nft x/tx x/upgrade
+# Sub-directories for tagging (caller can override)
+SUBDIR_PREFIXES ?= api core errors store x/circuit x/evidence x/feegrant x/nft x/tx x/upgrade

510-512: Restore the previous branch to avoid leaving users in detached-HEAD

After tagging, contributors remain on a detached commit, which can be confusing:

 	done
 	@echo "Successfully created and pushed all subdir tags for $(TAG)"
+	@orig_branch=$$(git symbolic-ref -q --short HEAD 2>/dev/null || echo ""); \
+	if [ -n "$$orig_branch" ]; then git checkout "$$orig_branch"; fi

Small UX improvement; no functional downside.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1753ce6 and da35c88.

📒 Files selected for processing (1)
  • Makefile (2 hunks)
🧰 Additional context used
🪛 checkmake (0.2.2)
Makefile

[warning] 513-513: Missing required phony target "all"

(minphony)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: tests (00)
  • GitHub Check: tests (03)
  • GitHub Check: tests (02)
  • GitHub Check: tests (01)
  • GitHub Check: test-sim-nondeterminism
  • GitHub Check: test-e2e
  • GitHub Check: liveness-test
  • GitHub Check: test-integration
  • GitHub Check: golangci-lint
  • GitHub Check: dependency-review
  • GitHub Check: build (amd64)
  • GitHub Check: build (arm64)
  • GitHub Check: build (arm)

Makefile Outdated
Comment on lines 496 to 503
tag-subdirs:
ifndef TAG
$(error TAG is required. Usage: make tag-subdirs TAG=v1.2.3)
endif
@echo "Checking out tag $(TAG) from origin..."
@git fetch origin
@git checkout $(TAG)
@echo "Creating and pushing subdir tags for $(TAG)..."
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Validate that the supplied TAG exists before checking out

git checkout $(TAG) will fail – and leave make in a detached-HEAD state – if the tag does not exist locally or remotely.
Add a lightweight verification step and fetch only the tag you need:

-	@echo "Checking out tag $(TAG) from origin..."
-	@git fetch origin
-	@git checkout $(TAG)
+	@echo "Verifying tag $(TAG) exists in origin..."
+	@git fetch --quiet origin "refs/tags/$(TAG):refs/tags/$(TAG)" || \
+		( echo "Tag $(TAG) not found in origin" && exit 1 )
+	@echo "Checking out tag $(TAG)..."
+	@git checkout --detach $(TAG)

Benefits: deterministic fetch, clear error, avoids polluting local branches.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tag-subdirs:
ifndef TAG
$(error TAG is required. Usage: make tag-subdirs TAG=v1.2.3)
endif
@echo "Checking out tag $(TAG) from origin..."
@git fetch origin
@git checkout $(TAG)
@echo "Creating and pushing subdir tags for $(TAG)..."
tag-subdirs:
ifndef TAG
$(error TAG is required. Usage: make tag-subdirs TAG=v1.2.3)
endif
@echo "Verifying tag $(TAG) exists in origin..."
@git fetch --quiet origin "refs/tags/$(TAG):refs/tags/$(TAG)" || \
( echo "Tag $(TAG) not found in origin" && exit 1 )
@echo "Checking out tag $(TAG)..."
@git checkout --detach $(TAG)
@echo "Creating and pushing subdir tags for $(TAG)..."
🤖 Prompt for AI Agents
In the Makefile around lines 496 to 503, before running 'git checkout $(TAG)',
add a verification step to check if the tag exists locally or remotely. Use a
lightweight git command like 'git rev-parse --verify refs/tags/$(TAG)' or 'git
ls-remote --tags origin $(TAG)' to confirm the tag's existence. If the tag does
not exist, output a clear error message and stop the make process. Also, modify
the fetch command to fetch only the specific tag instead of all refs to avoid
unnecessary data and local branch pollution.

Comment on lines +504 to +510
@for prefix in $(SUBDIR_PREFIXES); do \
new_tag="$$prefix/$(TAG)"; \
echo "Creating tag: $$new_tag"; \
git tag "$$new_tag" $(TAG); \
echo "Pushing tag: $$new_tag"; \
git push origin "$$new_tag"; \
done
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Handle pre-existing sub-dir tags to make the rule idempotent

Running the rule twice currently hard-fails on git tag or git push if the tag already exists.
Guard against it and add simple annotation for traceability:

-		new_tag="$$prefix/$(TAG)"; \
-		echo "Creating tag: $$new_tag"; \
-		git tag "$$new_tag" $(TAG); \
-		echo "Pushing tag: $$new_tag"; \
-		git push origin "$$new_tag"; \
+		new_tag="$$prefix/$(TAG)"; \
+		if git rev-parse -q --verify "$$new_tag" >/dev/null; then \
+			echo "Tag $$new_tag already exists – skipping"; \
+		else \
+			echo "Creating tag: $$new_tag"; \
+			git tag -a "$$new_tag" -m "Auto-generated subdir tag for $$prefix $(TAG)" $(TAG); \
+			echo "Pushing tag: $$new_tag"; \
+			git push origin "$$new_tag"; \
+		fi; \

This keeps the target repeatable and prevents accidental failures in CI.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@for prefix in $(SUBDIR_PREFIXES); do \
new_tag="$$prefix/$(TAG)"; \
echo "Creating tag: $$new_tag"; \
git tag "$$new_tag" $(TAG); \
echo "Pushing tag: $$new_tag"; \
git push origin "$$new_tag"; \
done
@for prefix in $(SUBDIR_PREFIXES); do \
new_tag="$$prefix/$(TAG)"; \
if git rev-parse -q --verify "$$new_tag" >/dev/null; then \
echo "Tag $$new_tag already exists – skipping"; \
else \
echo "Creating tag: $$new_tag"; \
git tag -a "$$new_tag" -m "Auto-generated subdir tag for $$prefix $(TAG)" $(TAG); \
echo "Pushing tag: $$new_tag"; \
git push origin "$$new_tag"; \
fi; \
done
🤖 Prompt for AI Agents
In the Makefile around lines 504 to 510, the current tag creation and push
commands fail if the tag already exists, making the rule non-idempotent. Modify
the script to first check if the tag "$$new_tag" already exists using git tag
-l, and only create and push the tag if it does not exist. When creating the
tag, add an annotation with a message for traceability. This will prevent errors
on repeated runs and ensure the rule is repeatable and safe for CI environments.

Copy link

@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

♻️ Duplicate comments (1)
Makefile (1)

518-524: Handle pre-existing sub-dir tags (idempotency)

Same concern as previously raised: re-running the target fails when a tag already exists. Add an existence check before git tag / git push, mirroring the proposed fix for tag-client.

🧹 Nitpick comments (2)
Makefile (2)

17-19: Declare prefixes in a make-safe way

A minor nit: if at some point a path in SUBDIR_PREFIXES contains spaces or other shell-special characters, word-splitting will break the loop later on. Wrapping each item in single quotes (or using a newline-separated variable) future-proofs the rule.


512-517: Redundant second git fetch

tag-subdirs depends on tag-client, which already fetches tags.
The extra fetch here adds latency with no benefit.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between da35c88 and 1a2d5bf.

📒 Files selected for processing (1)
  • Makefile (2 hunks)
🧰 Additional context used
🪛 checkmake (0.2.2)
Makefile

[warning] 527-527: Missing required phony target "all"

(minphony)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: tests (03)
  • GitHub Check: tests (02)
  • GitHub Check: tests (01)
  • GitHub Check: tests (00)
  • GitHub Check: test-e2e
  • GitHub Check: test-integration
  • GitHub Check: test-sim-nondeterminism
  • GitHub Check: liveness-test
  • GitHub Check: build (arm)
  • GitHub Check: build (amd64)
  • GitHub Check: build (arm64)
  • GitHub Check: golangci-lint
  • GitHub Check: dependency-review

Comment on lines +492 to +507
# tag-client creates and pushes the special client tag with v2.0.0- prefix
# Usage: make tag-client TAG=v1.2.3 (creates client/v2.0.0-v1.2.3)
tag-client:
ifndef TAG
$(error TAG is required. Usage: make tag-client TAG=v1.2.3)
endif
@echo "Fetching latest tags from origin..."
@git fetch origin --tags
@echo "Creating client tag for $(TAG)..."
@client_tag="client/v2.0.0-$(TAG)"; \
echo "Creating tag: $$client_tag"; \
git tag "$$client_tag" $(TAG); \
echo "Pushing tag: $$client_tag"; \
git push origin "$$client_tag"
@echo "Successfully created and pushed client tag for $(TAG)"

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

tag-client is not idempotent and lacks basic validation

Running the target twice hard-fails (git tag / git push), and it will happily create a tag even when $(TAG) is missing locally / remotely.

@@
-	@echo "Fetching latest tags from origin..."
-	@git fetch origin --tags
-	@echo "Creating client tag for $(TAG)..."
-	@client_tag="client/v2.0.0-$(TAG)"; \
-	echo "Creating tag: $$client_tag"; \
-	git tag "$$client_tag" $(TAG); \
-	echo "Pushing tag: $$client_tag"; \
-	git push origin "$$client_tag"
+	@echo "Verifying tag $(TAG) exists in origin…"
+	@git fetch --quiet origin "refs/tags/$(TAG):refs/tags/$(TAG)" || \
+		( echo "Tag $(TAG) not found in origin" && exit 1 )
+	@client_tag="client/v2.0.0-$(TAG)"; \
+	if git rev-parse -q --verify "$$client_tag" >/dev/null; then \
+		echo "Tag $$client_tag already exists — skipping"; \
+	else \
+		echo "Creating tag: $$client_tag"; \
+		git tag -a "$$client_tag" -m "Auto-generated client tag for $(TAG)" $(TAG); \
+		echo "Pushing tag: $$client_tag"; \
+		git push origin "$$client_tag"; \
+	fi

Benefits: repeatable runs, clear error message, no local-branch pollution, traceable annotated tag.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# tag-client creates and pushes the special client tag with v2.0.0- prefix
# Usage: make tag-client TAG=v1.2.3 (creates client/v2.0.0-v1.2.3)
tag-client:
ifndef TAG
$(error TAG is required. Usage: make tag-client TAG=v1.2.3)
endif
@echo "Fetching latest tags from origin..."
@git fetch origin --tags
@echo "Creating client tag for $(TAG)..."
@client_tag="client/v2.0.0-$(TAG)"; \
echo "Creating tag: $$client_tag"; \
git tag "$$client_tag" $(TAG); \
echo "Pushing tag: $$client_tag"; \
git push origin "$$client_tag"
@echo "Successfully created and pushed client tag for $(TAG)"
# tag-client creates and pushes the special client tag with v2.0.0- prefix
# Usage: make tag-client TAG=v1.2.3 (creates client/v2.0.0-v1.2.3)
tag-client:
ifndef TAG
$(error TAG is required. Usage: make tag-client TAG=v1.2.3)
endif
@echo "Verifying tag $(TAG) exists in origin…"
@git fetch --quiet origin "refs/tags/$(TAG):refs/tags/$(TAG)" || \
( echo "Tag $(TAG) not found in origin" && exit 1 )
@client_tag="client/v2.0.0-$(TAG)"; \
if git rev-parse -q --verify "$$client_tag" >/dev/null; then \
echo "Tag $$client_tag already exists — skipping"; \
else \
echo "Creating tag: $$client_tag"; \
git tag -a "$$client_tag" -m "Auto-generated client tag for $(TAG)" $(TAG); \
echo "Pushing tag: $$client_tag"; \
git push origin "$$client_tag"; \
fi
@echo "Successfully created and pushed client tag for $(TAG)"
🤖 Prompt for AI Agents
In the Makefile from lines 492 to 507, the tag-client target is not idempotent
and lacks validation, causing failures if run multiple times or if the TAG does
not exist locally or remotely. To fix this, add checks to verify that the TAG
exists locally before creating the client tag, and check if the client tag
already exists to avoid duplicate creation. Use annotated tags instead of
lightweight tags for traceability, and handle errors gracefully with clear
messages. Also, ensure the tag push only happens if the tag creation succeeds,
making the process repeatable and safe.

@maxim-inj maxim-inj merged commit ac26c4b into v0.50.x-inj Aug 4, 2025
41 of 46 checks passed
@maxim-inj maxim-inj deleted the chore/add_tagging_script branch August 4, 2025 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants