-
Notifications
You must be signed in to change notification settings - Fork 53
115 lines (112 loc) · 4.53 KB
/
single-postgres.yml
File metadata and controls
115 lines (112 loc) · 4.53 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Run pytest tests
on:
workflow_call:
inputs:
python-versions:
description: 'Supported python versions'
default: '["3.10", "3.11", "3.12", "3.13", "3.14", "pypy-3.11"]'
required: false
type: string
postgresql:
description: 'PostgreSQL version'
required: true
type: number
os:
description: 'Operating system to run tests on'
default: 'ubuntu-latest'
required: false
type: string
secrets:
codecov_token:
description: 'Codecov token'
required: false
jobs:
postgres:
runs-on: ${{ inputs.os }}
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJSON(inputs.python-versions) }}
env:
OS: ${{ inputs.os }}
PYTHON: ${{ matrix.python-version }}
POSTGRES: ${{ inputs.postgresql }}
steps:
- uses: actions/checkout@v6
- name: Set up Pipenv on python ${{ matrix.python-version }}
uses: fizyk/actions-reuse/.github/actions/pipenv-setup@v4.2.1
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: ankane/setup-postgres@v1
with:
postgres-version: ${{ inputs.postgresql }}
- name: Detect PostgreSQL path on Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$pgPath = "C:\Program Files\PostgreSQL\${{ inputs.postgresql }}\bin\pg_ctl.exe"
if (Test-Path $pgPath) {
echo "POSTGRESQL_EXEC=$pgPath" >> $env:GITHUB_ENV
} else {
$pgPath = (Get-Command pg_ctl -ErrorAction SilentlyContinue).Source
if ($pgPath) {
echo "POSTGRESQL_EXEC=$pgPath" >> $env:GITHUB_ENV
}
}
# Verify that PostgreSQL was found
if (-not $pgPath) {
Write-Error "Error: pg_ctl not found in expected locations. Checked hardcoded path and system PATH."
exit 1
}
- name: Set PostgreSQL path for Unix/macOS
if: runner.os != 'Windows'
run: |
# Try to find pg_ctl dynamically for cross-platform compatibility
if command -v pg_ctl >/dev/null 2>&1; then
PG_CTL_PATH=$(command -v pg_ctl)
echo "POSTGRESQL_EXEC=$PG_CTL_PATH" >> $GITHUB_ENV
elif [ -f "/opt/homebrew/opt/postgresql@${{ inputs.postgresql }}/bin/pg_ctl" ]; then
# macOS Apple Silicon Homebrew path
echo "POSTGRESQL_EXEC=/opt/homebrew/opt/postgresql@${{ inputs.postgresql }}/bin/pg_ctl" >> $GITHUB_ENV
elif [ -f "/usr/local/opt/postgresql@${{ inputs.postgresql }}/bin/pg_ctl" ]; then
# macOS Intel Homebrew path
echo "POSTGRESQL_EXEC=/usr/local/opt/postgresql@${{ inputs.postgresql }}/bin/pg_ctl" >> $GITHUB_ENV
elif [ -f "/usr/lib/postgresql/${{ inputs.postgresql }}/bin/pg_ctl" ]; then
# Debian/Ubuntu path (fallback)
echo "POSTGRESQL_EXEC=/usr/lib/postgresql/${{ inputs.postgresql }}/bin/pg_ctl" >> $GITHUB_ENV
else
echo "Error: pg_ctl not found in expected locations"
exit 1
fi
- name: Check installed locales
if: runner.os != 'Windows'
run: |
locale -a
- name: update locale for tests
if: ${{ inputs.os == 'ubuntu-latest' }}
run: |
sudo locale-gen de_DE.UTF-8
- name: install libpq
if: ${{ contains(matrix.python-version, 'pypy') && runner.os == 'Linux' }}
run: sudo apt install libpq5
- name: Run test
uses: fizyk/actions-reuse/.github/actions/pipenv-run@v4.2.1
with:
command: pytest -svv -p no:xdist --postgresql-exec="${{ env.POSTGRESQL_EXEC }}" -k "not docker" --cov-report=xml --basetemp="${{ runner.temp }}/pytest-basetemp"
- name: Run xdist test
uses: fizyk/actions-reuse/.github/actions/pipenv-run@v4.2.1
with:
command: pytest -n auto --dist loadgroup --max-worker-restart 0 --postgresql-exec="${{ env.POSTGRESQL_EXEC }}" -k "not docker" --cov-report=xml:coverage-xdist.xml --basetemp="${{ runner.temp }}/pytest-basetemp"
- uses: actions/upload-artifact@v7
if: failure()
with:
name: postgresql-${{ matrix.python-version }}-${{ inputs.postgresql }}
path: ${{ runner.temp }}/pytest-basetemp/**
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5.5.2
with:
token: ${{ secrets.codecov_token }}
flags: unittests
env_vars: OS,PYTHON
fail_ci_if_error: false