-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (86 loc) · 3.86 KB
/
codecov.yml
File metadata and controls
94 lines (86 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This workflow will run tests using pytest and upload the coverage report to Codecov
# Run test with various Python versions and database drivers
name: Integration Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9","3.10","3.11","3.12"]
driver: ["pg8000", "psycopg2", "psycopg", "psycopg2cffi", "asyncpg"]
name: Test pgmq-sqlalchemy (Python ${{ matrix.python-version }}, Driver ${{ matrix.driver }})
env:
# Create unique database name for this combination
DB_NAME_RAW: pgmq_py${{ matrix.python-version }}_${{ matrix.driver }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Install uv
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Install dependencies
run: uv sync --extra dev
- name: Start PostgreSQL
run: |
cp pgmq_postgres.template.env pgmq_postgres.env
cp pgmq_tests.template.env pgmq_tests.env
make start-db
- name: Setup unique database for this test run
run: |
# Normalize database name (remove dots and hyphens)
# Note: We normalize in each step because GitHub Actions doesn't support
# computed environment variables that can be reused across steps
export DB_NAME=$(echo "$DB_NAME_RAW" | sed 's/\.//g' | sed 's/-/_/g')
# Create the database
docker compose exec -T pgmq_postgres psql -U postgres -c "DROP DATABASE IF EXISTS ${DB_NAME};" || true
docker compose exec -T pgmq_postgres psql -U postgres -c "CREATE DATABASE ${DB_NAME};"
docker compose exec -T pgmq_postgres psql -U postgres -d ${DB_NAME} -c "CREATE EXTENSION IF NOT EXISTS pgmq CASCADE;"
- name: Run tests for specific driver
run: |
# Normalize database name (remove dots and hyphens)
export DB_NAME=$(echo "$DB_NAME_RAW" | sed 's/\.//g' | sed 's/-/_/g')
# Create unique coverage file name
export COVERAGE_FILE=".coverage.py${{ matrix.python-version }}.${{ matrix.driver }}"
uv run pytest tests --driver=${{ matrix.driver }} --db-name=${DB_NAME} --cov=pgmq_sqlalchemy.queue --cov-report=xml:coverage-py${{ matrix.python-version }}-${{ matrix.driver }}.xml
- name: Upload coverage artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-py${{ matrix.python-version }}-${{ matrix.driver }}
path: coverage-py${{ matrix.python-version }}-${{ matrix.driver }}.xml
retention-days: 1
- name: Cleanup database
if: always()
run: |
# Normalize database name (remove dots and hyphens)
export DB_NAME=$(echo "$DB_NAME_RAW" | sed 's/\.//g' | sed 's/-/_/g')
docker compose exec -T pgmq_postgres psql -U postgres -c "DROP DATABASE IF EXISTS ${DB_NAME};" || true
upload-coverage:
needs: test
runs-on: ubuntu-latest
name: Upload coverage to Codecov
steps:
- uses: actions/checkout@v4
- name: Download all coverage artifacts
uses: actions/download-artifact@v4
with:
path: coverage-reports
pattern: coverage-*
merge-multiple: true
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
directory: ./coverage-reports
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}