|
| 1 | +# Makefile for SysArx |
| 2 | +# Cross-platform build automation with self-documenting help system |
| 3 | + |
| 4 | +.PHONY: help restore build test test-security test-integration test-coverage publish docker docker-up docker-down clean all reports matrix format lint verify |
| 5 | + |
| 6 | +# Default configuration |
| 7 | +CONFIGURATION ?= Release |
| 8 | +SOLUTION = SysArx.sln |
| 9 | +WEB_PROJECT = src/web/SysArx.csproj |
| 10 | +AUTH_PROJECT = src/Services/Auth/Auth.csproj |
| 11 | +SYSMLSTORE_PROJECT = src/Services/SysMLStore/SysMLStore.csproj |
| 12 | +SYSMLDIAGRAM_PROJECT = src/Services/SysMLDiagram/SysMLDiagram.csproj |
| 13 | +TESTS_PROJECT = tests/SysArx.Tests/SysArx.Tests.csproj |
| 14 | +PUBLISH_DIR = publish |
| 15 | +REPORTS_DIR = reports |
| 16 | +MATRIX_SCRIPT = scripts/generate-requirements-matrix.py |
| 17 | + |
| 18 | +# Detect OS for platform-specific commands |
| 19 | +ifeq ($(OS),Windows_NT) |
| 20 | + SCRIPT_EXT = .ps1 |
| 21 | + SCRIPT_RUNNER = pwsh -File |
| 22 | + RM_RF = powershell -Command "Remove-Item -Recurse -Force" |
| 23 | + PYTHON = python |
| 24 | +else |
| 25 | + SCRIPT_EXT = .sh |
| 26 | + SCRIPT_RUNNER = bash |
| 27 | + RM_RF = rm -rf |
| 28 | + PYTHON = python3 |
| 29 | +endif |
| 30 | + |
| 31 | +help: ## Show this help message |
| 32 | + @echo "SysArx Build System" |
| 33 | + @echo "==================" |
| 34 | + @echo "" |
| 35 | + @echo "A system architecture documentation and modeling platform" |
| 36 | + @echo "" |
| 37 | + @echo "Usage: make [target]" |
| 38 | + @echo "" |
| 39 | + @echo "Common Targets:" |
| 40 | + @echo " help Show this help message" |
| 41 | + @echo " restore Restore NuGet dependencies" |
| 42 | + @echo " build Build the solution" |
| 43 | + @echo " test Run all tests" |
| 44 | + @echo " test-security Run security tests only" |
| 45 | + @echo " test-integration Run integration tests only" |
| 46 | + @echo " test-coverage Run tests with coverage" |
| 47 | + @echo " run-web Run the web application" |
| 48 | + @echo " docker Build all Docker images" |
| 49 | + @echo " docker-up Start all services with Docker Compose" |
| 50 | + @echo " docker-down Stop all Docker services" |
| 51 | + @echo " clean Clean build artifacts" |
| 52 | + @echo " all Run full build pipeline" |
| 53 | + @echo "" |
| 54 | + @echo "Advanced Targets:" |
| 55 | + @echo " publish Publish all applications" |
| 56 | + @echo " reports Generate requirements matrix" |
| 57 | + @echo " matrix Generate requirements traceability matrix" |
| 58 | + @echo " format Format code using dotnet format" |
| 59 | + @echo " lint Check code formatting" |
| 60 | + @echo " verify Verify Docker Compose configuration" |
| 61 | + @echo "" |
| 62 | + @echo "Configuration:" |
| 63 | + @echo " CONFIGURATION Build configuration (default: Release)" |
| 64 | + @echo "" |
| 65 | + @echo "Examples:" |
| 66 | + @echo " make build # Build in Release mode" |
| 67 | + @echo " make CONFIGURATION=Debug build # Build in Debug mode" |
| 68 | + @echo " make docker-up # Start all services" |
| 69 | + @echo " make test-security # Run security tests" |
| 70 | + @echo "" |
| 71 | + |
| 72 | +restore: ## Restore NuGet dependencies |
| 73 | + @echo "==> Restoring dependencies..." |
| 74 | + @dotnet restore $(SOLUTION) |
| 75 | + |
| 76 | +build: restore ## Build the solution |
| 77 | + @echo "==> Building solution..." |
| 78 | + @dotnet build $(SOLUTION) \ |
| 79 | + --configuration $(CONFIGURATION) \ |
| 80 | + --no-restore |
| 81 | + |
| 82 | +test: build ## Run all tests |
| 83 | + @echo "==> Running tests..." |
| 84 | + @dotnet test $(SOLUTION) \ |
| 85 | + --configuration $(CONFIGURATION) \ |
| 86 | + --no-build \ |
| 87 | + --verbosity normal \ |
| 88 | + --logger "trx;LogFileName=test-results.trx" |
| 89 | + |
| 90 | +test-security: build ## Run security tests only |
| 91 | + @echo "==> Running security tests..." |
| 92 | + @dotnet test $(SOLUTION) \ |
| 93 | + --configuration $(CONFIGURATION) \ |
| 94 | + --no-build \ |
| 95 | + --filter "Category=Security" |
| 96 | + |
| 97 | +test-integration: build ## Run integration tests only |
| 98 | + @echo "==> Running integration tests..." |
| 99 | + @dotnet test $(SOLUTION) \ |
| 100 | + --configuration $(CONFIGURATION) \ |
| 101 | + --no-build \ |
| 102 | + --filter "Category=Integration" |
| 103 | + |
| 104 | +test-coverage: build ## Run tests with code coverage |
| 105 | + @echo "==> Running tests with coverage..." |
| 106 | + @dotnet test $(SOLUTION) \ |
| 107 | + --configuration $(CONFIGURATION) \ |
| 108 | + --no-build \ |
| 109 | + --collect:"XPlat Code Coverage" \ |
| 110 | + --results-directory ./TestResults |
| 111 | + |
| 112 | +run-web: build ## Run the web application |
| 113 | + @echo "==> Starting web application..." |
| 114 | + @dotnet run --project $(WEB_PROJECT) --configuration $(CONFIGURATION) --no-build |
| 115 | + |
| 116 | +publish: ## Publish all applications |
| 117 | + @echo "==> Publishing applications..." |
| 118 | + @dotnet publish $(WEB_PROJECT) \ |
| 119 | + --configuration $(CONFIGURATION) \ |
| 120 | + --output $(PUBLISH_DIR)/web |
| 121 | + @dotnet publish $(AUTH_PROJECT) \ |
| 122 | + --configuration $(CONFIGURATION) \ |
| 123 | + --output $(PUBLISH_DIR)/auth |
| 124 | + @dotnet publish $(SYSMLSTORE_PROJECT) \ |
| 125 | + --configuration $(CONFIGURATION) \ |
| 126 | + --output $(PUBLISH_DIR)/sysmlstore |
| 127 | + @dotnet publish $(SYSMLDIAGRAM_PROJECT) \ |
| 128 | + --configuration $(CONFIGURATION) \ |
| 129 | + --output $(PUBLISH_DIR)/sysmldiagram |
| 130 | + @echo "==> Published to: $(PUBLISH_DIR)" |
| 131 | + |
| 132 | +docker: ## Build all Docker images |
| 133 | + @echo "==> Building Docker images..." |
| 134 | + @docker build -t sysarx-web -f src/web/Dockerfile . |
| 135 | + @docker build -t sysarx-auth -f src/Services/Auth/Dockerfile . |
| 136 | + @docker build -t sysarx-sysmlstore -f src/Services/SysMLStore/Dockerfile . |
| 137 | + @docker build -t sysarx-sysmldiagram -f src/Services/SysMLDiagram/Dockerfile . |
| 138 | + @echo "==> Docker images built successfully" |
| 139 | + |
| 140 | +docker-up: verify ## Start all services with Docker Compose |
| 141 | + @echo "==> Starting services with Docker Compose..." |
| 142 | + @docker compose up -d |
| 143 | + @echo "==> Services started. Access web at http://localhost:5000" |
| 144 | + |
| 145 | +docker-down: ## Stop all Docker services |
| 146 | + @echo "==> Stopping Docker services..." |
| 147 | + @docker compose down |
| 148 | + @echo "==> Services stopped" |
| 149 | + |
| 150 | +docker-logs: ## View Docker Compose logs |
| 151 | + @docker compose logs -f |
| 152 | + |
| 153 | +verify: ## Verify Docker Compose configuration |
| 154 | + @echo "==> Verifying Docker Compose configuration..." |
| 155 | + @docker compose config > /dev/null |
| 156 | + @echo "==> Docker Compose configuration is valid" |
| 157 | + |
| 158 | +clean: ## Clean build artifacts |
| 159 | + @echo "==> Cleaning build artifacts..." |
| 160 | +ifeq ($(OS),Windows_NT) |
| 161 | + @powershell -Command "Get-ChildItem -Path . -Include bin,obj -Recurse -Directory | Remove-Item -Recurse -Force" 2>nul || echo "No build artifacts to clean" |
| 162 | + @$(RM_RF) $(PUBLISH_DIR) 2>nul || echo "" |
| 163 | + @$(RM_RF) TestResults 2>nul || echo "" |
| 164 | +else |
| 165 | + @find . -type d -name bin -o -name obj | xargs $(RM_RF) 2>/dev/null || true |
| 166 | + @$(RM_RF) $(PUBLISH_DIR) 2>/dev/null || true |
| 167 | + @$(RM_RF) TestResults 2>/dev/null || true |
| 168 | +endif |
| 169 | + @echo "==> Clean complete" |
| 170 | + |
| 171 | +reports: matrix ## Generate all reports |
| 172 | + |
| 173 | +matrix: ## Generate requirements traceability matrix |
| 174 | + @echo "==> Generating requirements matrix..." |
| 175 | + @mkdir -p $(REPORTS_DIR) |
| 176 | + @$(PYTHON) $(MATRIX_SCRIPT) |
| 177 | + @echo "==> Requirements matrix generated: $(REPORTS_DIR)/REQUIREMENTS_MATRIX.md" |
| 178 | + |
| 179 | +format: ## Format code using dotnet format |
| 180 | + @echo "==> Formatting code..." |
| 181 | + @dotnet format $(SOLUTION) |
| 182 | + |
| 183 | +lint: ## Check code formatting |
| 184 | + @echo "==> Checking code formatting..." |
| 185 | + @dotnet format $(SOLUTION) --verify-no-changes |
| 186 | + |
| 187 | +all: restore build test matrix ## Run full build pipeline |
| 188 | + @echo "==> Full build pipeline complete" |
| 189 | + |
| 190 | +.DEFAULT_GOAL := help |
0 commit comments