A simple Golang demo application with CI/CD pipeline for AWS EKS deployment.
- Simple HTTP server with calculator functionality
- Health check endpoint
- Unit tests with coverage
- Docker containerization
- CI/CD pipeline with GitHub Actions
- AWS ECR image registry
- EKS deployment with manual review step
GET /health- Health check endpointPOST /calculator- Calculator endpoint for arithmetic operationsGET /hello?name=<name>- Simple greeting endpoint
Send a POST request to /calculator with JSON body:
{
"a": 10,
"b": 5,
"operator": "add"
}Supported operators: add, subtract, multiply, divide, +, -, *, /
- Go 1.21 or later
- Docker (optional)
- Make
# Install dependencies
make deps
# Run tests
make test
# Run the application
make run
# Or run with Go directly
go run main.goThe application will start on port 8080 (configurable via PORT environment variable).
# Run tests (generates test-results.xml)
make test
# Run tests with coverage (generates coverage.out, coverage.html, coverage.txt, coverage.json)
make test-coverage
# Run linting
make lintTest Output Formats:
test-results.xml- JUnit XML format for CI/CD integrationcoverage.out- Go coverage data filecoverage.html- HTML coverage reportcoverage.txt- Text coverage report with function-level detailscoverage.json- JSON format with coverage percentage for programmatic processing
# Build Docker image
make docker-build
# Run container locally
make docker-run
# Stop container
make docker-stopThe GitHub Actions workflow includes:
- Initialize Kosli: Sets up Kosli flow and begins audit trail
- Test Stage: Runs unit tests, linting, and coverage analysis with Kosli attestations
- Build and Push: Builds Docker image and pushes to AWS ECR with artifact attestation
- Manual Review: Requires manual approval before deployment with approval attestation
- Deploy to EKS: Deploys the application to Amazon EKS cluster
The pipeline includes comprehensive Kosli attestations for compliance and audit trails:
- Pull Request Attestation: Links code changes to the deployment trail
- Test Results: Attests unit test results and coverage metrics
- Artifact Attestation: Records Docker image build and push to ECR
- Manual Approval: Captures approval/rejection decisions with approver details
- Custom Attestation Types: Uses structured schemas for coverage and approval data
Configure the following secrets in your GitHub repository:
AWS_ACCESS_KEY_ID: AWS access keyAWS_SECRET_ACCESS_KEY: AWS secret keyKOSLI_API_TOKEN: Kosli API token for attestations
AWS_REGION: AWS region (default: eu-central-1)ECR_REPOSITORY: ECR repository name (default: demo-app)EKS_CLUSTER_NAME: EKS cluster name (default: demo-cluster)KOSLI_ORG: Kosli organization name (default: kosli-public)KOSLI_FLOW: Kosli flow name (default: demo-app)
The pipeline uses two environments:
manual-review: Requires manual approval and attests the decision to Kosliproduction: Deploys to EKS cluster
When a deployment requires manual approval:
- The workflow pauses at the
manual-reviewenvironment - An authorized user must approve or reject the deployment
- The approval decision is automatically attested to Kosli with:
- Approval status (approved/rejected)
- Approver username
- Timestamp
- Environment context
- Commit SHA and workflow run ID
make help- Show available targetsmake test- Run unit testsmake test-coverage- Run tests with coveragemake build- Build the applicationmake run- Run the application locallymake docker-build- Build Docker imagemake docker-run- Run Docker containermake docker-push- Push image to ECRmake lint- Run linting toolsmake clean- Clean build artifacts
.
├── main.go # Main application code
├── main_test.go # Unit tests
├── go.mod # Go module file
├── Dockerfile # Docker configuration
├── Makefile # Build automation
├── k8s/ # Kubernetes manifests
│ ├── deployment.yaml # Deployment configuration
│ └── service.yaml # Service configuration
├── custom-attestation-types/ # Kosli custom attestation schemas
│ ├── coverage.schema.json # Coverage attestation schema
│ └── manual-approval.schema.json # Manual approval schema
├── .github/
│ └── workflows/
│ ├── ci-cd.yml # GitHub Actions workflow
│ └── custom-attestation-types.yml # Kosli schema validation
└── README.md # This file