Skip to content

Add makefile and format check#10

Merged
Eeems merged 1 commit into
mainfrom
makefile
Aug 8, 2025
Merged

Add makefile and format check#10
Eeems merged 1 commit into
mainfrom
makefile

Conversation

@Eeems
Copy link
Copy Markdown
Owner

@Eeems Eeems commented Aug 8, 2025

Summary by CodeRabbit

  • Chores
    • Introduced automated linting and formatting checks in the continuous integration workflow.
    • Unified build, test, lint, and release commands under a new Makefile for easier project management.
    • Improved test script to avoid unnecessary recreation of the Python virtual environment.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 8, 2025

Walkthrough

A Makefile was introduced to standardize build, test, lint, and release operations for the Python project. The CI workflow was updated to utilize these Makefile targets, add a dedicated linting job, and ensure linting completes before building. The test script now only creates a virtual environment if it does not already exist.

Changes

Cohort / File(s) Change Summary
Makefile Introduction
Makefile
Added a Makefile with targets for build, test, lint, format, release, and environment management using variables.
CI Workflow Updates
.github/workflows/build.yaml
Added a lint job, updated test to use make test, made build depend on lint and test, and unified commands under Makefile targets.
Test Script Improvement
test.sh
Modified to only create the .venv virtual environment if it does not already exist.

Sequence Diagram(s)

sequenceDiagram
    participant GitHub Actions
    participant Makefile
    participant test.sh

    GitHub Actions->>Makefile: make lint
    GitHub Actions->>Makefile: make test
    Makefile->>test.sh: ./test.sh
    GitHub Actions->>Makefile: make release
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

In the warren where code bunnies dwell,
A Makefile now rings the build bell.
Linting hops in, CI flows anew,
Test script checks if the venv grew.
With every whisker and every hop,
This rabbit keeps the code tip-top! 🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch makefile

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
🪧 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.
  • 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.

Support

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

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.

@Eeems Eeems force-pushed the makefile branch 2 times, most recently from 73e26ee to b666903 Compare August 8, 2025 16:33
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: 10

🧹 Nitpick comments (4)
test.sh (1)

3-5: Good improvement: avoid re-creating venv on every run

The conditional venv creation is correct and avoids unnecessary work.

If you want to guard against stale/interpreter-mismatched venvs, consider checking the Python version inside .venv and recreating when it doesn’t match.

wheel_name.py (1)

7-12: Broaden import exception to avoid missing submodule edge-cases

Catching only ModuleNotFoundError can miss ImportError from submodule resolution. Catch ImportError to be safe.

-    except ModuleNotFoundError:
+    except ImportError:
         pass
Makefile (2)

50-55: clean may warn on macOS (missing mountpoint/umount flags)

mountpoint isn’t available on macOS; umount -ql is Linux-specific. Guard command presence and use portable flags.

 clean:
-	if [ -d .venv/mnt ] && mountpoint -q .venv/mnt; then \
-	    umount -ql .venv/mnt; \
-	fi
+	if [ -d .venv/mnt ]; then \
+	  if command -v mountpoint >/dev/null 2>&1 && mountpoint -q .venv/mnt; then \
+	    umount -ql .venv/mnt || true; \
+	  elif mount | grep -qE "\.venv/mnt( |$)"; then \
+	    umount .venv/mnt || true; \
+	  fi; \
+	fi
 	git clean --force -dX

75-82: Bootstrap: consider upgrading pip and minimizing duplicate installs

Small quality-of-life improvements.

 	@echo "Setting up development virtual env in .venv"
 	python -m venv .venv
 	. ${VENV_BIN_ACTIVATE}; \
-	python -m pip install wheel build ruff; \
+	python -m pip install --upgrade pip; \
+	python -m pip install --upgrade wheel build ruff; \
 	python -m pip install \
 	    -r requirements.txt
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 85c24aa and b666903.

📒 Files selected for processing (4)
  • .github/workflows/build.yaml (3 hunks)
  • Makefile (1 hunks)
  • test.sh (1 hunks)
  • wheel_name.py (1 hunks)
