This project demonstrates how to set up and use Testcontainers with FastAPI to ensure reliable and isolated test environments. By automating your tests, you can maintain high code quality and gain valuable insights into your system's performance and behavior.
Clone the repository and install the dependencies:
git clone https://github.com/gil-air-may/test-containers.git
cd test-containers
pip install -r requirements.txt
Start the FastAPI application:
uvicorn main:app --reload
Run tests with coverage:
pytest --cov=app tests/
This project uses GitHub Actions for continuous integration (CI) to automate testing. The CI workflow is defined in the .github/workflows/ci.yml
file and includes the following steps:
- Checkout code: Checks out the repository code.
- Set up Python: Sets up the specified version of Python.
- Install dependencies: Installs the required dependencies listed in
requirements.txt
. - Run tests with coverage: Executes tests and generates a coverage report.
- Set up Git for Pages: Configures Git with GitHub Actions bot credentials.
- Checkout
gh-pages
branch: Checks out thegh-pages
branch for updating the coverage badge. - Copy coverage badge: Copies the generated coverage badge to the correct location.
- Add and commit coverage badge: Adds and commits the coverage badge.
- Push to
gh-pages
branch: Pushes the updated badge to thegh-pages
branch.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License.