Skip to content

Commit

Permalink
Fix release workflow
Browse files Browse the repository at this point in the history
Install Kerberos deps when testing wheels and make cibuildwheel tests
run properly.
  • Loading branch information
elprans committed Oct 19, 2024
1 parent f6ec755 commit 965fb08
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 86 deletions.
42 changes: 37 additions & 5 deletions .github/workflows/install-krb5.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,42 @@
#!/bin/bash

set -Eexuo pipefail
shopt -s nullglob

if [ "$RUNNER_OS" == "Linux" ]; then
# Assume Ubuntu since this is the only Linux used in CI.
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libkrb5-dev krb5-user krb5-kdc krb5-admin-server
if [[ $OSTYPE == linux* ]]; then
if [ "$(id -u)" = "0" ]; then
SUDO=
else
SUDO=sudo
fi

if [ -e /etc/os-release ]; then
source /etc/os-release
elif [ -e /etc/centos-release ]; then
ID="centos"
VERSION_ID=$(cat /etc/centos-release | cut -f3 -d' ' | cut -f1 -d.)
else
echo "install-krb5.sh: cannot determine which Linux distro this is" >&2
exit 1
fi

if [ "${ID}" = "debian" -o "${ID}" = "ubuntu" ]; then
export DEBIAN_FRONTEND=noninteractive

$SUDO apt-get update
$SUDO apt-get install -y --no-install-recommends \
libkrb5-dev krb5-user krb5-kdc krb5-admin-server
elif [ "${ID}" = "almalinux" ]; then
$SUDO dnf install -y krb5-server krb5-workstation krb5-libs krb5-devel
elif [ "${ID}" = "centos" ]; then
$SUDO yum install -y krb5-server krb5-workstation krb5-libs krb5-devel
elif [ "${ID}" = "alpine" ]; then
$SUDO apk add krb5 krb5-server krb5-dev
else
echo "install-krb5.sh: Unsupported linux distro: ${distro}" >&2
exit 1
fi
else
echo "install-krb5.sh: unsupported OS: ${OSTYPE}" >&2
exit 1
fi
93 changes: 51 additions & 42 deletions .github/workflows/install-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,60 @@
set -Eexuo pipefail
shopt -s nullglob

PGVERSION=${PGVERSION:-12}
if [[ $OSTYPE == linux* ]]; then
PGVERSION=${PGVERSION:-12}

if [ -e /etc/os-release ]; then
source /etc/os-release
elif [ -e /etc/centos-release ]; then
ID="centos"
VERSION_ID=$(cat /etc/centos-release | cut -f3 -d' ' | cut -f1 -d.)
else
echo "install-postgres.sh: cannot determine which Linux distro this is" >&2
exit 1
fi
if [ -e /etc/os-release ]; then
source /etc/os-release
elif [ -e /etc/centos-release ]; then
ID="centos"
VERSION_ID=$(cat /etc/centos-release | cut -f3 -d' ' | cut -f1 -d.)
else
echo "install-postgres.sh: cannot determine which Linux distro this is" >&2
exit 1
fi

if [ "${ID}" = "debian" -o "${ID}" = "ubuntu" ]; then
export DEBIAN_FRONTEND=noninteractive

if [ "${ID}" = "debian" -o "${ID}" = "ubuntu" ]; then
export DEBIAN_FRONTEND=noninteractive

apt-get install -y --no-install-recommends curl gnupg ca-certificates
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
mkdir -p /etc/apt/sources.list.d/
echo "deb https://apt.postgresql.org/pub/repos/apt/ ${VERSION_CODENAME}-pgdg main" \
>> /etc/apt/sources.list.d/pgdg.list
apt-get update
apt-get install -y --no-install-recommends \
"postgresql-${PGVERSION}" \
"postgresql-contrib-${PGVERSION}"
elif [ "${ID}" = "almalinux" ]; then
yum install -y \
"postgresql-server" \
"postgresql-devel" \
"postgresql-contrib"
elif [ "${ID}" = "centos" ]; then
el="EL-${VERSION_ID%.*}-$(arch)"
baseurl="https://download.postgresql.org/pub/repos/yum/reporpms"
yum install -y "${baseurl}/${el}/pgdg-redhat-repo-latest.noarch.rpm"
if [ ${VERSION_ID%.*} -ge 8 ]; then
dnf -qy module disable postgresql
apt-get install -y --no-install-recommends curl gnupg ca-certificates
curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
mkdir -p /etc/apt/sources.list.d/
echo "deb https://apt.postgresql.org/pub/repos/apt/ ${VERSION_CODENAME}-pgdg main" \
>> /etc/apt/sources.list.d/pgdg.list
apt-get update
apt-get install -y --no-install-recommends \
"postgresql-${PGVERSION}" \
"postgresql-contrib-${PGVERSION}"
elif [ "${ID}" = "almalinux" ]; then
yum install -y \
"postgresql-server" \
"postgresql-devel" \
"postgresql-contrib"
elif [ "${ID}" = "centos" ]; then
el="EL-${VERSION_ID%.*}-$(arch)"
baseurl="https://download.postgresql.org/pub/repos/yum/reporpms"
yum install -y "${baseurl}/${el}/pgdg-redhat-repo-latest.noarch.rpm"
if [ ${VERSION_ID%.*} -ge 8 ]; then
dnf -qy module disable postgresql
fi
yum install -y \
"postgresql${PGVERSION}-server" \
"postgresql${PGVERSION}-contrib"
ln -s "/usr/pgsql-${PGVERSION}/bin/pg_config" "/usr/local/bin/pg_config"
elif [ "${ID}" = "alpine" ]; then
apk add shadow postgresql postgresql-dev postgresql-contrib
else
echo "install-postgres.sh: unsupported Linux distro: ${distro}" >&2
exit 1
fi
yum install -y \
"postgresql${PGVERSION}-server" \
"postgresql${PGVERSION}-contrib"
ln -s "/usr/pgsql-${PGVERSION}/bin/pg_config" "/usr/local/bin/pg_config"
elif [ "${ID}" = "alpine" ]; then
apk add shadow postgresql postgresql-dev postgresql-contrib