🧰 Additional context used
🪛 checkmake (0.2.2)
Makefile

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

(minphony)


[warning] 104-104: Missing required phony target "clean"

(minphony)


[warning] 104-104: Missing required phony target "test"

(minphony)


[warning] 56-56: Target "build" should be declared PHONY.

(phonydeclared)


[warning] 58-58: Target "release" should be declared PHONY.

(phonydeclared)


[warning] 60-60: Target "sdist" should be declared PHONY.

(phonydeclared)


[warning] 62-62: Target "wheel" should be declared PHONY.

(phonydeclared)


[warning] 86-86: Target "all" should be declared PHONY.

(phonydeclared)

🪛 actionlint (1.7.7)
.github/workflows/build.yaml

21-21: property "python" is not defined in object type {}

(expression)

🔇 Additional comments (3)
.github/workflows/build.yaml (3)

24-25: lint runs both lint and format (diff) — intentional?

Running make lint format will fail if formatting changes are needed (ruff format --diff). If that’s intended as a gate, LGTM.

Confirm this is desired to block on unformatted code.


76-76: Good: unify CI to use Makefile

Switching to make test aligns CI and local workflows.


80-80: Appropriate build gating

Making build depend on test and lint is correct.

Comment thread .github/workflows/build.yaml
Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread Makefile
Comment thread wheel_name.py Outdated
Comment thread wheel_name.py Outdated
Comment thread wheel_name.py Outdated
Comment thread wheel_name.py Outdated
@Eeems Eeems force-pushed the makefile branch 5 times, most recently from 8e1dd6e to 7b8d0d4 Compare August 8, 2025 17:11
@Eeems
Copy link
Copy Markdown
Owner Author

Eeems commented Aug 8, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 8, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

♻️ Duplicate comments (2)
Makefile (2)

5-10: OBJ should be a single-level glob (learned preference) and avoid ‘’**

GNU make’s wildcard doesn’t recurse with “**” by default; per repo preference, keep it non-recursive and explicit.

