Skip to content

Commit 587491e

Browse files
authored
Merge pull request #4 from cybertec-postgresql/fix-workflow
Refresh testing harness at multiple places, remove some stubbornly broken parts for the meantime
2 parents 564ccab + 21240ec commit 587491e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+110
-82
lines changed

.github/workflows/install_deps.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,32 @@
99

1010

1111
def install_requirements(what):
12+
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip'])
13+
s = subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'wheel', 'setuptools'])
14+
if s != 0:
15+
return s
16+
1217
old_path = sys.path[:]
1318
w = os.path.join(os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe())))
1419
sys.path.insert(0, os.path.dirname(os.path.dirname(w)))
1520
try:
1621
from setup import EXTRAS_REQUIRE, read
1722
finally:
1823
sys.path = old_path
19-
requirements = ['mock>=2.0.0', 'flake8', 'pytest', 'pytest-cov'] if what == 'all' else ['behave']
24+
requirements = ['flake8', 'pytest', 'pytest-cov'] if what == 'all' else ['behave']
2025
requirements += ['coverage']
2126
# try to split tests between psycopg2 and psycopg3
2227
requirements += ['psycopg[binary]'] if sys.version_info >= (3, 8, 0) and\
23-
(sys.platform != 'darwin' or what == 'etcd3') else ['psycopg2-binary']
28+
(sys.platform != 'darwin' or what == 'etcd3') else ['psycopg2-binary==2.9.9'
29+
if sys.platform == 'darwin' else 'psycopg2-binary']
2430
for r in read('requirements.txt').split('\n'):
2531
r = r.strip()
2632
if r != '':
2733
extras = {e for e, v in EXTRAS_REQUIRE.items() if v and any(r.startswith(x) for x in v)}
2834
if not extras or what == 'all' or what in extras:
2935
requirements.append(r)
3036

31-
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'pip'])
32-
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'wheel'])
33-
r = subprocess.call([sys.executable, '-m', 'pip', 'install'] + requirements)
34-
s = subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'setuptools'])
35-
return s | r
37+
return subprocess.call([sys.executable, '-m', 'pip', 'install'] + requirements)
3638

3739

3840
def install_packages(what):
@@ -45,7 +47,7 @@ def install_packages(what):
4547
packages['exhibitor'] = packages['zookeeper']
4648
packages = packages.get(what, [])
4749
ver = versions.get(what)
48-
if float(ver) >= 15:
50+
if 15 <= float(ver) < 17:
4951
packages += ['postgresql-{0}-citus-12.1'.format(ver)]
5052
subprocess.call(['sudo', 'apt-get', 'update', '-y'])
5153
return subprocess.call(['sudo', 'apt-get', 'install', '-y', 'postgresql-' + ver, 'expect-dev'] + packages)
@@ -142,4 +144,4 @@ def main():
142144

143145

144146
if __name__ == '__main__':
145-
sys.exit(main())
147+
sys.exit(main())

.github/workflows/run_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
import shutil
33
import subprocess
44
import sys
5-
import tempfile
65

76

87
def main():
98
what = os.environ.get('DCS', sys.argv[1] if len(sys.argv) > 1 else 'all')
9+
tmp = os.environ.get('RUNNER_TEMP')
1010

1111
if what == 'all':
1212
flake8 = subprocess.call([sys.executable, 'setup.py', 'flake8'])
1313
test = subprocess.call([sys.executable, 'setup.py', 'test'])
1414
version = '.'.join(map(str, sys.version_info[:2]))
15-
shutil.move('.coverage', os.path.join(tempfile.gettempdir(), '.coverage.' + version))
15+
print(shutil.move('.coverage', '.coverage.' + version))
16+
print(os.getcwd())
1617
return flake8 | test
1718
elif what == 'combine':
18-
tmp = tempfile.gettempdir()
1919
for name in os.listdir(tmp):
2020
if name.startswith('.coverage.'):
2121
shutil.move(os.path.join(tmp, name), name)

.github/workflows/tests.yaml

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
os: [ubuntu-latest, windows-latest, macos-latest]
21-
python-version: [3.7, 3.8, 3.9, '3.10', 3.11, 3.12]
21+
python-version: [3.7, 3.8, 3.9, '3.10', 3.11]
2222
exclude:
23+
- os: macos-latest
24+
python-version: 3.7
2325
- os: ubuntu-latest
2426
python-version: 3.7
2527
include:
@@ -37,10 +39,37 @@ jobs:
3739
run: python .github/workflows/install_deps.py
3840
- name: Run tests and flake8
3941
run: python .github/workflows/run_tests.py
42+
- name: Upload logs from unit tests
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: logs-${{ matrix.os }}-${{ matrix.python-version }}
46+
path: ${{ github.workspace }}/.coverage.*
47+
include-hidden-files: true
48+
retention-days: 1
4049

41-
post-unit:
50+
post-unit-coverage:
51+
runs-on: ${{ matrix.os }}
4252
needs: unit
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
os: [ubuntu-latest, windows-latest, macos-latest]
4357
steps:
58+
- uses: actions/checkout@v4
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: 3.11
64+
65+
- name: Install dependencies
66+
run: python .github/workflows/install_deps.py
67+
68+
- name: Download logs from unit tests
69+
uses: actions/download-artifact@v4
70+
with:
71+
pattern: logs-${{ matrix.os }}-*
72+
merge-multiple: true
4473
- name: Combine coverage
4574
run: python .github/workflows/run_tests.py combine
4675

