Skip to content
Merged
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
125 changes: 125 additions & 0 deletions MAKEFILE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# SoroTask Makefile Documentation

## Overview

This Makefile provides unified commands for building, testing, linting, and cleaning the SoroTask monorepo across all components (Contract, Keeper, Frontend).

## Available Targets

### Build Targets

| Target | Description | Command | Use Case |
| --------------------- | --------------------------------- | --------------------------------------------- | ---------------------------- |
| `make build` | Build contract and frontend | `make build` | Full build before deployment |
| `make build-contract` | Build Soroban smart contract | `cd contract && cargo build --release` | After contract code changes |
| `make build-keeper` | Keeper is runtime app (info only) | `npm start` in keeper/ | Start keeper service |
| `make build-frontend` | Build Next.js frontend | `cd frontend && npm install && npm run build` | After frontend changes |

### Test Targets

| Target | Description | Command | Framework |
| -------------------- | ------------------- | ---------------------------------------------- | --------------- |
| `make test` | Run all tests | runs test-contract, test-keeper, test-frontend | All |
| `make test-contract` | Test Rust contract | `cd contract && cargo test --release` | Cargo |
| `make test-keeper` | Test Node.js keeper | `cd keeper && npm test` | Jest |
| `make test-frontend` | Test frontend (N/A) | `cd frontend && npm test` | Echo (no tests) |

### Lint Targets

| Target | Description | Command | Tool |
| -------------------- | --------------------- | ------------------------------------------------------------------------- | ------------ |
| `make lint` | Lint all components | runs all lint-\* targets | Multiple |
| `make lint-contract` | Lint Rust contract | `cd contract && cargo clippy --all-targets --all-features -- -D warnings` | Cargo Clippy |
| `make lint-keeper` | Lint Node.js keeper | `cd keeper && npm run lint` | ESLint |
| `make lint-frontend` | Lint Next.js frontend | `cd frontend && npm run lint` | ESLint |
| `make lint-js` | Lint staged JS files | `npx lint-staged` | lint-staged |

### Clean Targets

| Target | Description | Command | Removes |
| --------------------- | -------------------- | ------------------------------------------ | ----------------------- |
| `make clean` | Clean all artifacts | runs all clean-\* targets | All build outputs |
| `make clean-contract` | Clean Rust build | `cd contract && cargo clean` | target/ directory |
| `make clean-keeper` | Clean Node.js keeper | `rm -rf node_modules coverage` | node_modules, coverage |
| `make clean-frontend` | Clean Next.js build | `rm -rf node_modules .next dist build out` | Next.js build artifacts |

### Utility Targets

| Target | Description | Usage |
| -------------- | -------------------------- | --------------------- |
| `make help` | Show all available targets | `make help` or `make` |
| `make install` | Install all dependencies | `make install` |
| `make format` | Format all code | `make format` |
| `make check` | Run lint + test | `make check` |
| `make dev` | Show development workflow | `make dev` |

## Usage Examples

### Development Workflow

```bash
# Install everything
make install

# Make code changes...

# Format code
make format

# Check code quality (lint + test)
make check

# Build for production
make build

# Start local development servers (run each in separate terminal)
make dev # Shows instructions
```

### CI/CD Pipeline

```bash
# Complete validation before commit
make lint
make test
make build
```

### Troubleshooting

```bash
# Clean and rebuild everything
make clean
make build

# Run only specific component test
make test-keeper

# Check only contract code
make lint-contract
```

## Component Details

### Contract (Rust/Soroban)

- **Language**: Rust
- **Build**: Cargo
- **Test**: `cargo test`
- **Lint**: `cargo clippy`
- **Features**: Fuzz testing, deny.toml security checks

### Keeper (Node.js)

- **Language**: JavaScript
- **Test Framework**: Jest
- **Linter**: ESLint
- **Scripts**: start, dev, test, lint, docker:build
- **Note**: No build step needed (runtime app)

### Frontend (Next.js)

- **Language**: TypeScript/React
- **Framework**: Next.js 16
- **Linter**: ESLint
- **Note**: Test target shows "No tests specified"
162 changes: 162 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
.PHONY: help build test lint clean build-contract build-keeper build-frontend test-contract test-keeper test-frontend lint-contract lint-keeper lint-frontend lint-js clean-contract clean-keeper clean-frontend

