This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
Improve the database engine handling #127
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Python 🐍 CI/CD tests | |
on: | |
push: | |
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] | |
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_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 }} |