@@ -63,24 +92,20 @@ jobs:
6392
strategy:
6493
fail-fast: false
6594
matrix:
66-
os: [ubuntu-latest]
67-
python-version: [3.7, 3.12]
95+
os: [ubuntu-22.04]
96+
python-version: [3.13]
97+
# python-version: [3.7, 3.13]
6898
dcs: [etcd, etcd3, consul, exhibitor, kubernetes, raft]
69-
exclude:
70-
- os: ubuntu-latest
71-
python-version: 3.7
72-
include:
73-
- os: ubuntu-22.04
74-
python-version: 3.7
75-
- os: macos-latest
76-
python-version: 3.8
77-
dcs: raft
78-
- os: macos-latest
79-
python-version: 3.9
80-
dcs: etcd
81-
- os: macos-latest
82-
python-version: 3.11
83-
dcs: etcd3
99+
# include:
100+
# - os: macos-latest
101+
# python-version: 3.8
102+
# dcs: raft
103+
# - os: macos-latest
104+
# python-version: 3.9
105+
# dcs: etcd
106+
# - os: macos-latest
107+
# python-version: 3.11
108+
# dcs: etcd3
84109

85110
steps:
86111
- uses: actions/checkout@v4
@@ -98,13 +123,13 @@ jobs:
98123
sudo sh -c 'wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg'
99124
sudo sh -c 'echo "deb [signed-by=/etc/apt/trusted.gpg.d/citusdata_community.gpg] https://packagecloud.io/citusdata/community/ubuntu/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/citusdata_community.list'
100125
sudo sh -c 'wget -qO - https://packagecloud.io/citusdata/community/gpgkey | gpg --dearmor > /etc/apt/trusted.gpg.d/citusdata_community.gpg'
101-
if: matrix.os == 'ubuntu'
126+
if: startsWith(matrix.os, 'ubuntu')
102127
- name: Install dependencies
103128
run: python .github/workflows/install_deps.py
104129
- name: Run behave tests
105130
run: python .github/workflows/run_tests.py
106131
- name: Upload logs if behave failed
107-
uses: actions/upload-artifact@v3
132+
uses: actions/upload-artifact@v4
108133
if: failure()
109134
with:
110135
name: behave-${{ matrix.os }}-${{ matrix.dcs }}-${{ matrix.python-version }}-logs
@@ -121,7 +146,7 @@ jobs:
121146

122147
coveralls-finish:
123148
name: Finalize coveralls.io
124-
needs: unit
149+
needs: post-unit-coverage
125150
runs-on: ubuntu-latest
126151
steps:
127152
- uses: actions/setup-python@v4
@@ -144,14 +169,14 @@ jobs:
144169
- uses: actions/checkout@v3
145170

146171
- name: Set up Python 3.11
147-
uses: actions/setup-python@v4
172+
uses: actions/setup-python@v5
148173
with:
149174
python-version: 3.11
150175

151176
- name: Install dependencies
152177
run: python -m pip install -r requirements.txt psycopg2-binary psycopg
153178

154-
- uses: jakebailey/pyright-action@v1
179+
- uses: jakebailey/pyright-action@v2
155180
with:
156181
version: 1.1.347
157182

docs/conf.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,6 @@
114114

115115
html_theme = 'sphinx_rtd_theme'
116116
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
117-
if not on_rtd: # only import and set the theme if we're building docs locally
118-
import sphinx_rtd_theme
119-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
120117

121118
# Theme options are theme-specific and customize the look and feel of a theme
122119
# further. For a list of options available for each theme, see the

patroni/ctl.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,12 @@
4141
from psycopg import Cursor
4242
from psycopg2 import cursor
4343

44-
try:
45-
from ydiff import markup_to_pager, PatchStream # pyright: ignore [reportMissingModuleSource]
44+
try: # pragma: no cover
45+
from ydiff import markup_to_pager # pyright: ignore [reportMissingModuleSource]
46+
try:
47+
from ydiff import PatchStream # pyright: ignore [reportMissingModuleSource]
48+
except ImportError:
49+
PatchStream = iter
4650
except ImportError: # pragma: no cover
4751
from cdiff import markup_to_pager, PatchStream # pyright: ignore [reportMissingModuleSource]
4852

patroni/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def _get_json_formatter(self, logformat: type_logformat, dateformat: Optional[st
351351
try:
352352
from pythonjsonlogger import jsonlogger
353353

354-
return jsonlogger.JsonFormatter(
354+
return jsonlogger.JsonFormatter( # pyright: ignore [reportPrivateImportUsage]
355355
jsonformat,
356356
dateformat,
357357
rename_fields=rename_fields,

requirements.docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sphinx>=4
1+
sphinx>=4,<8.2.0
22
sphinx_rtd_theme>1
33
sphinxcontrib-apidoc
44
sphinx-github-style<1.0.3

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ python-dateutil
1010
pysyncobj>=0.3.8
1111
cryptography>=1.4
1212
psutil>=2.0.0
13-
ydiff>=1.2.0
13+
ydiff>=1.2.0,<1.5,!=1.4.0,!=1.4.1
1414
python-json-logger>=2.0.2
15+
setuptools

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import shutil
44
import unittest
55

6-
from mock import Mock, PropertyMock, patch
6+
from unittest.mock import Mock, PropertyMock, patch
77

88
import urllib3
99

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from http.server import HTTPServer
77
from io import BytesIO as IO
8-
from mock import Mock, PropertyMock, patch
8+
from unittest.mock import Mock, PropertyMock, patch
99
from socketserver import ThreadingMixIn
1010

1111
from patroni import global_config

0 commit comments

Comments
 (0)