-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
976 lines (807 loc) Β· 38.4 KB
/
Makefile
File metadata and controls
976 lines (807 loc) Β· 38.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
# ============================================================================
# Rust Security Platform - Comprehensive Development & Deployment Automation
# ============================================================================
# This Makefile provides complete development workflow automation covering:
# - Development environment setup and management
# - Frontend & backend service orchestration
# - Comprehensive testing (unit, integration, e2e, security, performance)
# - Code quality, security, and compliance checks
# - Multi-environment deployment (local, staging, production)
# - Monitoring, observability, and maintenance
# ============================================================================
# Default shell and settings
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
# Core project variables
RUST_VERSION := 1.80
PROJECT_NAME := rust-security
AUTH_SERVICE := auth-service
POLICY_SERVICE := policy-service
USER_PORTAL := user-portal
COMPLIANCE_TOOLS := compliance-tools
# Test environment configurations
export TEST_MODE := 1
export DISABLE_RATE_LIMIT := 1
export RUST_LOG := info
export DATABASE_URL := postgresql://authuser:authpass@localhost:5432/authdb
export REDIS_URL := redis://localhost:6379
export CONFIG_DIR := config
export APP_ENV := development
# Color codes for beautiful output
GREEN := \033[0;32m
YELLOW := \033[1;33m
RED := \033[0;31m
BLUE := \033[0;34m
PURPLE := \033[0;35m
CYAN := \033[0;36m
WHITE := \033[1;37m
NC := \033[0m # No Color
# Emoji indicators for status
CHECKMARK := $(GREEN)β
$(NC)
CROSS := $(RED)β$(NC)
HAMMER := $(YELLOW)π¨$(NC)
ROCKET := $(BLUE)π$(NC)
LOCK := $(PURPLE)π$(NC)
CHART := $(CYAN)π$(NC)
TEST_TUBE := $(YELLOW)π§ͺ$(NC)
STETHOSCOPE := $(GREEN)π₯$(NC)
# Default target
.DEFAULT_GOAL := help
# ============================================================================
# HELP SYSTEM
# ============================================================================
.PHONY: help
help: ## Display comprehensive help with command categories
@echo "$(WHITE)================================================================================"
@echo "π RUST SECURITY PLATFORM - COMPREHENSIVE DEVELOPMENT WORKFLOW"
@echo "================================================================================"
@echo ""
@echo "$(CYAN)USAGE:$(NC)"
@echo " make <command> [OPTIONS]"
@echo ""
@echo "$(CYAN)QUICK START:$(NC)"
@echo " make setup # Initial development environment setup"
@echo " make dev # Start all services for development"
@echo " make test # Run complete test suite"
@echo ""
@echo "$(CYAN)AVAILABLE SECTIONS:$(NC)"
@echo " Quick Start & Environment Setup"
@echo " Development Workflow"
@echo " Code Quality & Formatting"
@echo " Frontend Management"
@echo " Testing & Quality Assurance"
@echo " Building & Compilation"
@echo " Documentation"
@echo " Supply Chain & Compliance"
@echo " Deployment & Infrastructure"
@echo " Monitoring & Observability"
@echo " Development Workflow & CI/CD"
@echo " Security & Vulnerability Management"
@echo " Utilities & Diagnostics"
@echo ""
@echo "$(CYAN)POPULAR COMMANDS:$(NC)"
@grep -E "^[a-zA-Z_0-9-]+:.*##" $(MAKEFILE_LIST) | grep -E "(setup|dev|test|build|check|clean|help)" | head -10 | awk 'BEGIN {FS = ":.*##"} {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
@echo ""
@echo "$(YELLOW)TIPS:$(NC)"
@echo " β’ Use 'make help | grep <topic>' to filter commands"
@echo " β’ Most commands support parallel execution with '-j'"
@echo " β’ Use 'make doctor' to diagnose environment issues"
@echo "================================================================================"
.PHONY: help-dev
help-dev: ## Show development workflow commands
@echo "$(CYAN)Development Workflow:$(NC)"
@grep -A 1 "^##@ Development" $(MAKEFILE_LIST) | grep -v "^##@" | awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " make %-20s %s\n", $$1, $$2 }'
.PHONY: help-test
help-test: ## Show testing commands
@echo "$(CYAN)Testing Commands:$(NC)"
@grep -A 1 "^##@ Testing" $(MAKEFILE_LIST) | grep -v "^##@" | awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " make %-20s %s\n", $$1, $$2 }'
.PHONY: help-deploy
help-deploy: ## Show deployment commands
@echo "$(CYAN)Deployment Commands:$(NC)"
@grep -A 1 "^##@ Deployment" $(MAKEFILE_LIST) | grep -v "^##@" | awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " make %-20s %s\n", $$1, $$2 }'
# ============================================================================
# QUICK START & ENVIRONMENT SETUP
# ============================================================================
.PHONY: quick-start
quick-start: setup dev-env-up build test-e2e-setup test ## π Complete development environment setup and validation
@echo "$(CHECKMARK) Quick start complete! Access points:"
@echo " β’ Frontend: http://localhost:5173"
@echo " β’ Auth API: http://localhost:8080"
@echo " β’ Policy API: http://localhost:8081"
@echo " β’ Health: http://localhost:8080/health"
@echo " β’ Metrics: http://localhost:8080/metrics"
@echo " β’ Database: localhost:5432"
@echo " β’ Redis: localhost:6379"
.PHONY: setup
setup: setup-rust setup-tools setup-deps setup-frontend ## π§ Complete development environment setup
@echo "$(CHECKMARK) Development environment fully configured!"
.PHONY: setup-rust
setup-rust: ## Install and configure Rust toolchain
@echo "$(HAMMER) Setting up Rust $(RUST_VERSION)..."
@rustup install $(RUST_VERSION) || echo "Rust $(RUST_VERSION) already installed"
@rustup default $(RUST_VERSION)
@rustup component add rustfmt clippy rust-src
@rustup target add wasm32-unknown-unknown
@cargo --version && rustc --version
@echo "$(CHECKMARK) Rust environment ready!"
.PHONY: setup-tools
setup-tools: ## Install development tools and dependencies
@echo "$(HAMMER) Installing development tools..."
@cargo install sqlx-cli --no-default-features --features postgres,sqlite || echo "sqlx-cli already installed"
@cargo install cargo-audit cargo-deny cargo-fuzz cargo-outdated cargo-watch || echo "Tools already installed"
@cargo install cargo-llvm-cov || echo "Coverage tools already installed"
@echo "$(CHECKMARK) Development tools installed!"
.PHONY: setup-deps
setup-deps: ## Start required dependencies (PostgreSQL, Redis)
@echo "$(HAMMER) Starting infrastructure dependencies..."
@docker-compose up -d postgres redis
@echo "$(YELLOW)β³ Waiting for services to be ready...$(NC)"
@sleep 10
@docker-compose ps
@echo "$(CHECKMARK) Infrastructure dependencies running!"
.PHONY: setup-frontend
setup-frontend: ## Install frontend dependencies
@echo "$(HAMMER) Setting up frontend environment..."
@cd $(USER_PORTAL) && npm install --no-audit --no-fund
@echo "$(CHECKMARK) Frontend dependencies installed!"
.PHONY: setup-migrations
setup-migrations: ## Run database migrations
@echo "$(HAMMER) Running database migrations..."
@sqlx migrate run --source $(AUTH_SERVICE)/migrations || echo "Migrations may already be applied"
@echo "$(CHECKMARK) Database migrations complete!"
.PHONY: setup-all
setup-all: setup setup-migrations setup-monitoring ## Complete environment setup with all components
@echo "$(CHECKMARK) Full environment setup complete!"
# ============================================================================
# DEVELOPMENT WORKFLOW
# ============================================================================
.PHONY: dev
dev: dev-env-up dev-services ## π Start complete development environment
@echo "$(CHECKMARK) Development environment running!"
@echo "$(YELLOW)π Access URLs:$(NC)"
@echo " Frontend: http://localhost:5173"
@echo " Auth API: http://localhost:8080"
@echo " Policy API: http://localhost:8081"
@echo " Metrics: http://localhost:8080/metrics"
.PHONY: dev-env-up
dev-env-up: ## Start development infrastructure (DB, Redis, monitoring)
@echo "$(HAMMER) Starting development infrastructure..."
@docker-compose up -d postgres redis
@sleep 5
@docker-compose ps
@echo "$(CHECKMARK) Development infrastructure ready!"
.PHONY: services-up
services-up: dev-env-up ## Start services for testing (alias for dev-env-up)
.PHONY: services-down
services-down: ## Stop all Docker services
@echo "$(YELLOW) Stopping services..."
@docker-compose down
@echo "$(CHECKMARK) Services stopped!"
.PHONY: dev-env-down
dev-env-down: ## Stop development infrastructure
@echo "$(HAMMER) Stopping development infrastructure..."
@docker-compose down
@echo "$(CHECKMARK) Development infrastructure stopped!"
.PHONY: dev-services
dev-services: ## Start all backend services
@echo "$(ROCKET) Starting backend services..."
@CONFIG_DIR=config APP_ENV=development cargo run -p $(AUTH_SERVICE) &
@sleep 2
@CONFIG_DIR=config APP_ENV=development cargo run -p $(POLICY_SERVICE) &
@echo "$(CHECKMARK) Backend services started!"
.PHONY: dev-frontend
dev-frontend: ## Start frontend development server
@echo "$(ROCKET) Starting frontend development server..."
@cd $(USER_PORTAL) && npm run dev
@echo "$(CHECKMARK) Frontend server started!"
.PHONY: dev-full
dev-full: dev-env-up dev-services ## Start full development stack (backend + infra)
@echo "$(CHECKMARK) Full development stack running!"
@echo "$(YELLOW)π‘ Tip: Run 'make dev-frontend' in another terminal for frontend$(NC)"
.PHONY: dev-watch
dev-watch: ## Start development with auto-reload
@echo "$(ROCKET) Starting development with file watching..."
@cargo watch -x "run -p $(AUTH_SERVICE)" -x "run -p $(POLICY_SERVICE)"
.PHONY: dev-auth
dev-auth: ## Start auth service in development mode
@echo "$(ROCKET) Starting auth service..."
@CONFIG_DIR=config APP_ENV=development cargo run -p $(AUTH_SERVICE)
.PHONY: dev-policy
dev-policy: ## Start policy service in development mode
@echo "$(ROCKET) Starting policy service..."
@CONFIG_DIR=config APP_ENV=development cargo run -p $(POLICY_SERVICE)
.PHONY: dev-frontend-watch
dev-frontend-watch: ## Start frontend with hot reload
@echo "$(ROCKET) Starting frontend with hot reload..."
@cd $(USER_PORTAL) && npm run dev
.PHONY: clean
clean: clean-build clean-deps clean-frontend ## π§Ή Clean all build artifacts and caches
@echo "$(CHECKMARK) Clean complete!"
.PHONY: clean-build
clean-build: ## Clean Rust build artifacts
@echo "$(HAMMER) Cleaning Rust build artifacts..."
@cargo clean
@echo "$(CHECKMARK) Rust artifacts cleaned!"
.PHONY: clean-deps
clean-deps: ## Clean development dependencies
@echo "$(HAMMER) Cleaning development dependencies..."
@docker-compose down -v
@docker system prune -f
@echo "$(CHECKMARK) Dependencies cleaned!"
.PHONY: clean-frontend
clean-frontend: ## Clean frontend build artifacts
@echo "$(HAMMER) Cleaning frontend artifacts..."
@cd $(USER_PORTAL) && rm -rf node_modules/.vite dist
@echo "$(CHECKMARK) Frontend artifacts cleaned!"
# ============================================================================
# CODE QUALITY & FORMATTING
# ============================================================================
.PHONY: check
check: fmt clippy audit test ## π Run comprehensive code quality checks
@echo "$(CHECKMARK) All quality checks passed!"
.PHONY: check-fast
check-fast: fmt-check clippy-check ## β‘ Run fast quality checks (formatting + linting)
@echo "$(CHECKMARK) Fast quality checks passed!"
.PHONY: fmt
fmt: fmt-check ## Check code formatting (alias for fmt-check)
.PHONY: fmt-check
fmt-check: ## Check code formatting without making changes
@echo "$(HAMMER) Checking code formatting..."
@cargo fmt --all -- --check || (echo "$(CROSS) Code formatting issues found. Run 'make fmt-fix' to fix."; exit 1)
@echo "$(CHECKMARK) Code formatting is correct!"
.PHONY: fmt-fix
fmt-fix: ## Fix code formatting issues
@echo "$(HAMMER) Fixing code formatting..."
@cargo fmt --all
@echo "$(CHECKMARK) Code formatting fixed!"
.PHONY: clippy
clippy: clippy-check ## Run clippy lints (alias for clippy-check)
.PHONY: clippy-check
clippy-check: ## Run clippy lints with strict settings
@echo "$(HAMMER) Running clippy lints..."
@cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::perf -W clippy::suspicious -W clippy::nursery
@echo "$(CHECKMARK) Clippy checks passed!"
.PHONY: clippy-fix
clippy-fix: ## Fix clippy issues automatically
@echo "$(HAMMER) Fixing clippy issues..."
@cargo clippy --workspace --all-targets --all-features --fix --allow-dirty -- -D warnings
@echo "$(CHECKMARK) Clippy issues fixed!"
.PHONY: clippy-strict
clippy-strict: ## Run clippy with maximum strictness (CI mode)
@echo "$(HAMMER) Running strict clippy checks..."
@cargo clippy --workspace --all-targets --all-features -- -D warnings -W clippy::pedantic -W clippy::nursery
@echo "$(CHECKMARK) Strict clippy checks passed!"
.PHONY: audit
audit: security-audit ## π Run security audit (alias for security-audit)
.PHONY: security-audit
security-audit: audit-deps audit-vulns ## π Run comprehensive security audit
@echo "$(CHECKMARK) Security audit complete!"
.PHONY: audit-deps
audit-deps: ## Check dependency security
@echo "$(LOCK) Checking dependency security..."
@cargo audit --deny warnings || (echo "$(CROSS) Security vulnerabilities found!"; exit 1)
@cargo deny check || (echo "$(CROSS) Dependency policy violations found!"; exit 1)
@echo "$(CHECKMARK) Dependency security checks passed!"
.PHONY: audit-vulns
audit-vulns: ## Check for known vulnerabilities
@echo "$(LOCK) Scanning for vulnerabilities..."
@cargo audit || echo "$(YELLOW)β οΈ Review security advisories above$(NC)"
@echo "$(CHECKMARK) Vulnerability scan complete!"
.PHONY: lint
lint: clippy-check ## π Run linting checks (alias for clippy-check)
.PHONY: lint-fix
lint-fix: clippy-fix ## π Fix linting issues (alias for clippy-fix)
# ============================================================================
# FRONTEND MANAGEMENT
# ============================================================================
.PHONY: frontend-install
frontend-install: ## Install frontend dependencies
@echo "$(HAMMER) Installing frontend dependencies..."
@cd $(USER_PORTAL) && npm install --no-audit --no-fund
@echo "$(CHECKMARK) Frontend dependencies installed!"
.PHONY: frontend-dev
frontend-dev: ## Start frontend development server
@echo "$(ROCKET) Starting frontend development server..."
@cd $(USER_PORTAL) && npm run dev
.PHONY: frontend-build
frontend-build: ## Build frontend for production
@echo "$(HAMMER) Building frontend for production..."
@cd $(USER_PORTAL) && npm run build
@echo "$(CHECKMARK) Frontend build complete!"
.PHONY: frontend-test
frontend-test: ## Run frontend tests
@echo "$(TEST_TUBE) Running frontend tests..."
@cd $(USER_PORTAL) && npm run test
@echo "$(CHECKMARK) Frontend tests complete!"
.PHONY: frontend-test-ui
frontend-test-ui: ## Run frontend tests with UI
@echo "$(TEST_TUBE) Running frontend tests with UI..."
@cd $(USER_PORTAL) && npm run test:ui
.PHONY: frontend-test-coverage
frontend-test-coverage: ## Run frontend tests with coverage
@echo "$(TEST_TUBE) Running frontend tests with coverage..."
@cd $(USER_PORTAL) && npm run test:coverage
.PHONY: frontend-lint
frontend-lint: ## Run frontend linting
@echo "$(HAMMER) Running frontend linting..."
@cd $(USER_PORTAL) && npm run lint
@echo "$(CHECKMARK) Frontend linting complete!"
.PHONY: frontend-lint-fix
frontend-lint-fix: ## Fix frontend linting issues
@echo "$(HAMMER) Fixing frontend linting issues..."
@cd $(USER_PORTAL) && npm run lint:fix
@echo "$(CHECKMARK) Frontend linting issues fixed!"
.PHONY: frontend-preview
frontend-preview: ## Preview production build
@echo "$(ROCKET) Starting frontend preview server..."
@cd $(USER_PORTAL) && npm run preview
.PHONY: frontend-clean
frontend-clean: ## Clean frontend build artifacts
@echo "$(HAMMER) Cleaning frontend artifacts..."
@cd $(USER_PORTAL) && rm -rf node_modules dist .vite
@echo "$(CHECKMARK) Frontend artifacts cleaned!"
# ============================================================================
# TESTING & QUALITY ASSURANCE
# ============================================================================
.PHONY: test
test: test-unit test-integration-quick test-frontend test-e2e-smoke ## π§ͺ Run complete test suite
@echo "$(CHECKMARK) All tests passed!"
.PHONY: test-all
test-all: test test-security test-fuzz test-e2e benchmark ## π§ͺ Run all tests including security, e2e and performance
@echo "$(CHECKMARK) Complete test suite passed!"
.PHONY: test-unit
test-unit: ## Run unit tests only
@echo "$(TEST_TUBE) Running unit tests..."
@cargo test --package common --package mvp-tools --lib --no-fail-fast
@echo "$(CHECKMARK) Unit tests passed!"
.PHONY: test-integration
test-integration: services-up ## Run integration tests with Docker services
@echo "$(TEST_TUBE) Running integration tests..."
@cargo test --test core_auth_tests --features="full-integration api-keys redis-sessions crypto" --no-fail-fast
@echo "$(CHECKMARK) Integration tests passed!"
.PHONY: test-integration-quick
test-integration-quick: ## Run integration tests without starting services (assumes running)
@echo "$(TEST_TUBE) Running integration tests (quick)..."
@cargo test --test core_auth_tests --features="full-integration api-keys redis-sessions crypto" --no-fail-fast
@echo "$(CHECKMARK) Integration tests passed!"
.PHONY: test-with-services
test-with-services: services-up test-unit test-integration-quick ## Run all tests with Docker services
@echo "$(CHECKMARK) All tests with services passed!"
.PHONY: test-clean
test-clean: services-down ## Clean up test environment
@echo "$(YELLOW) Cleaning up test environment..."
@docker system prune -f
@echo "$(CHECKMARK) Test environment cleaned!"
.PHONY: test-frontend
test-frontend: ## Run frontend tests
@echo "$(TEST_TUBE) Running frontend tests..."
@cd $(USER_PORTAL) && npm run test
@echo "$(CHECKMARK) Frontend tests passed!"
.PHONY: test-coverage
test-coverage: ## Run tests with coverage report
@echo "$(CHART) Running tests with coverage..."
@cargo llvm-cov --workspace --all-features --html --output-dir target/coverage/html -- --nocapture
@cargo llvm-cov --workspace --all-features --lcov --output-path target/coverage/lcov.info
@echo "$(CHECKMARK) Coverage report generated at target/coverage/html/index.html"
.PHONY: test-coverage-frontend
test-coverage-frontend: ## Run frontend tests with coverage
@echo "$(CHART) Running frontend tests with coverage..."
@cd $(USER_PORTAL) && npm run test:coverage
.PHONY: test-security
test-security: test-security-unit test-security-integration ## π Run security-specific tests
@echo "$(CHECKMARK) Security tests completed!"
.PHONY: test-security-unit
test-security-unit: ## Run security unit tests
@echo "$(LOCK) Running security unit tests..."
@cargo test --workspace --lib security -- --nocapture || echo "$(YELLOW)β οΈ Some security tests may have failed$(NC)"
.PHONY: test-security-integration
test-security-integration: ## Run security integration tests
@echo "$(LOCK) Running security integration tests..."
@cargo test -p $(AUTH_SERVICE) --test jwks_rs256 -- --nocapture || true
@cargo test -p $(AUTH_SERVICE) --test csrf_middleware -- --nocapture || true
@cargo test -p $(AUTH_SERVICE) --test cookie_issuance -- --nocapture || true
@./scripts/security/run_security_scenarios.sh || echo "$(YELLOW)β οΈ Security scenario tests completed with warnings$(NC)"
.PHONY: test-fuzz
test-fuzz: ## Run fuzz tests with timeout
@echo "$(TEST_TUBE) Running fuzz tests..."
@cd $(AUTH_SERVICE) && timeout 60 cargo fuzz run fuzz_jwt_parsing -- -max_total_time=60 || true
@cd $(AUTH_SERVICE) && timeout 60 cargo fuzz run fuzz_oauth_parsing -- -max_total_time=60 || true
@echo "$(CHECKMARK) Fuzz testing complete!"
.PHONY: test-load
test-load: ## Run load tests
@echo "$(CHART) Running load tests..."
@./scripts/testing/comprehensive_load_test.sh || echo "$(YELLOW)β οΈ Load tests completed$(NC)"
# E2E Testing Suite
.PHONY: test-e2e
test-e2e: services-up ## π Run complete E2E test suite with Playwright
@echo "$(TEST_TUBE) Running complete E2E test suite..."
@cd e2e-testing && ./run-e2e.sh
@echo "$(CHECKMARK) E2E tests completed!"
.PHONY: test-e2e-smoke
test-e2e-smoke: services-up ## π₯ Run E2E smoke tests (5min)
@echo "$(TEST_TUBE) Running E2E smoke tests..."
@cd e2e-testing && npm run test:smoke
@echo "$(CHECKMARK) E2E smoke tests passed!"
.PHONY: test-e2e-regression
test-e2e-regression: services-up ## π Run E2E regression tests (30min)
@echo "$(TEST_TUBE) Running E2E regression tests..."
@cd e2e-testing && npm run test:regression
@echo "$(CHECKMARK) E2E regression tests passed!"
.PHONY: test-e2e-security
test-e2e-security: services-up ## π‘οΈ Run E2E security tests (15min)
@echo "$(LOCK) Running E2E security tests..."
@cd e2e-testing && npm run test:security
@echo "$(CHECKMARK) E2E security tests passed!"
.PHONY: test-e2e-ui
test-e2e-ui: services-up ## π¨ Run E2E UI tests with Playwright
@echo "$(TEST_TUBE) Running E2E UI tests..."
@cd e2e-testing && npm run test:ui
@echo "$(CHECKMARK) E2E UI tests passed!"
.PHONY: test-e2e-api
test-e2e-api: services-up ## π Run E2E API tests
@echo "$(TEST_TUBE) Running E2E API tests..."
@cd e2e-testing && npm run test:api
@echo "$(CHECKMARK) E2E API tests passed!"
.PHONY: validate-urls
validate-urls: services-up ## π Validate all API endpoints and frontend routes
@echo "$(TEST_TUBE) Validating URLs..."
@cd e2e-testing && npm run validate:urls
@echo "$(CHECKMARK) URL validation completed!"
.PHONY: test-e2e-docker
test-e2e-docker: ## π³ Run E2E tests in Docker environment
@echo "$(TEST_TUBE) Running E2E tests in Docker..."
@cd e2e-testing && npm run test:docker
@echo "$(CHECKMARK) Docker E2E tests completed!"
.PHONY: test-e2e-setup
test-e2e-setup: ## π¦ Setup E2E testing environment
@echo "$(HAMMER) Setting up E2E testing environment..."
@cd e2e-testing && npm install
@cd e2e-testing && npm run setup
@echo "$(CHECKMARK) E2E environment ready!"
.PHONY: test-performance
test-performance: benchmark ## Run performance tests (alias for benchmark)
.PHONY: benchmark
benchmark: ## Run performance benchmarks
@echo "$(CHART) Running performance benchmarks..."
@cargo bench --workspace
@echo "$(CHECKMARK) Benchmarks complete!"
.PHONY: test-watch
test-watch: ## Run tests in watch mode
@echo "$(TEST_TUBE) Running tests in watch mode..."
@cargo watch -x "test --workspace --lib -- --nocapture"
.PHONY: test-quick
test-quick: test-unit test-frontend ## β‘ Run quick test suite (unit + frontend)
@echo "$(CHECKMARK) Quick tests passed!"
.PHONY: test-verbose
test-verbose: ## Run tests with maximum verbosity
@echo "$(TEST_TUBE) Running tests with maximum verbosity..."
@RUST_LOG=debug cargo test --workspace --all-features -- --nocapture
# ============================================================================
# BUILDING & COMPILATION
# ============================================================================
.PHONY: build
build: build-debug ## π¨ Build all packages (alias for build-debug)
.PHONY: build-debug
build-debug: ## Build all packages in debug mode
@echo "$(HAMMER) Building all packages in debug mode..."
@cargo build --workspace --all-features
@echo "$(CHECKMARK) Debug build complete!"
.PHONY: build-release
build-release: ## Build optimized release version
@echo "$(ROCKET) Building release version..."
@cargo build --workspace --all-features --release
@echo "$(CHECKMARK) Release build complete!"
.PHONY: build-fast
build-fast: ## Build with minimal features for faster compilation
@echo "$(HAMMER) Building with minimal features..."
@cargo build --workspace
@echo "$(CHECKMARK) Fast build complete!"
.PHONY: build-check
build-check: ## Check compilation without building
@echo "$(HAMMER) Checking compilation..."
@cargo check --workspace --all-features --all-targets
@echo "$(CHECKMARK) Compilation check passed!"
.PHONY: build-docker
build-docker: build-docker-auth build-docker-policy ## π³ Build all Docker images
@echo "$(CHECKMARK) All Docker images built!"
.PHONY: build-docker-auth
build-docker-auth: ## Build auth service Docker image
@echo "$(HAMMER) Building auth service Docker image..."
@docker build -t $(PROJECT_NAME)/$(AUTH_SERVICE):latest -f $(AUTH_SERVICE)/Dockerfile.secure .
@echo "$(CHECKMARK) Auth service Docker image built!"
.PHONY: build-docker-policy
build-docker-policy: ## Build policy service Docker image
@echo "$(HAMMER) Building policy service Docker image..."
@docker build -t $(PROJECT_NAME)/$(POLICY_SERVICE):latest -f $(POLICY_SERVICE)/Dockerfile .
@echo "$(CHECKMARK) Policy service Docker image built!"
.PHONY: build-docker-all
build-docker-all: build-docker build-frontend-docker ## π³ Build all Docker images including frontend
@echo "$(CHECKMARK) All Docker images built!"
.PHONY: build-frontend-docker
build-frontend-docker: ## Build frontend Docker image
@echo "$(HAMMER) Building frontend Docker image..."
@docker build -t $(PROJECT_NAME)/$(USER_PORTAL):latest -f $(USER_PORTAL)/Dockerfile .
@echo "$(CHECKMARK) Frontend Docker image built!"
.PHONY: build-production
build-production: build-release build-frontend-build ## π Build all components for production
@echo "$(CHECKMARK) Production build complete!"
# ============================================================================
# DOCUMENTATION
# ============================================================================
.PHONY: docs
docs: docs-generate ## π Generate documentation (alias for docs-generate)
.PHONY: docs-generate
docs-generate: ## Generate Rust documentation
@echo "$(HAMMER) Generating Rust documentation..."
@cargo doc --workspace --all-features --no-deps --document-private-items
@echo "$(CHECKMARK) Documentation generated at target/doc/index.html"
.PHONY: docs-open
docs-open: docs-generate ## Open documentation in browser
@echo "$(ROCKET) Opening documentation in browser..."
@cargo doc --workspace --all-features --no-deps --document-private-items --open
.PHONY: docs-serve
docs-serve: ## Serve documentation locally
@echo "$(ROCKET) Serving documentation locally..."
@cargo doc --workspace --all-features --no-deps --document-private-items --open
.PHONY: docs-api
docs-api: ## Generate API documentation from OpenAPI specs
@echo "$(HAMMER) Generating API documentation..."
@./scripts/documentation/regenerate-api-docs.sh || echo "$(YELLOW)β οΈ API docs generation completed$(NC)"
# ============================================================================
# SUPPLY CHAIN & COMPLIANCE
# ============================================================================
.PHONY: sbom
sbom: sbom-generate ## π¦ Generate Software Bill of Materials (alias for sbom-generate)
.PHONY: sbom-generate
sbom-generate: ## Generate Software Bill of Materials (SBOM)
@echo "$(HAMMER) Generating SBOM..."
@cargo install cargo-auditable cargo-sbom || echo "SBOM tools already installed"
@cargo auditable build --release
@cargo sbom > target/$(PROJECT_NAME)-sbom.json
@echo "$(CHECKMARK) SBOM generated at target/$(PROJECT_NAME)-sbom.json"
.PHONY: sbom-spdx
sbom-spdx: ## Generate SPDX format SBOM
@echo "$(HAMMER) Generating SPDX SBOM..."
@cd $(COMPLIANCE_TOOLS) && cargo run --bin sbom-generator -- --project-root .. --output ../sbom.spdx.json
@echo "$(CHECKMARK) SPDX SBOM generated at sbom.spdx.json"
.PHONY: supply-chain-check
supply-chain-check: audit sbom ## π Complete supply chain security check
@echo "$(CHECKMARK) Supply chain security check complete!"
.PHONY: compliance-check
compliance-check: audit sbom validate-security ## π Run compliance validation
@echo "$(CHECKMARK) Compliance check complete!"
.PHONY: compliance-report
compliance-report: ## Generate compliance report
@echo "$(CHART) Generating compliance report..."
@./scripts/compliance/generate_compliance_report.py || echo "$(YELLOW)β οΈ Compliance report generation completed$(NC)"
# ============================================================================
# DEPLOYMENT & INFRASTRUCTURE
# ============================================================================
.PHONY: deploy-local
deploy-local: build-docker deploy-docker-compose ## π Deploy to local environment
@echo "$(CHECKMARK) Local deployment complete!"
@echo "$(YELLOW)π Service URLs:$(NC)"
@echo " Auth API: http://localhost:8080"
@echo " Policy API: http://localhost:8081"
@echo " Frontend: http://localhost:5173"
.PHONY: deploy-docker-compose
deploy-docker-compose: ## Deploy using Docker Compose
@echo "$(ROCKET) Deploying with Docker Compose..."
@docker-compose up -d
@echo "$(CHECKMARK) Docker Compose deployment complete!"
.PHONY: deploy-k8s
deploy-k8s: build-docker deploy-k8s-apply ## π Deploy to Kubernetes
@echo "$(CHECKMARK) Kubernetes deployment complete!"
.PHONY: deploy-k8s-apply
deploy-k8s-apply: ## Apply Kubernetes manifests
@echo "$(ROCKET) Applying Kubernetes manifests..."
@kubectl apply -f k8s/
@echo "$(CHECKMARK) Kubernetes manifests applied!"
.PHONY: deploy-k8s-delete
deploy-k8s-delete: ## Remove from Kubernetes
@echo "$(HAMMER) Removing from Kubernetes..."
@kubectl delete -f k8s/
@echo "$(CHECKMARK) Kubernetes resources removed!"
.PHONY: deploy-helm
deploy-helm: ## Deploy using Helm charts
@echo "$(ROCKET) Deploying with Helm..."
@helm upgrade --install $(PROJECT_NAME) ./helm/$(PROJECT_NAME)
@echo "$(CHECKMARK) Helm deployment complete!"
.PHONY: deploy-staging
deploy-staging: build-production ## π Deploy to staging environment
@echo "$(ROCKET) Deploying to staging..."
@./scripts/deployment/deploy-staging.sh
@echo "$(CHECKMARK) Staging deployment complete!"
.PHONY: deploy-production
deploy-production: build-production ## π Deploy to production environment
@echo "$(ROCKET) Deploying to production..."
@./scripts/deployment/deploy-production.sh
@echo "$(CHECKMARK) Production deployment complete!"
# ============================================================================
# MONITORING & OBSERVABILITY
# ============================================================================
.PHONY: monitoring-up
monitoring-up: ## Start monitoring stack (Prometheus, Grafana)
@echo "$(ROCKET) Starting monitoring stack..."
@docker-compose -f monitoring/docker-compose.yml up -d
@echo "$(CHECKMARK) Monitoring stack started!"
.PHONY: monitoring-down
monitoring-down: ## Stop monitoring stack
@echo "$(HAMMER) Stopping monitoring stack..."
@docker-compose -f monitoring/docker-compose.yml down
@echo "$(CHECKMARK) Monitoring stack stopped!"
.PHONY: logs
logs: logs-auth logs-policy ## π Show logs from all services
.PHONY: logs-auth
logs-auth: ## Show auth service logs
@echo "$(π) Auth service logs:"
@kubectl logs -f deployment/$(AUTH_SERVICE) || docker-compose logs -f $(AUTH_SERVICE)
.PHONY: logs-policy
logs-policy: ## Show policy service logs
@echo "$(π) Policy service logs:"
@kubectl logs -f deployment/$(POLICY_SERVICE) || docker-compose logs -f $(POLICY_SERVICE)
.PHONY: metrics
metrics: ## Show service metrics
@echo "$(CHART) Service metrics:"
@curl -s http://localhost:8080/metrics || echo "Metrics not available"
# ============================================================================
# DEVELOPMENT WORKFLOW & CI/CD
# ============================================================================
.PHONY: install-hooks
install-hooks: ## πͺ Install git pre-commit hooks
@echo "$(HAMMER) Installing git hooks..."
@./scripts/setup/setup-git-hooks.sh || pre-commit install
@pre-commit install --hook-type commit-msg
@echo "$(CHECKMARK) Git hooks installed!"
.PHONY: ci-local
ci-local: check test test-e2e-smoke security-audit ## π Run CI checks locally
@echo "$(CHECKMARK) Local CI checks complete!"
.PHONY: ci-strict
ci-strict: ## π Run strict CI checks (warnings as errors)
@echo "$(ROCKET) Running strict CI checks..."
@RUSTFLAGS="-D warnings" cargo build --workspace --all-features
@cargo clippy --workspace --all-targets --all-features -- -D warnings
@cargo test --workspace --all-features
@echo "$(CHECKMARK) Strict CI checks complete!"
.PHONY: pre-commit
pre-commit: fmt-fix clippy-fix test-unit ## β
Run pre-commit checks and fixes
@echo "$(CHECKMARK) Pre-commit checks complete!"
.PHONY: validate-pr
validate-pr: ci-local supply-chain-check compliance-check ## β
Validate changes before creating PR
@echo "$(CHECKMARK) PR validation complete! Ready to create pull request."
.PHONY: validate-release
validate-release: test-all test-e2e compliance-check build-production ## β
Validate release readiness
@echo "$(CHECKMARK) Release validation complete!"
# ============================================================================
# SECURITY & VULNERABILITY MANAGEMENT
# ============================================================================
.PHONY: security-scan
security-scan: audit test-security ## π Run comprehensive security scan
@echo "$(CHECKMARK) Security scan complete!"
.PHONY: security-vulnerability-scan
security-vulnerability-scan: ## π Scan for vulnerabilities
@echo "$(LOCK) Scanning for vulnerabilities..."
@./scripts/security/security-vulnerability-scan.sh
@echo "$(CHECKMARK) Vulnerability scan complete!"
.PHONY: security-threat-test
security-threat-test: ## π Run threat modeling tests
@echo "$(LOCK) Running threat modeling tests..."
@./scripts/security/simple_threat_test.rs || echo "$(YELLOW)β οΈ Threat tests completed$(NC)"
.PHONY: validate-security
validate-security: ## π Validate security implementation
@echo "$(LOCK) Validating security implementation..."
@./scripts/validation/validate_security_implementation.sh
@echo "$(CHECKMARK) Security validation complete!"
# ============================================================================
# UTILITIES & DIAGNOSTICS
# ============================================================================
.PHONY: show-env
show-env: ## Show current environment configuration
@echo "$(BLUE)Environment Configuration:$(NC)"
@echo "RUST_VERSION: $(RUST_VERSION)"
@echo "PROJECT_NAME: $(PROJECT_NAME)"
@echo "AUTH_SERVICE: $(AUTH_SERVICE)"
@echo "POLICY_SERVICE: $(POLICY_SERVICE)"
@echo "USER_PORTAL: $(USER_PORTAL)"
@echo "DATABASE_URL: $(DATABASE_URL)"
@echo "REDIS_URL: $(REDIS_URL)"
@echo "CONFIG_DIR: $(CONFIG_DIR)"
@echo "APP_ENV: $(APP_ENV)"
.PHONY: workspace-status
workspace-status: ## π Show workspace status
@echo "$(BLUE)Workspace Status:$(NC)"
@echo "Rust version: $$(rustc --version)"
@echo "Cargo version: $$(cargo --version)"
@echo "Node version: $$(cd $(USER_PORTAL) && node --version 2>/dev/null || echo 'N/A')"
@echo "Git branch: $$(git branch --show-current)"
@echo "Git status: $$(git status --porcelain | wc -l) files changed"
@echo "Docker status:"
@docker-compose ps 2>/dev/null || echo "Docker not running"
.PHONY: doctor
doctor: doctor-system doctor-project ## π₯ Run complete diagnostic checks
@echo "$(CHECKMARK) Diagnostic complete!"
.PHONY: doctor-system
doctor-system: ## Check system dependencies
@echo "$(STETHOSCOPE) Checking system dependencies..."
@rustc --version || echo "$(CROSS) Rust not installed"
@cargo --version || echo "$(CROSS) Cargo not available"
@docker --version || echo "$(YELLOW)β οΈ Docker not available$(NC)"
@docker-compose --version || echo "$(YELLOW)β οΈ Docker Compose not available$(NC)"
@kubectl version --client || echo "$(YELLOW)β οΈ kubectl not available$(NC)"
@echo "$(CHECKMARK) System check complete!"
.PHONY: doctor-project
doctor-project: ## Check project-specific dependencies
@echo "$(STETHOSCOPE) Checking project dependencies..."
@sqlx --version || echo "$(YELLOW)β οΈ SQLx CLI not installed$(NC)"
@cargo audit --version || echo "$(YELLOW)β οΈ cargo-audit not installed$(NC)"
@cargo deny --version || echo "$(YELLOW)β οΈ cargo-deny not installed$(NC)"
@cd $(USER_PORTAL) && npm --version || echo "$(YELLOW)β οΈ npm not available$(NC)"
@echo "$(CHECKMARK) Project check complete!"
.PHONY: reset
reset: clean setup ## π Complete reset of development environment
@echo "$(CHECKMARK) Development environment reset complete!"
.PHONY: reset-hard
reset-hard: clean reset-deps setup ## π Hard reset (removes all containers and volumes)
@echo "$(CHECKMARK) Hard reset complete!"
.PHONY: reset-deps
reset-deps: ## Reset development dependencies
@echo "$(HAMMER) Resetting development dependencies..."
@docker-compose down -v
@docker system prune -f
@echo "$(CHECKMARK) Dependencies reset!"
.PHONY: update
update: update-rust update-deps update-frontend ## π Update all dependencies
@echo "$(CHECKMARK) All dependencies updated!"
.PHONY: update-rust
update-rust: ## Update Rust toolchain
@echo "$(HAMMER) Updating Rust toolchain..."
@rustup update
@echo "$(CHECKMARK) Rust updated!"
.PHONY: update-deps
update-deps: ## Update Rust dependencies
@echo "$(HAMMER) Updating Rust dependencies..."
@cargo update
@echo "$(CHECKMARK) Rust dependencies updated!"
.PHONY: update-frontend
update-frontend: ## Update frontend dependencies
@echo "$(HAMMER) Updating frontend dependencies..."
@cd $(USER_PORTAL) && npm update
@echo "$(CHECKMARK) Frontend dependencies updated!"
.PHONY: outdated
outdated: outdated-rust outdated-frontend ## π Check for outdated dependencies
@echo "$(CHECKMARK) Outdated check complete!"
.PHONY: outdated-rust
outdated-rust: ## Check for outdated Rust dependencies
@echo "$(π) Checking Rust dependencies..."
@cargo outdated --workspace
.PHONY: outdated-frontend
outdated-frontend: ## Check for outdated frontend dependencies
@echo "$(π) Checking frontend dependencies..."
@cd $(USER_PORTAL) && npm outdated
# ============================================================================
# REGRESSION TESTING TARGETS
# ============================================================================
# Include regression testing makefile
include Makefile.regression
test-regression-quick: ## Quick regression tests (pre-commit)
@echo "$(ROCKET) Running Quick Regression Tests..."
@$(MAKE) -f Makefile.regression regression-quick
@echo "$(CHECKMARK) Quick regression tests completed"
test-regression-full: ## Full regression test suite (pre-release)
@echo "$(ROCKET) Running Full Regression Suite..."
@$(MAKE) -f Makefile.regression regression-full
@echo "$(CHECKMARK) Full regression suite completed"
test-regression-security: ## Security-focused regression tests
@echo "$(ROCKET) Running Security Regression Tests..."
@$(MAKE) -f Makefile.regression regression-security
@echo "$(CHECKMARK) Security regression tests completed"
test-regression-performance: ## Performance regression tests
@echo "$(ROCKET) Running Performance Regression Tests..."
@$(MAKE) -f Makefile.regression regression-performance
@echo "$(CHECKMARK) Performance regression tests completed"
test-regression-coverage: ## Regression tests with coverage
@echo "$(ROCKET) Running Regression Tests with Coverage..."
@$(MAKE) -f Makefile.regression regression-coverage
@echo "$(CHECKMARK) Regression coverage analysis completed"