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
53 changes: 6 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ on:
permissions:
contents: write

env:
GO_VERSION: "1.24.x"

jobs:
test:
name: Test and Quality Checks
runs-on: ${{ matrix.os }}
if: github.event_name == 'pull_request' || github.event_name == 'push'

env:
GO_VERSION: ${{ matrix.go-version }}

strategy:
matrix:
os: [ubuntu-latest, macos-latest]
go-version: ["1.23", "1.24.4"]
go-version: ["1.24.x"]
fail-fast: false

steps:
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.24.4'
if: matrix.os == 'ubuntu-latest'
with:
token: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -85,47 +85,6 @@ jobs:
name: task-engine-tests
token: ${{ secrets.CODECOV_TOKEN }}

staging-validation:
name: Staging Validation
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: test

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Install development tools
run: make install-tools

- name: Validate library builds
run: |
# Validate that the library can be built successfully
go build ./...

- name: Run integration tests
run: make test-ci

- name: Check go mod tidy
run: |
go mod tidy
git diff --exit-code -- go.mod go.sum

release-validation:
name: Release Validation
runs-on: ubuntu-latest
Expand Down Expand Up @@ -187,7 +146,7 @@ jobs:
echo "" >> release-info.md
echo "This release has been tested on:" >> release-info.md
echo "- **Operating Systems**: Linux, macOS" >> release-info.md
echo "- **Go Versions**: 1.23, 1.24.4+" >> release-info.md
echo "- **Go Versions**: ${{ env.GO_VERSION }}+" >> release-info.md

- name: Upload release documentation
uses: softprops/action-gh-release@v2
Expand Down
56 changes: 31 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
.PHONY: help test test-unit test-coverage clean fmt fmt-check vet lint tidy deps check install-tools security dev
.PHONY: help test test-unit test-unit-ci test-integration test-integration-ci test-coverage clean fmt fmt-check vet lint tidy deps check install-tools security dev test-coverage-ci

help: ## Show available commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'

test: test-unit ## Run all tests

# Base test execution - generates JSON output
test-unit-json: ## Run unit tests and save JSON output
@go test -json -run "^Test.*" ./... > test-unit.json

# Local development formatters (human-readable)
test-unit: test-unit-json install-tools ## Run unit tests with human-readable output
@if command -v gotestfmt >/dev/null 2>&1; then \
cat test-unit.json | gotestfmt; \
else \
echo "gotestfmt not found, running tests without formatting..."; \
go test ./...; \
fi

# CI formatters (JUnit XML)
test-unit-ci: test-unit-json install-tools ## Run unit tests with JUnit XML output for CI
@if command -v gotestsum >/dev/null 2>&1; then \
gotestsum --junitfile=junit-unit.xml --format=testname --raw-command -- cat test-unit.json; \
else \
echo "gotestsum not found, running tests without JUnit XML..."; \
go test ./...; \
fi
# Unit tests with live progress and JSON capture
test-unit: ## Run unit tests with live progress
@go test -json -run "^Test.*" ./... | tee test-unit.json | gotestfmt

# Unit tests with JUnit XML output and live progress for CI
test-unit-ci: ## Run unit tests with JUnit XML output and live progress for CI
@go test -json -run "^Test.*" ./... | tee test-unit.json | gotestfmt
@gotestsum --junitfile=junit-unit.xml --format=testname --raw-command -- cat test-unit.json

# Integration tests with live progress and JSON capture
test-integration: ## Run integration tests with live progress
@go test -json -race ./... | tee test-integration.json | gotestfmt

# Integration tests with JUnit XML output and live progress for CI
test-integration-ci: ## Run integration tests with JUnit XML output and live progress for CI
@go test -json -race ./... | tee test-integration.json | gotestfmt
@gotestsum --junitfile=junit-integration.xml --format=testname --raw-command -- cat test-integration.json

test-ci: test-unit-ci ## Run all tests with JUnit XML output for CI

test-coverage: ## Run tests with coverage
@go test -v -race -coverprofile=coverage.out ./...

# Coverage tests with live progress and JSON capture
test-coverage-ci: ## Run tests with coverage and live progress for CI
@go test -json -race -coverprofile=coverage.out ./... | tee test-coverage.json | gotestfmt

clean: ## Clean build artifacts
@rm -f *coverage.out junit-unit.xml test-unit.json test-e2e.json
@rm -f *coverage.out junit-unit.xml junit-integration.xml test-unit.json test-integration.json test-e2e.json test-coverage.log test-coverage.json security-scan.log vulnerability-scan.log
@rm -f coverage.out coverage.html coverage.txt
@rm -f test-*.json test-*.log test-*.xml
@rm -f *-scan.log *-coverage.log *-test.log
@rm -f junit-*.xml
@rm -f coverage-*.out security-*.log
@rm -f *.log *.json *.xml *.out
@go clean

