A simple Rust application designed for testing Tekton CI/CD pipelines.
- Simple console application with multiple functions
- Unit tests using Rust's built-in test framework
- Dockerfile for containerization
- Compatible with Tekton pipelines
rust-demo-app/
├── Cargo.toml # Rust package manifest
├── Dockerfile # Multi-stage Docker build
├── .dockerignore # Docker ignore file
├── src/
│ └── main.rs # Main application with tests
└── README.md # This file
- Rust 1.75 or later
- Cargo (comes with Rust)
cargo runcargo testcargo test -- --nocapturedocker build -t rust-demo-app:latest .docker run --rm rust-demo-app:latestThis application is designed to work with the Tekton pipelines in the parent directory.
- Kubernetes cluster with Tekton installed
- Tekton tasks and pipelines configured (see parent directory)
- GitHub repository containing this code
- AWS ECR repository (if pushing images)
This application works with the rust-build-and-push pipeline which:
- Clones the repository
- Runs
cargo testto execute all tests - Builds a Docker image using the Dockerfile
- Pushes the image to AWS ECR
Create a PipelineRun to test this application:
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: rust-demo-app-build
spec:
pipelineRef:
name: rust-build-and-push
params:
- name: repo-url
value: "https://github.com/YOUR_USERNAME/YOUR_REPO.git"
- name: repo-name
value: "rust-demo-app"
- name: revision
value: "main"
- name: ecr-image
value: "123456789012.dkr.ecr.us-east-1.amazonaws.com/rust-demo-app"
- name: image-tag
value: "latest"
- name: dockerfile-path
value: "rust-demo-app/Dockerfile"
- name: test-command
value: "cd rust-demo-app && cargo test"
workspaces:
- name: shared-workspace
persistentVolumeClaim:
claimName: source-pvc
- name: aws-credentials
secret:
secretName: aws-ecr-credentialsThe application includes tests for:
- Addition function: Tests basic arithmetic
- Even number checker: Tests modulo operations
- Fibonacci calculator: Tests recursive logic
- Greeting function: Tests string formatting
All tests must pass for the Tekton pipeline to succeed.
You can extend this application to test various Tekton pipeline scenarios:
- Add more complex tests: Test failure scenarios
- Add dependencies: Test dependency resolution
- Add integration tests: Test external service calls
- Add benchmarks: Test performance testing in pipelines
- Add multiple binaries: Test multi-binary projects
MIT