tentative to add ci pipeline
This commit is contained in:
56
.gitlab-ci.yml
Normal file
56
.gitlab-ci.yml
Normal file
@ -0,0 +1,56 @@
|
||||
# GitLab CI/CD Configuration for FastAPI
|
||||
stages:
|
||||
- test
|
||||
- deploy
|
||||
- release
|
||||
|
||||
variables:
|
||||
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.pip_cache"
|
||||
VIRTUAL_ENV: ".venv"
|
||||
|
||||
# Cache for dependencies
|
||||
cache:
|
||||
paths:
|
||||
- .pip_cache/
|
||||
|
||||
before_script: # common setup for every job
|
||||
- python3 -m venv $VIRTUAL_ENV
|
||||
- source $VIRTUAL_ENV/bin/activate
|
||||
- pip install --upgrade pip
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- source $VIRTUAL_ENV/bin/activate
|
||||
- pip install -r requirements.txt
|
||||
- pytest --cov=app --cov-report=xml # Run tests and generate coverage report
|
||||
|
||||
lint:
|
||||
stage: test
|
||||
script:
|
||||
- source $VIRTUAL_ENV/bin/activate
|
||||
- pip install flake8
|
||||
- flake8 app/ # Run linting for code quality
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
only:
|
||||
- main
|
||||
script:
|
||||
- echo "Updating repository..."
|
||||
- git pull origin main # Update the repository with the latest code
|
||||
- echo "Setting up Python dependencies..."
|
||||
- source $VIRTUAL_ENV/bin/activate
|
||||
- pip install -r requirements.txt # Install the required Python dependencies
|
||||
- bash ./make_openapi_client.sh # Re-generate OpenAPI client library
|
||||
- echo "Running the application..."
|
||||
- python3.8 -m main # Replace with the exact command to start your app
|
||||
|
||||
release:
|
||||
stage: release
|
||||
when: manual
|
||||
variables:
|
||||
TWINE_USERNAME: gitlab-ci-token
|
||||
TWINE_PASSWORD: $CI_JOB_TOKEN
|
||||
script:
|
||||
- bash make_openapi_client.sh
|
Reference in New Issue
Block a user