fmt: ## Format code
Expand All @@ -58,9 +64,9 @@ check: fmt vet ## Run code quality checks

security: ## Run security and vulnerability checks
@echo "Running static security analysis..."
@gosec -exclude=G304,G115 ./...
@gosec -exclude=G304,G115 ./... | tee security-scan.log
@echo "Running vulnerability scanning..."
@govulncheck ./...
@govulncheck ./... | tee vulnerability-scan.log

install-tools: ## Install development tools
@go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.1
Expand Down
77 changes: 26 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,64 +47,49 @@ func main() {

- **Type-Safe Actions**: Generic-based architecture with compile-time safety
- **24+ Built-in Actions**: File operations, Docker management, system commands, package management
- **Action Parameter Passing**: Seamless data flow between actions and tasks using declarative parameter references
- **Lifecycle Management**: Before/Execute/After hooks with proper error handling
- **Context Support**: Cancellation and timeout handling
- **Comprehensive Logging**: Structured logging with configurable output
- **Easy Testing**: Built-in mocking support for all actions

## Built-in Actions

The Task Engine includes 19+ built-in actions covering file operations, Docker management, system administration, and utilities. For a complete inventory with detailed documentation, parameters, and examples, see [ACTIONS.md](ACTIONS.md).

### Docker Environment Setup
The Task Engine includes 19+ built-in actions for file operations, Docker management, system administration, and utilities. See [ACTIONS.md](ACTIONS.md) for complete documentation.

```go
import "github.com/ndizazzo/task-engine/tasks"

task := tasks.NewDockerSetupTask(logger, "/path/to/project")
// Common task examples
dockerTask := tasks.NewDockerSetupTask(logger, "/path/to/project")
fileTask := tasks.NewFileOperationsTask(logger, "/path/to/project")
packageTask := tasks.NewPackageManagementTask(logger, []string{"git", "curl"})
```

Sets up a complete Docker environment with service management and health checks.
## Action Parameter Passing

### File Operations Workflow
Actions can reference outputs from previous actions and tasks using declarative parameters:

```go
task := tasks.NewFileOperationsTask(logger, "/path/to/project")
```

Demonstrates file creation, copying, text replacement, and cleanup.

### Package Management

```go
task := tasks.NewPackageManagementTask(logger, []string{"git", "curl", "wget", "htop"})
```

Cross-platform package installation supporting Debian-based Linux (apt) and macOS (Homebrew).

### Compression Operations

```go
task := tasks.NewCompressionOperationsTask(logger, "/path/to/project")
```

Shows file compression and decompression workflows with auto-detection.

### System Management

```go
task := tasks.NewSystemManagementTask(logger, "nginx")
```

Demonstrates system service management and administrative operations.

### Utility Operations
// Action-to-action parameter passing
file.NewReplaceLinesAction(
"input.txt",
map[*regexp.Regexp]string{
regexp.MustCompile("{{content}}"):
task_engine.ActionOutput("read-file", "content"),
},
logger,
)

```go
task := tasks.NewUtilityOperationsTask(logger)
// Cross-task parameter passing
docker.NewDockerRunAction(
task_engine.TaskOutput("build-app", "imageID"),
[]string{"-p", "8080:8080"},
logger,
)
```

Shows utility operations including timing, prerequisites, and system information.
See [docs/parameter_passing.md](docs/parameter_passing.md) for complete documentation.

## Creating Custom Actions

Expand Down Expand Up @@ -162,27 +147,17 @@ if err := task.Run(ctx); err != nil {

## Testing

The module provides comprehensive testing support:

### Testing Support

The module provides comprehensive testing utilities:
The module provides comprehensive testing support with mocks and performance testing:

```go
import "github.com/ndizazzo/task-engine/testing"
import "github.com/ndizazzo/task-engine/testing/mocks"

// Performance testing
tester := testing.NewPerformanceTester(taskManager, logger)
metrics := tester.BenchmarkTaskExecution(ctx, task, 100, 10)

// Mock implementations
mockManager := mocks.NewEnhancedTaskManagerMock()
mockRunner := &mocks.MockCommandRunner{}
logger := mocks.NewDiscardLogger()
```

See [testing/README.md](testing/README.md) for comprehensive testing documentation.
See [testing/README.md](testing/README.md) for complete testing documentation.

## License

Expand Down
Loading
Loading