Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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.

header:
license:
spdx-id: Apache-2.0
copyright-owner: Apache Software Foundation

paths-ignore:
- "LICENSE"
- "NOTICE"
- ".gitattributes"
- "**/*.json"
- "target"
- "Cargo.lock"
- ".github/*.md"
- "bindings/go/**/go.mod"
- "bindings/go/**/go.sum"
comment: on-failure
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,19 @@ docker-up:
# Stop and remove Docker containers, networks, and volumes.
docker-down:
docker compose -f dev/docker-compose.yaml down -v

# Code quality checks
check:
./dev/check.sh

check-fix:
./dev/check.sh --fix

check-fmt:
cargo fmt --all -- --check

check-clippy:
cargo clippy --all-targets --all-features --workspace -- -D warnings

test:
cargo test --workspace
102 changes: 102 additions & 0 deletions dev/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash
# 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.

set -e

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
AUTO_FIX=false

# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--fix)
AUTO_FIX=true
shift
;;
*)
echo "Unknown option: $1"
echo "Usage: $0 [--fix]"
exit 1
;;
esac
done

cd "$PROJECT_ROOT"

echo "========================================"
echo "Running code checks for paimon-rust"
echo "========================================"

# 1. Check license headers
echo ""
echo "[1/4] Checking license headers..."
if command -v license-eye &> /dev/null; then
license-eye header check
Copy link
Contributor

Choose a reason for hiding this comment

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

This project already uses skywalking-eyes to check for licenses.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where is the skywalking-eyes? You mean ci.yml? I added this script to facilitate local verification.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the skywalking-eyes? You mean ci.yml? I added this script to facilitate local verification.

Nice initiative! For the "facilitate local verification" goal, a pre-commit hook might be more appropriate — it runs automatically on every commit, so contributors can't forget. Consider adding a .pre-commit-config.yaml for fmt/clippy checks. The Makefile targets and .licenserc.yaml are still valuable and can be kept. The dev/check.sh script could be simplified or removed if pre-commit covers the same ground.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I will try it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! I did look into pre-commit hooks and .pre-commit-config.yaml before going with dev/check.sh.

I don't think it's necessary to introduce git hooks at present. Because it cannot be uploaded to the repository, or relies on external plugins, or is manually configured, and the current repository is not very large at present.

dev/check.sh provides an easy, zero-dependency way for contributors to verify locally, and CI serves as the final safeguard. I think this combination is sufficient for the current project scale without introducing additional tooling overhead. We can revisit this if the project grows and the team scales.

echo "✓ License check passed"
else
echo "⚠ Failed to check license headers. license-eye not installed, skipping license check"
fi

# 2. Check code formatting (with auto-fix)
echo ""
echo "[2/4] Checking code formatting (cargo fmt)..."
if ! cargo fmt --all -- --check; then
if [ "$AUTO_FIX" = true ]; then
echo "Fixing formatting issues..."
cargo fmt --all
echo "✓ Format fixed"
else
echo "✗ Format check failed. Run with --fix to auto-fix, or run 'cargo fmt --all' manually."
exit 1
fi
else
echo "✓ Format check passed"
fi

# 3. Run clippy (with auto-fix)
echo ""
echo "[3/4] Running clippy..."
if ! cargo clippy --all-targets --all-features --workspace -- -D warnings 2>&1; then
if [ "$AUTO_FIX" = true ]; then
echo "Attempting to fix clippy issues..."
cargo clippy --fix --allow-dirty --allow-staged --all-targets --all-features --workspace
echo "✓ Clippy fixes applied. Re-running clippy..."
if ! cargo clippy --all-targets --all-features --workspace -- -D warnings; then
echo "✗ Some clippy issues could not be auto-fixed. Please fix manually."
exit 1
fi
echo "✓ Clippy check passed after fixes"
else
echo "✗ Clippy check failed. Run with --fix to auto-fix, or fix manually."
exit 1
fi
else
echo "✓ Clippy check passed"
fi

# 4. Run tests
echo ""
echo "[4/4] Running tests..."
cargo test --workspace --lib
echo "✓ Tests passed"

echo ""
echo "========================================"
echo "All checks passed! ✓"
echo "========================================"
Loading