github.com/jasoet/gopki@v1.15.0/Taskfile.yml (about) 1 version: '3' 2 3 vars: 4 MODULE: github.com/jasoet/gopki 5 GO_FILES: 6 sh: find . -type f -name '*.go' -not -path './vendor/*' -not -path './.git/*' | head -20 7 8 tasks: 9 default: 10 desc: Show available tasks 11 cmds: 12 - task --list 13 silent: true 14 15 help:quality: 16 desc: Show all code quality and analysis tasks 17 cmds: 18 - 'echo "📋 Code Quality & Analysis Tasks:"' 19 - 'echo ""' 20 - 'echo "Testing:"' 21 - 'echo " task test - Run tests with race detection and coverage"' 22 - 'echo " task test:quick - Run tests without race detection (faster)"' 23 - 'echo ""' 24 - 'echo "Compatibility Testing:"' 25 - 'echo " task test:compatibility - Run OpenSSL compatibility tests (build tag: compatibility)"' 26 - 'echo " task test:compatibility:keypair - Run keypair compatibility tests only"' 27 - 'echo " task test:compatibility:cert - Run certificate compatibility tests only"' 28 - 'echo " task test:compatibility:signing - Run signing compatibility tests only"' 29 - 'echo ""' 30 - 'echo "Code Analysis:"' 31 - 'echo " task lint - Run go vet static analysis"' 32 - 'echo " task lint:full - Run golangci-lint comprehensive check"' 33 - 'echo " task deadcode - Find unused/dead code with deadcode tool"' 34 - 'echo " task unused - Find unused code with golangci-lint"' 35 - 'echo " task unused:all - Run all unused code detection tools"' 36 - 'echo " task analyze - Run lint, vet, and deadcode"' 37 - 'echo " task analyze:full - Run full analysis with all tools"' 38 - 'echo ""' 39 - 'echo "Formatting:"' 40 - 'echo " task format - Format all Go code"' 41 - 'echo " task format:check - Check if code is properly formatted"' 42 - 'echo ""' 43 - 'echo "💡 Tips:"' 44 - 'echo " • Use task test for comprehensive testing with coverage"' 45 - 'echo " • Use task deadcode to quickly find unused functions"' 46 - 'echo " • Use task analyze:full for complete code analysis"' 47 silent: true 48 49 # Setup and Dependencies 50 setup: 51 desc: Initial project setup - download dependencies and verify module 52 cmds: 53 - go mod download 54 - go mod verify 55 - go mod tidy 56 - 'echo "✅ Project setup complete"' 57 silent: true 58 59 # Build Tasks 60 build: 61 desc: Build the module and verify compilation 62 sources: 63 - '**/*.go' 64 - go.mod 65 - go.sum 66 cmds: 67 - go build ./... 68 - 'echo "✅ Build successful"' 69 silent: true 70 71 build:examples: 72 desc: Build example binaries 73 deps: [build] 74 cmds: 75 - mkdir -p bin/ 76 - go build -tags example -o bin/keypair-example ./examples/keypair/main.go 77 - go build -tags example -o bin/certificates-example ./examples/certificates/main.go 78 - go build -tags example -o bin/signing-example ./examples/signing/main.go 79 - go build -tags example -o bin/encryption-example ./examples/encryption/main.go 80 - go build -tags example -o bin/pkcs12-example ./examples/pkcs12/main.go 81 - 'echo "✅ Examples built in bin/ directory"' 82 generates: 83 - bin/keypair-example 84 - bin/certificates-example 85 - bin/signing-example 86 - bin/encryption-example 87 - bin/pkcs12-example 88 silent: true 89 90 # Testing Tasks 91 test: 92 desc: Run all tests with race detection and coverage report 93 env: 94 CGO_ENABLED: 1 95 cmds: 96 - mkdir -p output/ 97 - go test ./... -race -coverprofile=output/coverage.out 98 - go tool cover -html=output/coverage.out -o output/coverage.html 99 - go tool cover -func=output/coverage.out | tail -1 100 - 'echo "✅ Tests completed with coverage report: output/coverage.html"' 101 generates: 102 - output/coverage.out 103 - output/coverage.html 104 silent: true 105 106 test:compatibility: 107 desc: Run OpenSSL compatibility tests 108 env: 109 CGO_ENABLED: 1 110 cmds: 111 - mkdir -p output/ 112 - | 113 echo "🔗 Running OpenSSL Compatibility Tests..." 114 echo " This tests interoperability between GoPKI and OpenSSL" 115 - go test -mod=mod ./compatibility/... -v -tags=compatibility 116 - 'echo "✅ OpenSSL compatibility tests completed"' 117 silent: false 118 119 test:compatibility:keypair: 120 desc: Run keypair compatibility tests only 121 env: 122 CGO_ENABLED: 1 123 cmds: 124 - mkdir -p output/ 125 - | 126 echo "🔑 Running Keypair Compatibility Tests..." 127 echo " Testing RSA, ECDSA, Ed25519 key compatibility with OpenSSL" 128 - go test -mod=mod ./compatibility/keypair -v -tags=compatibility 129 - 'echo "✅ Keypair compatibility tests completed"' 130 silent: false 131 132 test:compatibility:cert: 133 desc: Run certificate compatibility tests only 134 env: 135 CGO_ENABLED: 1 136 cmds: 137 - mkdir -p output/ 138 - | 139 echo "📜 Running Certificate Compatibility Tests..." 140 echo " Testing X.509 certificate compatibility with OpenSSL" 141 - go test -mod=mod ./compatibility/cert -v -tags=compatibility 142 - 'echo "✅ Certificate compatibility tests completed"' 143 silent: false 144 145 test:compatibility:signing: 146 desc: Run signing compatibility tests only 147 env: 148 CGO_ENABLED: 1 149 cmds: 150 - mkdir -p output/ 151 - | 152 echo "✍️ Running Signing Compatibility Tests..." 153 echo " Testing digital signature and PKCS#7/CMS compatibility with OpenSSL" 154 - go test -mod=mod ./compatibility/signing -v -tags=compatibility 155 - 'echo "✅ Signing compatibility tests completed"' 156 silent: false 157 158 # Code Quality Tasks 159 lint: 160 desc: Run static analysis with go vet 161 cmds: 162 - go vet ./... 163 - 'echo "✅ Linting complete"' 164 silent: true 165 166 unused: 167 desc: Check for unused code using golangci-lint 168 cmds: 169 - | 170 if ! command -v golangci-lint &> /dev/null; then 171 echo "⚠️ golangci-lint not found. Installing..." 172 go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest 173 fi 174 - golangci-lint run --enable=unused --disable-all ./... 175 silent: false 176 177 lint:install: 178 desc: Install golangci-lint for advanced linting 179 cmds: 180 - go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest 181 - 'echo "✅ golangci-lint installed"' 182 silent: true 183 184 lint:full: 185 desc: Run comprehensive linting with golangci-lint on core modules 186 deps: [lint:check] 187 cmds: 188 - golangci-lint run ./keypair/... ./cert/... ./signing/... 189 - 'echo "✅ Full lint checks passed"' 190 silent: true 191 192 lint:check: 193 desc: Check if golangci-lint is installed 194 cmds: 195 - | 196 if ! command -v golangci-lint >/dev/null 2>&1; then 197 echo "❌ golangci-lint not found. Install from https://golangci-lint.run/usage/install/" 198 echo " For macOS: brew install golangci-lint" 199 echo " For Linux: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin" 200 exit 1 201 fi 202 silent: true 203 204 lint:fix: 205 desc: Auto-fix linting issues where possible 206 deps: [lint:check] 207 cmds: 208 - golangci-lint run --fix ./keypair/... ./cert/... ./signing/... ./encryption/... ./pkcs12/... 209 - 'echo "✅ Auto-fixable lint issues resolved"' 210 silent: true 211 212 lint:security: 213 desc: Run security-focused linting 214 deps: [lint:check] 215 cmds: 216 - golangci-lint run --enable gosec,ineffassign,unconvert ./keypair/... ./cert/... ./signing/... ./encryption/... ./pkcs12/... 217 - 'echo "✅ Security lint checks passed"' 218 silent: true 219 220 lint:summary: 221 desc: Show linting issues summary by type 222 deps: [lint:check] 223 cmds: 224 - | 225 echo "📊 Linting Issues Summary:" 226 golangci-lint run ./keypair/... ./cert/... ./signing/... --out-format=tab 2>/dev/null | cut -f3 | sort | uniq -c | sort -nr | head -10 227 silent: false 228 229 format: 230 desc: Format all Go code 231 cmds: 232 - go fmt ./... 233 - 'echo "✅ Code formatted"' 234 silent: true 235 236 format:check: 237 desc: Check if code is properly formatted 238 cmds: 239 - | 240 if [ -n "$(gofmt -l .)" ]; then 241 echo "❌ The following files need formatting:" 242 gofmt -l . 243 exit 1 244 else 245 echo "✅ All files are properly formatted" 246 fi 247 silent: true 248 249 # Module Management 250 mod:verify: 251 desc: Verify module dependencies 252 cmds: 253 - go mod verify 254 - 'echo "✅ Module dependencies verified"' 255 silent: true 256 257 mod:tidy: 258 desc: Clean up module dependencies 259 cmds: 260 - go mod tidy 261 - 'echo "✅ Module dependencies tidied"' 262 silent: true 263 264 mod:update: 265 desc: Update all dependencies to latest versions 266 cmds: 267 - go get -u ./... 268 - go mod tidy 269 - 'echo "✅ Dependencies updated"' 270 silent: true 271 272 mod:graph: 273 desc: Show module dependency graph 274 cmds: 275 - go mod graph 276 277 278 clean: 279 desc: Clean build artifacts and generated files 280 cmds: 281 - rm -rf bin/ dist/ _output/ output/ 282 - rm -f *.test *.out *.html 283 - rm -rf examples/keypair/output/ 284 - rm -rf examples/certificates/output/ 285 - rm -rf examples/signing/output/ 286 - rm -rf format_output/ 287 - rm -f *.pem *.key *.crt *.csr 288 - 'echo "✅ Cleaned build artifacts and generated files"' 289 silent: true 290 291 clean:cache: 292 desc: Clean Go build and test cache 293 cmds: 294 - go clean -cache 295 - go clean -testcache 296 - 'echo "✅ Go cache cleaned"' 297 silent: true 298 299 clean:all: 300 desc: Clean everything including module cache 301 deps: [clean, clean:cache] 302 cmds: 303 - go clean -modcache 304 - 'echo "✅ All caches and artifacts cleaned"' 305 silent: true 306 307 # Environment Tasks 308 env:check: 309 desc: Validate Go environment setup 310 cmds: 311 - go version 312 - go env GOPATH 313 - go env GOROOT 314 - go env GOOS 315 - go env GOARCH 316 - 'echo "✅ Go environment validated"' 317 318 env:doctor: 319 desc: Check project health and dependencies 320 cmds: 321 - 'echo "🔍 Checking project health..."' 322 - go version 323 - go mod verify 324 - go vet ./... 325 - 'echo "✅ Project health check complete"' 326 silent: true 327 328 # Benchmark Tasks 329 bench: 330 desc: Run all benchmarks 331 cmds: 332 - go test -bench=. ./... 333 334 # Security Tasks 335 security:check: 336 desc: Check for known vulnerabilities in dependencies 337 cmds: 338 - go list -json -m all | nancy sleuth 339 340 security:install: 341 desc: Install security scanning tools 342 cmds: 343 - go install github.com/sonatype-nexus-community/nancy@latest 344 - 'echo "✅ Security tools installed"' 345 silent: true 346 347 # Git Tasks 348 git:status: 349 desc: Show git status and current branch 350 cmds: 351 - git status 352 - git branch --show-current 353 354 git:update: 355 desc: Pull latest changes from repository 356 cmds: 357 - git pull 358 359 git:sync: 360 desc: Sync with remote repository 361 cmds: 362 - git fetch --all 363 - git pull 364 365 git:commit: 366 desc: Add and commit changes with message (usage - task git:commit -- "your commit message") 367 cmds: 368 - git add . 369 - git commit -m "{{.CLI_ARGS}}" 370 371 # Documentation Tasks 372 docs:install: 373 desc: Install documentation tools 374 cmds: 375 - | 376 if ! command -v godoc &> /dev/null; then 377 echo "⚠️ godoc not found. Installing..." 378 go install golang.org/x/tools/cmd/godoc@latest 379 fi 380 - 'echo "✅ Documentation tools installed"' 381 silent: true 382 383 docs:generate: 384 desc: Generate documentation files for all packages 385 deps: [docs:install] 386 cmds: 387 - mkdir -p output/docs/ 388 - | 389 echo "# GoPKI Library Documentation" > output/docs/README.md 390 echo "" >> output/docs/README.md 391 echo "## Keypair Package" >> output/docs/README.md 392 go doc -all ./keypair >> output/docs/README.md 393 echo "" >> output/docs/README.md 394 echo "## Certificate Package" >> output/docs/README.md 395 go doc -all ./cert >> output/docs/README.md 396 echo "" >> output/docs/README.md 397 echo "## Signing Package" >> output/docs/README.md 398 go doc -all ./signing >> output/docs/README.md 399 echo "" >> output/docs/README.md 400 echo "## Formats Package" >> output/docs/README.md 401 go doc -all ./signing/formats >> output/docs/README.md 402 - 'echo "✅ Documentation generated in output/docs/README.md"' 403 - 'echo "💡 For interactive docs, run: task docs:serve"' 404 generates: 405 - output/docs/README.md 406 silent: true 407 408 docs:serve: 409 desc: Start godoc server for interactive documentation 410 cmds: 411 - 'echo "🌐 Starting godoc server on http://localhost:6060"' 412 - 'echo "📖 Visit http://localhost:6060/pkg/{{.MODULE}}/ to view documentation"' 413 - godoc -http=:6060 414 415 docs:clean: 416 desc: Clean generated documentation 417 cmds: 418 - rm -rf output/docs/ 419 - 'echo "✅ Documentation cleaned"' 420 silent: true 421 422 # Example Management 423 examples:run: 424 desc: Run all examples 425 deps: [build] 426 cmds: 427 - 'echo "🔐 Running keypair examples..."' 428 - go run -tags example ./examples/keypair/main.go 429 - 'echo ""' 430 - 'echo "📜 Running certificate examples..."' 431 - go run -tags example ./examples/certificates/main.go 432 - 'echo ""' 433 - 'echo "✍️ Running document signing examples..."' 434 - go run -tags example ./examples/signing/main.go 435 - 'echo ""' 436 - 'echo "🔒 Running encryption examples..."' 437 - go run -tags example ./examples/encryption/main.go 438 - 'echo ""' 439 - 'echo "📦 Running PKCS#12 examples..."' 440 - go run -tags example ./examples/pkcs12/main.go 441 - 'echo "✅ All examples completed successfully!"' 442 silent: true 443 444 examples:keypair: 445 desc: Run keypair examples only 446 deps: [build] 447 cmds: 448 - go run -tags example ./examples/keypair/main.go 449 silent: true 450 451 examples:certificates: 452 desc: Run certificate examples only 453 deps: [build] 454 cmds: 455 - go run -tags example ./examples/certificates/main.go 456 silent: true 457 458 examples:signing: 459 desc: Run signing examples only 460 deps: [build] 461 cmds: 462 - go run -tags example ./examples/signing/main.go 463 silent: true 464 465 examples:encryption: 466 desc: Run encryption examples only 467 deps: [build] 468 cmds: 469 - go run -tags example ./examples/encryption/main.go 470 silent: true 471 472 examples:pkcs12: 473 desc: Run PKCS#12 examples only 474 deps: [build] 475 cmds: 476 - go run -tags example ./examples/pkcs12/main.go 477 silent: true 478 479 examples:clean: 480 desc: Clean example output directories 481 cmds: 482 - rm -rf examples/keypair/output/ 483 - rm -rf examples/certificates/output/ 484 - rm -rf examples/signing/output/ 485 - rm -rf examples/encryption/output/ 486 - rm -rf examples/pkcs12/output/ 487 - 'echo "✅ Example outputs cleaned"' 488 silent: true 489 490 # CI/CD Pipeline Tasks 491 ci: 492 desc: Run complete CI pipeline locally 493 deps: [format:check, lint:security, test:coverage, build] 494 cmds: 495 - 'echo "✅ CI pipeline completed successfully"' 496 silent: true 497 498 ci:quick: 499 desc: Run quick CI checks (format, lint, basic tests) 500 deps: [format:check, lint, test] 501 cmds: 502 - 'echo "✅ Quick CI checks completed"' 503 silent: true 504 505 ci:full: 506 desc: Run comprehensive CI pipeline with all checks 507 deps: [format:check, lint:full, lint:security, test:coverage, build, examples:run] 508 cmds: 509 - 'echo "✅ Full CI pipeline completed successfully"' 510 silent: true 511 512 release:check: 513 desc: Check if project is ready for release 514 deps: [format:check, lint:full, test:coverage, build] 515 cmds: 516 - | 517 echo "🔍 Release Readiness Check:" 518 echo " ✅ Code formatting verified" 519 echo " ✅ Linting checks passed" 520 echo " ✅ Test coverage analyzed" 521 echo " ✅ Build successful" 522 echo "" 523 echo "📦 Project appears ready for release!" 524 silent: false 525 526 pre-commit: 527 desc: Run pre-commit checks (format, quick lint, basic tests) 528 deps: [format, lint, test:quick] 529 cmds: 530 - 'echo "✅ Pre-commit checks completed"' 531 silent: true