useradd -m -s /bin/bash apgtest

elif [[ $OSTYPE == darwin* ]]; then
brew install postgresql

else
echo "install-postgres.sh: Unsupported distro: ${distro}" >&2
echo "install-postgres.sh: unsupported OS: ${OSTYPE}" >&2
exit 1
fi

useradd -m -s /bin/bash apgtest
29 changes: 21 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
name: dist-version
path: dist/VERSION

build-sdist:
needs: validate-release-request
Expand All @@ -67,7 +67,7 @@ jobs:
- uses: actions/upload-artifact@v4
with:
name: dist
name: dist-sdist
path: dist/*.tar.*

build-wheels-matrix:
Expand Down Expand Up @@ -127,9 +127,19 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: dist
name: dist-wheels-${{ matrix.only }}
path: wheelhouse/*.whl

merge-artifacts:
runs-on: ubuntu-latest
needs: [build-sdist, build-wheels]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: dist
delete-merged: true

publish-docs:
needs: [build-sdist, build-wheels]
runs-on: ubuntu-latest
Expand Down Expand Up @@ -180,6 +190,12 @@ jobs:
needs: [build-sdist, build-wheels, publish-docs]
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/asyncpg
permissions:
id-token: write

steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -223,7 +239,4 @@ jobs:
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
# password: ${{ secrets.TEST_PYPI_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
attestations: true
24 changes: 12 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,28 @@ jobs:
missing_version_ok: yes
version_file: asyncpg/_version.py
version_line_pattern: |
__version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
__version__(?:\s*:\s*typing\.Final)?\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
- name: Setup PostgreSQL
if: steps.release.outputs.version == 0 && matrix.os == 'macos-latest'
if: "!steps.release.outputs.is_release && matrix.os == 'macos-latest'"
run: |
brew install postgresql
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
if: steps.release.outputs.version == 0
if: "!steps.release.outputs.is_release"
with:
python-version: ${{ matrix.python-version }}

- name: Install Python Deps
if: steps.release.outputs.version == 0
if: "!steps.release.outputs.is_release"
run: |
.github/workflows/install-krb5.sh
[ "$RUNNER_OS" = "Linux" ] && .github/workflows/install-krb5.sh
python -m pip install -U pip setuptools wheel
python -m pip install -e .[test]
- name: Test
if: steps.release.outputs.version == 0
if: "!steps.release.outputs.is_release"
env:
LOOP_IMPL: ${{ matrix.loop }}
run: |
Expand Down Expand Up @@ -103,10 +103,10 @@ jobs:
missing_version_ok: yes
version_file: asyncpg/_version.py
version_line_pattern: |
__version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
__version__(?:\s*:\s*typing\.Final)?\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
- name: Set up PostgreSQL
if: steps.release.outputs.version == 0
if: "!steps.release.outputs.is_release"
env:
PGVERSION: ${{ matrix.postgres-version }}
DISTRO_NAME: focal
Expand All @@ -118,19 +118,19 @@ jobs:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
if: steps.release.outputs.version == 0
if: "!steps.release.outputs.is_release"
with:
python-version: "3.x"

- name: Install Python Deps
if: steps.release.outputs.version == 0
if: "!steps.release.outputs.is_release"
run: |
.github/workflows/install-krb5.sh
[ "$RUNNER_OS" = "Linux" ] && .github/workflows/install-krb5.sh
python -m pip install -U pip setuptools wheel
python -m pip install -e .[test]
- name: Test
if: steps.release.outputs.version == 0
if: "!steps.release.outputs.is_release"
env:
PGVERSION: ${{ matrix.postgres-version }}
run: |
Expand Down
15 changes: 6 additions & 9 deletions asyncpg/_testbase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,6 @@ def _init_cluster(ClusterCls, cluster_kwargs, initdb_options=None):
return cluster


def _start_cluster(ClusterCls, cluster_kwargs, server_settings,
initdb_options=None):
cluster = _init_cluster(ClusterCls, cluster_kwargs, initdb_options)
cluster.start(port='dynamic', server_settings=server_settings)
return cluster


def _get_initdb_options(initdb_options=None):
if not initdb_options:
initdb_options = {}
Expand All @@ -256,8 +249,12 @@ def _init_default_cluster(initdb_options=None):
_default_cluster = pg_cluster.RunningCluster()
else:
_default_cluster = _init_cluster(
pg_cluster.TempCluster, cluster_kwargs={},
initdb_options=_get_initdb_options(initdb_options))
pg_cluster.TempCluster,
cluster_kwargs={
"data_dir_suffix": ".apgtest",
},
initdb_options=_get_initdb_options(initdb_options),
)

return _default_cluster

Expand Down
Loading

0 comments on commit 965fb08

Please sign in to comment.