This repository contains the release branches for the FastAPI very basic project.
The staging
branch is the intermediary protected branch and the main
branch is the latest stable production release.
Development flow follows main
-> staging
-> feature
-> staging
-> main
-> release
.
Release notes are generated using Commitizen and Conventional Commits. They are generated from the CHANGELOG.md
file.
Standard reinforced conventional commits are enforced using pre-commit. Basically, defined as follows:
feat
: A new featurefix
: A bug fixdocs
: Documentation only changesstyle
: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)refactor
: A code change that neither fixes a bug nor adds a featureperf
: A code change that improves performancetest
: Adding missing tests or correcting existing testsbuild
: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)ci
: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)chore
: Other changes that don't modify src or test filesrevert
: Reverts a previous commit
Install the project dependencies:
poetry install
Enforce the pre-commit hooks for conventional commits:
poetry run pre-commit install --hook-type commit-msg --hook-type pre-push
Start the application with uvicorn:
poetry run uvicorn api.app:app --reload
Or using scripts definition:
poetry run api
Run the tests:
poetry run pytest ./tests
Build the docker image:
docker build -t api-app .
Run the docker image as a container:
docker run --name f-api -p 8888:8000 -d api-app
Use docker compose to run the application:
docker-compose up -d
Shutdown with docker compose:
docker-compose down
This is a process sequence to release a new version of the project.
# from staging branch
git checkout -b feat/X
# do all changes and commits
poetry run cz --no-raise 21 bump --yes --changelog --check-consistency
git push origin feat/X
## PR, approve and merge
git checkout staging
git pull
# when ready to release
git push origin staging:main
git checkout main
git pull
echo $(head -1 CHANGELOG.md | awk '{print $2}')
git push origin $(head -1 CHANGELOG.md | awk '{print $2}')