Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Use pydantic settings management #133

Use pydantic settings management

Use pydantic settings management #133

Workflow file for this run

name: Python 🐍 CI/CD tests
on:
push:
branches: [main, develop]
paths-ignore: # prevents workflow execution when only these types of files are modified
- "**.md" # wildcards prevent file in any repo dir from trigering workflow
- "**.bib"
- "**.ya?ml" # captures both .yml and .yaml
- "LICENSE"
- ".gitignore"
pull_request:
branches: [main, develop]
types: [opened, reopened] # excludes syncronize to avoid redundant trigger from commits on PRs
paths-ignore:
- "**.md"
- "**.bib"
- "**.ya?ml"
- "LICENSE"
- ".gitignore"
workflow_dispatch: # also allow manual trigger, for testing purposes
defaults:
run:
shell: bash -l {0}
jobs:
build:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
env:
DATABASE_URL: postgresql+psycopg://user:password@localhost:5432/testdb
API_KEY: test_api_key
strategy:
matrix:
python-version: ["3.11", "3.12"]
os: [ubuntu-latest]
services:
postgres:
image: postgres
env:
POSTGRES_DB: testdb
POSTGRES_USER: user
POSTGRES_PASSWORD: password
ports:
- 5432:5432
# Use health checks to wait until postgres is ready
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: pip install .[test]
- name: Wait for PostgreSQL to start
run: |
until pg_isready -h localhost -p 5432 -U user; do
echo "Waiting for PostgreSQL to start..."
sleep 2
done
- name: Run unit tests
run: pytest tests/unit
- name: Run integrations tests
run: pytest tests/integration
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}