mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
the problem existed because _build_retain_slots() method was falsely relying on members being present in DCS, while on failover the member key for the former leader is expiring exactly at the same time.
260 lines
7.7 KiB
YAML
260 lines
7.7 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- master
|
|
- 'REL_[0-9]+_[0-9]+'
|
|
|
|
env:
|
|
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
|
SECRETS_AVAILABLE: ${{ secrets.CODACY_PROJECT_TOKEN != '' }}
|
|
|
|
jobs:
|
|
unit:
|
|
runs-on: ${{ fromJson('{"ubuntu":"ubuntu-22.04","windows":"windows-latest","macos":"macos-latest"}')[matrix.os] }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu, windows, macos]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.7
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.7
|
|
if: matrix.os != 'macos'
|
|
- name: Install dependencies
|
|
run: python .github/workflows/install_deps.py
|
|
if: matrix.os != 'macos'
|
|
- name: Run tests and flake8
|
|
run: python .github/workflows/run_tests.py
|
|
if: matrix.os != 'macos'
|
|
|
|
- name: Set up Python 3.8
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.8
|
|
- name: Install dependencies
|
|
run: python .github/workflows/install_deps.py
|
|
- name: Run tests and flake8
|
|
run: python .github/workflows/run_tests.py
|
|
|
|
- name: Set up Python 3.9
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.9
|
|
- name: Install dependencies
|
|
run: python .github/workflows/install_deps.py
|
|
- name: Run tests and flake8
|
|
run: python .github/workflows/run_tests.py
|
|
|
|
- name: Set up Python 3.10
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.10'
|
|
- name: Install dependencies
|
|
run: python .github/workflows/install_deps.py
|
|
- name: Run tests and flake8
|
|
run: python .github/workflows/run_tests.py
|
|
|
|
- name: Set up Python 3.11
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.11
|
|
- name: Install dependencies
|
|
run: python .github/workflows/install_deps.py
|
|
- name: Run tests and flake8
|
|
run: python .github/workflows/run_tests.py
|
|
|
|
- name: Set up Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.12
|
|
- name: Install dependencies
|
|
run: python .github/workflows/install_deps.py
|
|
- name: Run tests and flake8
|
|
run: python .github/workflows/run_tests.py
|
|
|
|
- name: Set up Python 3.13
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.13
|
|
if: matrix.os != 'macos'
|
|
- name: Install dependencies
|
|
run: python .github/workflows/install_deps.py
|
|
if: matrix.os != 'macos'
|
|
- name: Run tests and flake8
|
|
run: python .github/workflows/run_tests.py
|
|
if: matrix.os != 'macos'
|
|
|
|
- name: Combine coverage
|
|
run: python .github/workflows/run_tests.py combine
|
|
|
|
- name: Install coveralls
|
|
run: python -m pip install coveralls
|
|
|
|
- name: Upload Coverage
|
|
env:
|
|
COVERALLS_FLAG_NAME: unit-${{ matrix.os }}
|
|
COVERALLS_PARALLEL: 'true'
|
|
GITHUB_TOKEN: ${{ secrets.github_token }}
|
|
run: python -m coveralls --service=github
|
|
|
|
behave:
|
|
runs-on: ${{ fromJson('{"ubuntu":"ubuntu-22.04","windows":"windows-latest","macos":"macos-latest"}')[matrix.os] }}
|
|
env:
|
|
DCS: ${{ matrix.dcs }}
|
|
ETCDVERSION: 3.4.23
|
|
PGVERSION: 16.1-1 # for windows and macos
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
os: [ubuntu]
|
|
python-version: [3.7, 3.13]
|
|
dcs: [etcd, etcd3, consul, exhibitor, kubernetes, raft]
|
|
include:
|
|
- os: macos
|
|
python-version: 3.8
|
|
dcs: raft
|
|
- os: macos
|
|
python-version: 3.9
|
|
dcs: etcd
|
|
- os: macos
|
|
python-version: 3.11
|
|
dcs: etcd3
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
- uses: nolar/setup-k3d-k3s@v1
|
|
if: matrix.dcs == 'kubernetes'
|
|
- name: Add postgresql and citus apt repo
|
|
run: |
|
|
sudo apt-get update -y
|
|
sudo apt-get install -y wget ca-certificates gnupg debian-archive-keyring apt-transport-https
|
|
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
|
sudo sh -c 'wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg'
|
|
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'
|
|
sudo sh -c 'wget -qO - https://packagecloud.io/citusdata/community/gpgkey | gpg --dearmor > /etc/apt/trusted.gpg.d/citusdata_community.gpg'
|
|
if: matrix.os == 'ubuntu'
|
|
- name: Install dependencies
|
|
run: python .github/workflows/install_deps.py
|
|
- name: Run behave tests
|
|
run: python .github/workflows/run_tests.py
|
|
- name: Upload logs if behave failed
|
|
uses: actions/upload-artifact@v4
|
|
if: failure()
|
|
with:
|
|
name: behave-${{ matrix.os }}-${{ matrix.dcs }}-${{ matrix.python-version }}-logs
|
|
path: |
|
|
features/output/*_failed/*postgres-?.*
|
|
features/output/*.log
|
|
if-no-files-found: error
|
|
retention-days: 5
|
|
- name: Generate coverage xml report
|
|
run: python -m coverage xml -o cobertura.xml
|
|
- name: Upload coverage to Codacy
|
|
run: bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r cobertura.xml -l Python --partial
|
|
if: ${{ env.SECRETS_AVAILABLE == 'true' }}
|
|
|
|
coveralls-finish:
|
|
name: Finalize coveralls.io
|
|
needs: unit
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/setup-python@v5
|
|
- run: python -m pip install coveralls
|
|
- run: python -m coveralls --service=github --finish
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.github_token }}
|
|
|
|
codacy-final:
|
|
name: Finalize Codacy
|
|
needs: behave
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- run: bash <(curl -Ls https://coverage.codacy.com/get.sh) final
|
|
if: ${{ env.SECRETS_AVAILABLE == 'true' }}
|
|
|
|
pyright:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.12
|
|
|
|
- name: Install dependencies
|
|
run: python -m pip install -r requirements.txt psycopg2-binary psycopg
|
|
|
|
- uses: jakebailey/pyright-action@v2
|
|
with:
|
|
version: 1.1.391
|
|
|
|
ydiff:
|
|
name: Test compatibility with the latest version of ydiff
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.13
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.13
|
|
- name: Install dependencies
|
|
run: python .github/workflows/install_deps.py
|
|
- name: Update ydiff
|
|
run: python -m pip install -U ydiff
|
|
- name: Run tests
|
|
run: python -m pytest tests/test_ctl.py -v
|
|
|
|
docs:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.11
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.11
|
|
cache: pip
|
|
|
|
- name: Install dependencies
|
|
run: pip install tox
|
|
|
|
- name: Install package dependencies
|
|
run: |
|
|
sudo apt update \
|
|
&& sudo apt install -y \
|
|
latexmk texlive-latex-extra tex-gyre \
|
|
--no-install-recommends
|
|
|
|
- name: Generate documentation
|
|
run: tox -m docs
|
|
|
|
isort:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: 3.12
|
|
cache: pip
|
|
|
|
- name: isort
|
|
uses: isort/isort-action@master
|
|
with:
|
|
requirementsFiles: "requirements.txt requirements.dev.txt requirements.docs.txt"
|
|
sort-paths: "patroni tests features setup.py"
|