๐ CI/CD Pipeline Example¶
Complete CI/CD pipeline example using Sloth Runner.
Overview¶
This example demonstrates a full CI/CD pipeline with: - Build - Test - Deploy - Monitoring
Complete Example¶
-- Build stage
task("build", {
description = "Build application",
command = function()
log.info("๐จ Building...")
local result = exec.run({ cmd = "go build -o app ./cmd" })
if not result.success then
return false, "Build failed: " .. result.stderr
end
return true, result.stdout
end
})
-- Test stage
task("test", {
description = "Run tests",
depends_on = {"build"},
command = function()
log.info("๐งช Testing...")
local result = exec.run({ cmd = "go test -v ./..." })
if not result.success then
return false, "Tests failed: " .. result.stderr
end
return true, result.stdout
end
})
-- Deploy stage
task("deploy", {
description = "Deploy to production",
depends_on = {"build", "test"},
command = function()
log.info("๐ Deploying...")
local result = exec.run({ cmd = "kubectl apply -f k8s/" })
if not result.success then
return false, "Deploy failed: " .. result.stderr
end
return true, "Deployment completed successfully"
end
})
Features Demonstrated¶
- โ Multi-stage pipeline
- โ Task dependencies
- โ Error handling
- โ Logging
- โ Deployment automation