-OBJ := $(wildcard ${PACKAGE}/**)
+OBJ := $(wildcard $(PACKAGE)/*)

35-46: Don’t predict wheel filename; make ‘wheel’ build the wheel directly

Wheel tags vary (pure vs platform, PEP 425/440 normalization). Binding the target to dist/${PACKAGE}-${VERSION}-py3-none-any.whl is brittle. Make wheel a PHONY aggregator that runs build and avoid a file-specific dependency. Keep sdist as-is if you want the predictable tar.gz.

-wheel: dist/${PACKAGE}-${VERSION}-py3-none-any.whl
+wheel: ${VENV_BIN_ACTIVATE} dist $(OBJ)
+	. ${VENV_BIN_ACTIVATE}; \
+	$(PYTHON) -m build --wheel
@@
-dist/${PACKAGE}-${VERSION}-py3-none-any.whl: ${VENV_BIN_ACTIVATE} dist $(OBJ)
-	. ${VENV_BIN_ACTIVATE}; \
-	python -m build --wheel
+## wheel artifact path may vary (pure vs platform). Avoid predicting filename; use dist/*.whl if needed.
🧹 Nitpick comments (2)
Makefile (2)

41-46: Consistency: use $(PYTHON) and fail-fast in multi-line recipes

Use $(PYTHON) consistently and add “set -euo pipefail” to stop on failures within chained commands.

-	. ${VENV_BIN_ACTIVATE}; \
-	python -m build --sdist
+	set -euo pipefail; \
+	. ${VENV_BIN_ACTIVATE}; \
+	$(PYTHON) -m build --sdist

If you keep the separate wheel file rule elsewhere, apply the same pattern there too.


48-55: Virtualenv setup: use $(PYTHON) and upgrade pip before installs

Minor hardening for reproducibility and cross-version consistency.

 ${VENV_BIN_ACTIVATE}: requirements.txt
 	@echo "Setting up development virtual env in .venv"
-	python -m venv .venv
-	. ${VENV_BIN_ACTIVATE}; \
-	python -m pip install wheel build ruff; \
-	python -m pip install \
+	$(PYTHON) -m venv .venv
+	set -euo pipefail; \
+	. ${VENV_BIN_ACTIVATE}; \
+	$(PYTHON) -m pip install -U pip setuptools wheel; \
+	$(PYTHON) -m pip install build ruff; \
+	$(PYTHON) -m pip install \
 	    -r requirements.txt
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 36a248a and 7b8d0d4.

📒 Files selected for processing (3)
  • .github/workflows/build.yaml (3 hunks)
  • Makefile (1 hunks)
  • test.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/build.yaml
  • test.sh
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-08T16:50:44.221Z
Learnt from: Eeems
PR: Eeems/python-ext4#10
File: Makefile:0-0
Timestamp: 2025-08-08T16:50:44.221Z
Learning: In this repository’s current structure, the package directory does not require recursive file discovery; keep OBJ non-recursive (single-level glob) in the Makefile.

Applied to files:

  • Makefile
🪛 checkmake (0.2.2)
Makefile

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

(minphony)


[warning] 77-77: Missing required phony target "clean"

(minphony)


[warning] 77-77: Missing required phony target "test"

(minphony)


[warning] 29-29: Target "build" should be declared PHONY.

(phonydeclared)


[warning] 31-31: Target "release" should be declared PHONY.

(phonydeclared)


[warning] 33-33: Target "sdist" should be declared PHONY.

(phonydeclared)


[warning] 35-35: Target "wheel" should be declared PHONY.

(phonydeclared)


[warning] 59-59: Target "all" should be declared PHONY.

(phonydeclared)

🔇 Additional comments (1)
Makefile (1)

56-58: No Makefile change needed: test.sh creates and sources the venv

The test.sh script already handles creating and activating the .venv (lines 6–9), so the Makefile target can simply invoke it without an extra source step.

Comment thread Makefile
@Eeems Eeems force-pushed the makefile branch 2 times, most recently from f90d3f4 to ab569d1 Compare August 8, 2025 18:17
@Eeems
Copy link
Copy Markdown
Owner Author

Eeems commented Aug 8, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 8, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 0

♻️ Duplicate comments (2)
Makefile (2)

5-10: Use a single-level glob for OBJ (clarity; avoid unintended recursion/directories).

Per repo preference, make the intent explicit and avoid matching directories or deeper paths.

-OBJ := $(wildcard ${PACKAGE}/**)
+OBJ := $(wildcard $(PACKAGE)/*)
 OBJ += requirements.txt
 OBJ += pyproject.toml
 OBJ += README.md
 OBJ += LICENSE

33-36: Don’t predict dist filenames; make sdist/wheel build into dist/ without file-tied targets.

Predicting exact names is brittle (normalization, tags, backend differences). Build targets should be PHONY and not depend on computed filenames.

-sdist: dist/${PACKAGE}-${VERSION}.tar.gz
-
-wheel: dist/${PACKAGE}-${VERSION}-py3-none-any.whl
+sdist: ${VENV_BIN_ACTIVATE} dist $(OBJ)
+	. ${VENV_BIN_ACTIVATE}; \
+	$(PYTHON) -m build --sdist
+
+wheel: ${VENV_BIN_ACTIVATE} dist $(OBJ)
+	. ${VENV_BIN_ACTIVATE}; \
+	$(PYTHON) -m build --wheel
@@
-dist/${PACKAGE}-${VERSION}.tar.gz: ${VENV_BIN_ACTIVATE} dist $(OBJ)
-	. ${VENV_BIN_ACTIVATE}; \
-	$(PYTHON) -m build --sdist
-
-dist/${PACKAGE}-${VERSION}-py3-none-any.whl: ${VENV_BIN_ACTIVATE} dist $(OBJ)
-	. ${VENV_BIN_ACTIVATE}; \
-	$(PYTHON) -m build --wheel
+# File-specific rules removed to avoid filename coupling; artifacts land in dist/

This keeps your existing release/build graph intact while avoiding filename coupling.

Also applies to: 40-46

🧹 Nitpick comments (2)
Makefile (2)

11-20: SHELL=/bin/bash on Windows may break; set bash only on non-Windows.

On Windows_NT, /bin/bash may not exist. Consider scoping SHELL to non-Windows.

-SHELL := /bin/bash
-ifeq ($(OS),Windows_NT)
+ifeq ($(OS),Windows_NT)
 	ifeq ($(VENV_BIN_ACTIVATE),)
 		VENV_BIN_ACTIVATE := .venv/Scripts/activate
 	endif
 else
+SHELL := /bin/bash
 	ifeq ($(VENV_BIN_ACTIVATE),)
 		VENV_BIN_ACTIVATE := .venv/bin/activate
 	endif
 endif

Please confirm whether Windows is a supported dev env here; if not, we can skip this.


26-28: Consider removing build artifacts not tracked by .gitignore.

git clean -dX preserves untracked, non-ignored artifacts. Optionally add explicit removal.

 clean:
-	git clean --force -dX
+	git clean --force -dX
+	@rm -rf dist build *.egg-info || true
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7b8d0d4 and ab569d1.

📒 Files selected for processing (3)
  • .github/workflows/build.yaml (3 hunks)
  • Makefile (1 hunks)
  • test.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • test.sh
  • .github/workflows/build.yaml
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-08-08T18:16:46.168Z
Learnt from: Eeems
PR: Eeems/python-ext4#10
File: Makefile:2-3
Timestamp: 2025-08-08T18:16:46.168Z
Learning: In the python-ext4 repository, Eeems prefers simple shell-based parsing (grep/tr pipelines) in the Makefile over more robust but complex solutions like Python TOML parsers, following the YAGNI principle until there's an actual need for the added complexity.

Applied to files:

  • Makefile
📚 Learning: 2025-08-08T16:50:44.221Z
Learnt from: Eeems
PR: Eeems/python-ext4#10
File: Makefile:0-0
Timestamp: 2025-08-08T16:50:44.221Z
Learning: In this repository’s current structure, the package directory does not require recursive file discovery; keep OBJ non-recursive (single-level glob) in the Makefile.

Applied to files:

  • Makefile
📚 Learning: 2025-08-08T14:41:18.073Z
Learnt from: Eeems
PR: Eeems/python-ext4#8
File: test.py:0-0
Timestamp: 2025-08-08T14:41:18.073Z
Learning: Repository: Eeems/python-ext4 — In test.py, the test framework intentionally uses an eval-based _assert(source: str) to display the expression alongside pass/fail. Avoid suggesting replacements with direct assert statements in this file to preserve the intended output format.

Applied to files:

  • Makefile
🪛 checkmake (0.2.2)
Makefile

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

(minphony)


[warning] 77-77: Missing required phony target "clean"

(minphony)


[warning] 77-77: Missing required phony target "test"

(minphony)


[warning] 29-29: Target "build" should be declared PHONY.

(phonydeclared)


[warning] 31-31: Target "release" should be declared PHONY.

(phonydeclared)


[warning] 33-33: Target "sdist" should be declared PHONY.

(phonydeclared)


[warning] 35-35: Target "wheel" should be declared PHONY.

(phonydeclared)


[warning] 59-59: Target "all" should be declared PHONY.

(phonydeclared)

🔇 Additional comments (3)
Makefile (3)

2-3: Keep simple grep/tr parsing (fits YAGNI preference).

This matches the repo’s preference to avoid TOML parsers unless needed. No change required.


61-75: Good separation of lint vs format, and lint-fix uses --fix.

Targets are clear and idempotent inside venv. LGTM.


77-87: .PHONY coverage looks complete.

all, build, clean, sdist, wheel, test, lint, lint-fix, format, format-fix are declared. Good.

@Eeems Eeems merged commit dfce902 into main Aug 8, 2025
26 checks passed
@Eeems Eeems deleted the makefile branch August 8, 2025 19:34
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