228 lines
7.0 KiB
Plaintext
228 lines
7.0 KiB
Plaintext
|
|
# CI/CD Just Recipes
|
|||
|
|
# Generated by dev-system/ci
|
|||
|
|
# Provides `just` recipes for running CI checks locally
|
|||
|
|
|
|||
|
|
# Show CI help
|
|||
|
|
[doc("Show ci help")]
|
|||
|
|
help:
|
|||
|
|
@echo "CI/CD Just Recipes"
|
|||
|
|
@echo ""
|
|||
|
|
@echo "Main Commands:"
|
|||
|
|
@echo " just ci-full - Run all CI checks"
|
|||
|
|
@echo " just ci-fmt - Check Rust formatting"
|
|||
|
|
@echo " just ci-fmt-toml - Check TOML formatting"
|
|||
|
|
@echo " just fmt - Format Rust + TOML"
|
|||
|
|
@echo " just fmt-toml - Format TOML files only"
|
|||
|
|
@echo " just ci-lint - Run all linting checks"
|
|||
|
|
@echo " just ci-test - Run all tests"
|
|||
|
|
@echo " just ci-audit - Run security audits"
|
|||
|
|
@echo ""
|
|||
|
|
@echo "Language-Specific:"
|
|||
|
|
@echo " just ci-lint-rust - Lint Rust (clippy)"
|
|||
|
|
@echo " just ci-lint-toml - Lint TOML files (taplo)"
|
|||
|
|
@echo " just ci-lint-nushell - Validate Nushell"
|
|||
|
|
@echo " just ci-lint-nickel - Type check Nickel"
|
|||
|
|
@echo " just ci-lint-bash - Lint Bash scripts"
|
|||
|
|
@echo ""
|
|||
|
|
@echo "Other:"
|
|||
|
|
@echo " just ci-sbom - Generate SBOM"
|
|||
|
|
@echo " just setup-hooks - Install pre-commit hooks"
|
|||
|
|
@echo " just hooks-run-all - Run pre-commit on all files"
|
|||
|
|
@echo " just clean - Clean build artifacts"
|
|||
|
|
# Run all CI checks
|
|||
|
|
ci-full: ci-fmt ci-fmt-toml ci-lint ci-test ci-audit
|
|||
|
|
@echo "✅ All CI checks passed!"
|
|||
|
|
|
|||
|
|
# ==============================================================================
|
|||
|
|
# Formatting Checks
|
|||
|
|
# ==============================================================================
|
|||
|
|
|
|||
|
|
# Check Rust code formatting
|
|||
|
|
ci-fmt:
|
|||
|
|
@echo "📝 Checking Rust code formatting..."
|
|||
|
|
cargo fmt --all -- --check
|
|||
|
|
|
|||
|
|
# Check TOML file formatting
|
|||
|
|
ci-fmt-toml:
|
|||
|
|
@echo "📝 Checking TOML formatting..."
|
|||
|
|
@command -v taplo >/dev/null || (echo "❌ taplo not installed: cargo install taplo-cli"; exit 1)
|
|||
|
|
taplo format --check
|
|||
|
|
|
|||
|
|
# Format all code (Rust + TOML)
|
|||
|
|
fmt:
|
|||
|
|
@echo "🎨 Formatting code..."
|
|||
|
|
cargo fmt --all
|
|||
|
|
just fmt-toml
|
|||
|
|
|
|||
|
|
# Format TOML files
|
|||
|
|
fmt-toml:
|
|||
|
|
@echo "🎨 Formatting TOML files..."
|
|||
|
|
@command -v taplo >/dev/null || (echo "❌ taplo not installed: cargo install taplo-cli"; exit 1)
|
|||
|
|
taplo format
|
|||
|
|
|
|||
|
|
# ==============================================================================
|
|||
|
|
# Linting
|
|||
|
|
# ==============================================================================
|
|||
|
|
|
|||
|
|
# Run all linting checks
|
|||
|
|
ci-lint: ci-lint-rust ci-lint-toml ci-lint-nushell ci-lint-nickel ci-lint-bash
|
|||
|
|
@echo "✅ All lint checks passed!"
|
|||
|
|
|
|||
|
|
# Lint Rust code
|
|||
|
|
ci-lint-rust:
|
|||
|
|
@echo "🔍 Linting Rust (clippy)..."
|
|||
|
|
cargo clippy --all-targets --all-features -- -D warnings
|
|||
|
|
|
|||
|
|
# Lint TOML files
|
|||
|
|
ci-lint-toml:
|
|||
|
|
@echo "🔍 Linting TOML files..."
|
|||
|
|
@command -v taplo >/dev/null || (echo "❌ taplo not installed: cargo install taplo-cli"; exit 1)
|
|||
|
|
taplo lint
|
|||
|
|
|
|||
|
|
# Lint Nushell scripts
|
|||
|
|
ci-lint-nushell:
|
|||
|
|
#!/usr/bin/env bash
|
|||
|
|
echo "🔍 Validating Nushell scripts..."
|
|||
|
|
SCRIPTS=$(find . -name "*.nu" -type f \
|
|||
|
|
! -path "./target/*" \
|
|||
|
|
! -path "./.git/*" \
|
|||
|
|
! -path "./node_modules/*" \
|
|||
|
|
| head -20)
|
|||
|
|
|
|||
|
|
if [ -z "$SCRIPTS" ]; then
|
|||
|
|
echo " ℹ️ No Nushell scripts found"
|
|||
|
|
exit 0
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
for script in $SCRIPTS; do
|
|||
|
|
echo " Checking: $script"
|
|||
|
|
nu --ide-check 100 "$script" || exit 1
|
|||
|
|
done
|
|||
|
|
echo " ✓ All Nushell scripts valid"
|
|||
|
|
|
|||
|
|
# Lint Nickel schemas
|
|||
|
|
ci-lint-nickel:
|
|||
|
|
#!/usr/bin/env bash
|
|||
|
|
echo "🔍 Type checking Nickel..."
|
|||
|
|
SCHEMAS=$(find . -name "*.ncl" -type f \
|
|||
|
|
! -path "./target/*" \
|
|||
|
|
! -path "./.git/*" \
|
|||
|
|
! -path "./node_modules/*" \
|
|||
|
|
| head -20)
|
|||
|
|
|
|||
|
|
if [ -z "$SCHEMAS" ]; then
|
|||
|
|
echo " ℹ️ No Nickel schemas found"
|
|||
|
|
exit 0
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
export NICKEL_IMPORT_PATH="/Users/Akasha/Tools/dev-system/ci/schemas:/Users/Akasha/Tools/dev-system/ci/validators:/Users/Akasha/Tools/dev-system/ci/defaults:."
|
|||
|
|
|
|||
|
|
for schema in $SCHEMAS; do
|
|||
|
|
echo " Checking: $schema"
|
|||
|
|
nickel typecheck "$schema" || exit 1
|
|||
|
|
done
|
|||
|
|
echo " ✓ All Nickel schemas valid"
|
|||
|
|
|
|||
|
|
# Lint Bash scripts
|
|||
|
|
ci-lint-bash:
|
|||
|
|
#!/usr/bin/env bash
|
|||
|
|
echo "🔍 Linting Bash scripts..."
|
|||
|
|
SCRIPTS=$(find . -name "*.sh" -o -name "*.bash" \
|
|||
|
|
! -path "./target/*" \
|
|||
|
|
! -path "./.git/*" \
|
|||
|
|
! -path "./node_modules/*" \
|
|||
|
|
| head -20)
|
|||
|
|
|
|||
|
|
if [ -z "$SCRIPTS" ]; then
|
|||
|
|
echo " ℹ️ No Bash scripts found"
|
|||
|
|
exit 0
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
for script in $SCRIPTS; do
|
|||
|
|
echo " Checking: $script"
|
|||
|
|
shellcheck "$script" || exit 1
|
|||
|
|
done
|
|||
|
|
echo " ✓ All Bash scripts valid"
|
|||
|
|
|
|||
|
|
# ==============================================================================
|
|||
|
|
# Testing
|
|||
|
|
# ==============================================================================
|
|||
|
|
|
|||
|
|
# Run all tests
|
|||
|
|
ci-test:
|
|||
|
|
@echo "🧪 Running tests..."
|
|||
|
|
cargo test --workspace --all-features
|
|||
|
|
|
|||
|
|
# Run tests with coverage (requires cargo-llvm-cov)
|
|||
|
|
ci-test-coverage:
|
|||
|
|
@echo "📊 Running tests with coverage..."
|
|||
|
|
cargo llvm-cov --all-features --lcov --output-path lcov.info
|
|||
|
|
|
|||
|
|
# ==============================================================================
|
|||
|
|
# Security Auditing
|
|||
|
|
# ==============================================================================
|
|||
|
|
|
|||
|
|
# Run all security audits
|
|||
|
|
ci-audit: ci-audit-rust
|
|||
|
|
@echo "✅ All security audits passed!"
|
|||
|
|
|
|||
|
|
# Audit Rust dependencies
|
|||
|
|
ci-audit-rust:
|
|||
|
|
@echo "🔒 Auditing Rust dependencies..."
|
|||
|
|
cargo audit
|
|||
|
|
cargo deny check licenses
|
|||
|
|
cargo deny check advisories
|
|||
|
|
|
|||
|
|
# Generate SBOM
|
|||
|
|
ci-sbom:
|
|||
|
|
@echo "📦 Generating Software Bill of Materials..."
|
|||
|
|
cargo sbom > sbom.json
|
|||
|
|
@echo "✓ SBOM generated: sbom.json"
|
|||
|
|
|
|||
|
|
# ==============================================================================
|
|||
|
|
# Documentation
|
|||
|
|
# ==============================================================================
|
|||
|
|
|
|||
|
|
# Generate documentation
|
|||
|
|
docs:
|
|||
|
|
@echo "📚 Generating documentation..."
|
|||
|
|
cargo doc --no-deps --open
|
|||
|
|
|
|||
|
|
# Check documentation
|
|||
|
|
ci-docs:
|
|||
|
|
@echo "📚 Checking documentation..."
|
|||
|
|
cargo doc --no-deps --document-private-items 2>&1 | grep -i "warning:" && exit 1 || true
|
|||
|
|
@echo "✓ Documentation check passed"
|
|||
|
|
|
|||
|
|
# ==============================================================================
|
|||
|
|
# Pre-commit Setup
|
|||
|
|
# ==============================================================================
|
|||
|
|
|
|||
|
|
# Install pre-commit hooks
|
|||
|
|
setup-hooks:
|
|||
|
|
@echo "🪝 Installing pre-commit hooks..."
|
|||
|
|
@if command -v pre-commit &> /dev/null; then \
|
|||
|
|
pre-commit install && pre-commit install --hook-type pre-push; \
|
|||
|
|
echo "✓ Pre-commit hooks installed"; \
|
|||
|
|
else \
|
|||
|
|
echo "❌ pre-commit not found. Install with: pip install pre-commit"; \
|
|||
|
|
exit 1; \
|
|||
|
|
fi
|
|||
|
|
|
|||
|
|
# Run pre-commit on all files
|
|||
|
|
hooks-run-all:
|
|||
|
|
@echo "🪝 Running pre-commit on all files..."
|
|||
|
|
pre-commit run --all-files
|
|||
|
|
|
|||
|
|
# ==============================================================================
|
|||
|
|
# Utility Commands
|
|||
|
|
# ==============================================================================
|
|||
|
|
|
|||
|
|
# Clean build artifacts
|
|||
|
|
clean:
|
|||
|
|
@echo "🧹 Cleaning..."
|
|||
|
|
cargo clean
|
|||
|
|
rm -rf target/
|
|||
|
|
rm -f sbom.json lcov.info
|
|||
|
|
|