This is an automated email from the ASF dual-hosted git repository.
guanmingchiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/mahout.git
The following commit(s) were added to refs/heads/main by this push:
new 805c5a551 feat: add make test & make pre-commit to enhance development
flow (#943)
805c5a551 is described below
commit 805c5a551e67ab896293f570dc586985a2a99f0c
Author: Ryan Huang <[email protected]>
AuthorDate: Wed Jan 28 01:02:11 2026 +0800
feat: add make test & make pre-commit to enhance development flow (#943)
* Implement conditional testing for Rust and Python
Add tests for Rust and Python based on NVIDIA GPU detection.
* Add Apache License information to Makefile
Added licensing information to the Makefile.
* Add test_rust target to Makefile
* Update CONTRIBUTING.md with test and pre-commit instructions
Added instructions for running tests and pre-commit checks.
* Update test instructions in CONTRIBUTING.md
Reformatted the test section to improve clarity and consistency.
* Rename 'test' target to 'tests' in Makefile
* Update Makefile to improve GPU detection and tasks
---
CONTRIBUTING.md | 10 ++++++++++
Makefile | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a01a3ab6e..ed88897de 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -77,6 +77,11 @@ The project uses a unified test workflow with pytest. Tests
are organized in the
- `testing/utils/` - Shared test utilities and helpers
- `testing/conftest.py` - Pytest configuration with shared fixtures
+To run all tests:
+```
+make tests
+```
+
See [testing/README.md](testing/README.md) for detailed testing documentation.
### 2.4 Pre-commit Checks
@@ -93,6 +98,11 @@ Or run pre-commit hooks on all files:
pre-commit run --all-files
```
+Or run pre-commit with makefile style (that ensures you uses `pre-commit` in
uv's venv)
+```bash
+make pre-commit
+```
+
### 2.5 Create a Pull Request
Create a pull request on GitHub. Please follow the [pull request
template](.github/PULL_REQUEST_TEMPLATE) to provide a detailed description of
your changes.
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..636b2ee60
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,43 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+.PHONY: test_rust test_python tests pre-commit setup-test-python
+
+# Detect NVIDIA GPU
+HAS_NVIDIA := $(shell command -v nvidia-smi >/dev/null 2>&1 && nvidia-smi -L
>/dev/null 2>&1 && echo yes || echo no)
+
+setup-test-python:
+ uv sync --group dev
+
+test_rust:
+ifeq ($(HAS_NVIDIA),yes)
+ cd qdp && cargo test
+else
+ @echo "[SKIP] No NVIDIA GPU detected, skipping test_rust"
+endif
+
+test_python: setup-test-python
+ifeq ($(HAS_NVIDIA),yes)
+ unset CONDA_PREFIX && uv run --active maturin develop --manifest-path
qdp/qdp-python/Cargo.toml
+else
+ @echo "[SKIP] No NVIDIA GPU detected, skipping maturin develop"
+endif
+ uv run pytest
+
+tests: test_rust test_python
+
+pre-commit: setup-test-python
+ uv run pre-commit run --all-files