This repository provides an example of how to use Docker Compose to run and test a Spring Boot API in GitHub Actions. The API provides basic CRUD operations for managing clients data, and the tests are written in robotframework.
To use this example, follow these steps:
- Fork this repository to your own GitHub account.
- Clone the repository to your local machine.
- Build the Docker images for the API and the DB.
- Start the Docker containers by running
docker-compose up -d
. - Run the tests by running
robot tests.robot
. - Stop the Docker containers by running
docker-compose down
.
This repository includes a GitHub Actions workflow that runs the Docker Compose commands to run and test the API whenever changes are pushed to the main branch. The workflow is defined in the .github/workflows/test.yml file.
The API provides the following endpoints:
- GET /api/v1/clients - Returns a list of all clients.
- GET /api/v1/clients/{id} - Returns the client with the specified ID.
- POST /api/v1/clients - Adds a new client.
- PUT /api/v1/clients/{id} - Updates the client with the specified ID.
- DELETE /api/v1/clients/{id} - Deletes the client with the specified ID.
Please update the following:
When running locally:
- Update the image names of the API and the database in the compose.yaml file.
- Ensure that Robot Framework is installed.
And in GitHub Actions:
- Please update the variables used to login to ghcr.io.