mirror of
https://github.com/ivuorinen/gh-action-readme.git
synced 2026-01-26 11:14:04 +00:00
* chore(lint): added nlreturn, run linting * chore(lint): replace some fmt.Sprintf calls * chore(lint): replace fmt.Sprintf with strconv * chore(lint): add goconst, use http lib for status codes, and methods * chore(lint): use errors lib, errCodes from internal/errors * chore(lint): dupl, thelper and usetesting * chore(lint): fmt.Errorf %v to %w, more linters * chore(lint): paralleltest, where possible * perf(test): optimize test performance by 78% - Implement shared binary building with package-level cache to eliminate redundant builds - Add strategic parallelization to 15+ tests while preserving environment variable isolation - Implement thread-safe fixture caching with RWMutex to reduce I/O operations - Remove unnecessary working directory changes by leveraging embedded templates - Add embedded template system with go:embed directive for reliable template resolution - Fix linting issues: rename sharedBinaryError to errSharedBinary, add nolint directive Performance improvements: - Total test execution time: 12+ seconds → 2.7 seconds (78% faster) - Binary build overhead: 14+ separate builds → 1 shared build (93% reduction) - Parallel execution: Limited → 15+ concurrent tests (60-70% better CPU usage) - I/O operations: 66+ fixture reads → cached with sync.RWMutex (50% reduction) All tests maintain 100% success rate and coverage while running nearly 4x faster.
120 lines
4.0 KiB
Makefile
120 lines
4.0 KiB
Makefile
.PHONY: help test lint run example clean readme config-verify security vulncheck audit snyk trivy gitleaks \
|
|
editorconfig editorconfig-fix format
|
|
|
|
all: help
|
|
|
|
help: ## Show this help message
|
|
@echo "GitHub Action README Generator - Available Make Targets:"
|
|
@echo ""
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
|
|
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
@echo ""
|
|
@echo "Common workflows:"
|
|
@echo " make test lint # Run tests and linting"
|
|
@echo " make format # Format code and fix EditorConfig issues"
|
|
@echo " make security # Run all security scans"
|
|
|
|
test: ## Run all tests
|
|
go test ./...
|
|
|
|
lint: format ## Run linter (after formatting)
|
|
golangci-lint run \
|
|
--max-issues-per-linter 100 \
|
|
--max-same-issues 50 \
|
|
--output.tab.path stdout || true
|
|
|
|
config-verify: ## Verify golangci-lint configuration
|
|
golangci-lint config verify --verbose
|
|
|
|
run: ## Run the application
|
|
go run .
|
|
|
|
example: ## Generate example README
|
|
go run . gen --config config.yml --output-format=md
|
|
|
|
readme: ## Generate project README
|
|
go run . gen --config config.yml --output-format=md
|
|
|
|
clean: ## Clean build artifacts
|
|
rm -rf dist/
|
|
|
|
# Code formatting and EditorConfig targets
|
|
format: editorconfig-fix ## Format code and fix EditorConfig issues
|
|
@echo "Running all formatters..."
|
|
@command -v gofmt >/dev/null 2>&1 && gofmt -w -s . || echo "gofmt not available"
|
|
@command -v goimports >/dev/null 2>&1 && \
|
|
goimports -w -local github.com/ivuorinen/gh-action-readme . || \
|
|
echo "goimports not available"
|
|
|
|
editorconfig: ## Check EditorConfig compliance
|
|
@echo "Checking EditorConfig compliance..."
|
|
@command -v eclint >/dev/null 2>&1 || \
|
|
{ echo "Please install eclint: npm install -g eclint"; exit 1; }
|
|
@echo "Checking files for EditorConfig compliance..."
|
|
@find . -type f \( \
|
|
-name "*.go" -o \
|
|
-name "*.yml" -o \
|
|
-name "*.yaml" -o \
|
|
-name "*.json" -o \
|
|
-name "*.md" -o \
|
|
-name "Makefile" -o \
|
|
-name ".snyk" -o \
|
|
-name "*.tmpl" -o \
|
|
-name "*.adoc" -o \
|
|
-name "*.sh" \
|
|
\) -not -path "./gh-action-readme" -not -path "./coverage*" \
|
|
-not -path "./testutil.test" -not -path "./test_*" | \
|
|
xargs eclint check
|
|
|
|
editorconfig-fix: ## Fix EditorConfig violations
|
|
@echo "Fixing EditorConfig violations..."
|
|
@command -v eclint >/dev/null 2>&1 || \
|
|
{ echo "Please install eclint: npm install -g eclint"; exit 1; }
|
|
@echo "Fixing files for EditorConfig compliance..."
|
|
@find . -type f \( \
|
|
-name "*.go" -o \
|
|
-name "*.yml" -o \
|
|
-name "*.yaml" -o \
|
|
-name "*.json" -o \
|
|
-name "*.md" -o \
|
|
-name "Makefile" -o \
|
|
-name ".snyk" -o \
|
|
-name "*.tmpl" -o \
|
|
-name "*.adoc" -o \
|
|
-name "*.sh" \
|
|
\) -not -path "./gh-action-readme" -not -path "./coverage*" \
|
|
-not -path "./testutil.test" -not -path "./test_*" | \
|
|
xargs eclint fix
|
|
|
|
# Security targets
|
|
security: vulncheck snyk trivy gitleaks ## Run all security scans
|
|
@echo "All security scans completed"
|
|
|
|
vulncheck: ## Run Go vulnerability check
|
|
@echo "Running Go vulnerability check..."
|
|
@command -v govulncheck >/dev/null 2>&1 || \
|
|
{ echo "Installing govulncheck..."; go install golang.org/x/vuln/cmd/govulncheck@latest; }
|
|
govulncheck ./...
|
|
|
|
audit: vulncheck ## Run comprehensive security audit
|
|
@echo "Running comprehensive security audit..."
|
|
go list -json -deps ./... | jq -r '.Module | select(.Path != null) | .Path + "@" + .Version' | sort -u
|
|
|
|
snyk: ## Run Snyk security scan
|
|
@echo "Running Snyk security scan..."
|
|
@command -v snyk >/dev/null 2>&1 || \
|
|
{ echo "Please install Snyk CLI: npm install -g snyk"; exit 1; }
|
|
snyk test --file=go.mod --package-manager=gomodules
|
|
|
|
trivy: ## Run Trivy filesystem scan
|
|
@echo "Running Trivy filesystem scan..."
|
|
@command -v trivy >/dev/null 2>&1 || \
|
|
{ echo "Please install Trivy: https://aquasecurity.github.io/trivy/"; exit 1; }
|
|
trivy fs . --severity HIGH,CRITICAL
|
|
|
|
gitleaks: ## Run gitleaks secrets detection
|
|
@echo "Running gitleaks secrets detection..."
|
|
@command -v gitleaks >/dev/null 2>&1 || \
|
|
{ echo "Please install gitleaks: https://github.com/gitleaks/gitleaks"; exit 1; }
|
|
gitleaks detect --source . --verbose
|