CI/CD Configuration
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The CI/CD configuration for the SafeDispatch HQ Administration API project is designed to automate the integration, testing, and deployment of the Java-based Spring Boot application. It leverages GitLab's built-in continuous integration capabilities to ensure code quality through static analysis and comprehensive automated testing.
The workflow focus is on verifying application integrity before deployment to target environments like Kubernetes or Amazon Web Services (AWS). This includes executing unit and integration tests, performing security scans, and managing build artifacts using the Gradle wrapper.
Sources: README.md:19-25, Part1/API/gradlew.bat
Pipeline Architecture and Lifecycle
The project utilizes a standard GitLab CI/CD lifecycle that transitions from local development and environment setup to automated verification and deployment.
Build and Environment Setup
The project uses Gradle as its build automation tool. The gradlew.bat file provides a script for Windows environments to execute Gradle commands without requiring a pre-installed Gradle distribution, ensuring consistency across different development and CI environments. It requires JAVA_HOME to be configured and defaults to 64MB of heap space for the JVM.
Sources: Part1/API/gradlew.bat:32-48, Part1/API/gradlew.bat:69
Automated Testing Suite
The pipeline executes a robust suite of tests to validate business logic and API endpoints. These tests are categorized into service-level unit tests and controller-level integration tests.
| Test Category | Target Component | Purpose |
|---|---|---|
| Unit Tests | EmployeeService, DepartmentService | Validates business logic such as promotion eligibility and budget constraints. |
| Integration Tests | EmployeeController, DepartmentController | Validates REST endpoints, status codes, and repository interactions. |
| Context Tests | ApiApplicationTests | Ensures the Spring ApplicationContext loads correctly. |
Sources: Part1/API/src/test/java/com/example/api/EmployeeServiceTest.java, Part1/API/src/test/java/com/example/api/EmployeeControllerTest.java, Part1/API/src/test/java/com/example/api/ApiApplicationTests.java
CI/CD Flow Diagram
The following diagram illustrates the high-level flow of the CI/CD pipeline from code commit to deployment.
The pipeline integrates Static Application Security Testing (SAST) to identify vulnerabilities before the code is deployed to protected environments.
Sources: README.md:20-24
Security and Quality Gates
The CI/CD configuration includes specific gates to maintain high code standards and security.
Static Application Security Testing (SAST)
The project is configured to use GitLab's built-in SAST to analyze the source code for known vulnerabilities. This is a critical step in the "Test and Deploy" phase mentioned in the project documentation.
Sources: README.md:21
Protected Environments
To ensure stability, the project supports "Protected Environments." This feature limits deployment to critical production environments (like AWS or Kubernetes clusters) to authorized users or successful pipeline completions.
Sources: README.md:24
Promotion Logic Verification
A key business logic component verified during the CI process is the employee promotion eligibility. The pipeline ensures that the logic requiring an employee to have started more than 6 months ago is strictly enforced via automated tests.
Deployment Targets
The project supports multiple modern deployment strategies supported by the GitLab runner environment.
- Kubernetes: Using the GitLab Agent for pull-based deployments.
- Amazon Web Services: Deployment to EC2 (Elastic Compute Cloud) or ECS (Elastic Container Service).
- Auto Deploy: Automated deployment logic for rapid iteration.
Sources: README.md:22-23
Conclusion
The CI/CD configuration provides a streamlined path from development to production. By utilizing the Gradle wrapper for consistent builds, executing a comprehensive test suite covering service and controller logic, and integrating security scanning, the project ensures that only high-quality, secure code reaches the deployment targets on AWS or Kubernetes.