# Default target
help:
@echo "SoroTask Makefile - Common Development Tasks"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@echo " build Build all components (contract, frontend)"
@echo " build-contract Build Soroban smart contract (Rust)"
@echo " build-keeper Keeper doesn't require build (Node.js runtime)"
@echo " build-frontend Build Frontend component (Next.js)"
@echo ""
@echo " test Run tests for all components"
@echo " test-contract Run contract tests (Rust)"
@echo " test-keeper Run keeper tests (Jest)"
@echo " test-frontend Run frontend tests (N/A - echo only)"
@echo ""
@echo " lint Lint all components"
@echo " lint-contract Lint contract code (cargo clippy)"
@echo " lint-keeper Lint keeper code (ESLint)"
@echo " lint-frontend Lint frontend code (ESLint)"
@echo ""
@echo " clean Clean all build artifacts"
@echo " clean-contract Clean contract build artifacts"
@echo " clean-keeper Clean keeper build artifacts"
@echo " clean-frontend Clean frontend build artifacts"
@echo ""
@echo " install Install all dependencies"
@echo " format Format all code"
@echo " check Run lint + test"
@echo " dev Show dev workflow"
@echo ""

# ==============================================================================
# BUILD TARGETS
# ==============================================================================

build: build-contract build-frontend
@echo "✓ All buildable components built successfully"

build-contract:
@echo "Building Soroban smart contract..."
cd contract && cargo build --release
@echo "✓ Contract built successfully"

build-keeper:
@echo "Keeper is a Node.js runtime application - no build step needed"
@echo "Run 'npm start' in keeper/ directory to start the service"

build-frontend:
@echo "Building Frontend component (Next.js)..."
cd frontend && npm install && npm run build
@echo "✓ Frontend built successfully"

# ==============================================================================
# TEST TARGETS
# ==============================================================================

test: test-contract test-keeper test-frontend
@echo "✓ All tests completed"

test-contract:
@echo "Running contract tests..."
cd contract && cargo test --release
@echo "✓ Contract tests passed"

test-keeper:
@echo "Running keeper tests (Jest)..."
cd keeper && npm test
@echo "✓ Keeper tests passed"

test-frontend:
@echo "Frontend tests not specified (echo only)"
cd frontend && npm test

# ==============================================================================
# LINT TARGETS
# ==============================================================================

lint: lint-contract lint-keeper lint-frontend lint-js
@echo "✓ All components linted successfully"

lint-contract:
@echo "Linting contract code (cargo clippy)..."
cd contract && cargo clippy --all-targets --all-features -- -D warnings
@echo "✓ Contract linting passed"

lint-keeper:
@echo "Linting keeper code (ESLint)..."
cd keeper && npm run lint
@echo "✓ Keeper linting passed"

lint-frontend:
@echo "Linting frontend code (ESLint)..."
cd frontend && npm run lint
@echo "✓ Frontend linting passed"

lint-js:
@echo "Running lint-staged on staged files..."
npx lint-staged
@echo "✓ Lint-staged passed"

# ==============================================================================
# CLEAN TARGETS
# ==============================================================================

clean: clean-contract clean-keeper clean-frontend
@echo "✓ All build artifacts cleaned"

clean-contract:
@echo "Cleaning contract build artifacts..."
cd contract && cargo clean
@echo "✓ Contract cleaned"

clean-keeper:
@echo "Cleaning keeper build artifacts..."
cd keeper && rm -rf node_modules coverage .nyc_output
@echo "✓ Keeper cleaned"

clean-frontend:
@echo "Cleaning frontend build artifacts..."
cd frontend && rm -rf node_modules .next dist build out
@echo "✓ Frontend cleaned"

# ==============================================================================
# UTILITY TARGETS
# ==============================================================================

install:
@echo "Installing dependencies for all components..."
npm install
cd contract && cargo fetch
cd keeper && npm install
cd frontend && npm install
@echo "✓ All dependencies installed"

format:
@echo "Formatting all code..."
cd contract && cargo fmt
cd keeper && npm run lint:fix 2>/dev/null || npx prettier --write "src/**/*.{ts,js}" "__tests__/**/*.{ts,js}" 2>/dev/null || echo " (prettier not configured for keeper)"
cd frontend && npm run lint:fix 2>/dev/null || echo " (lint:fix not configured for frontend)"
@echo "✓ Code formatted"

check: lint test
@echo "✓ All checks passed (lint + test)"

dev:
@echo "Development workflow - Run each in a separate terminal:"
@echo ""
@echo "Contract (Rust):"
@echo " cd contract && cargo watch -x build"
@echo ""
@echo "Keeper (Node.js - background service):"
@echo " cd keeper && npm run dev"
@echo ""
@echo "Frontend (Next.js):"
@echo " cd frontend && npm run dev"
@echo ""

.DEFAULT_GOAL := help
Loading
Loading