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 18, 2024
1 parent f6ec755 commit de59e30
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 57 deletions.
41 changes: 36 additions & 5 deletions .github/workflows/install-krb5.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
#!/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
fi
94 changes: 51 additions & 43 deletions .github/workflows/install-postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,59 @@
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
exit 1
echo "install-postgres.sh: unsupported OS: ${OSTYPE}" >&2
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
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,17 @@ build-frontend = "build"
test-extras = "test"

[tool.cibuildwheel.macos]
before-all = ".github/workflows/install-postgres.sh"
test-command = "python {project}/tests/__init__.py"

[tool.cibuildwheel.windows]
test-command = "python {project}\\tests\\__init__.py"

[tool.cibuildwheel.linux]
before-all = ".github/workflows/install-postgres.sh"
before-all = """
.github/workflows/install-postgres.sh \
&& .github/workflows/install-krb5.sh \
"""
test-command = """\
PY=`which python` \
&& chmod -R go+rX "$(dirname $(dirname $(dirname $PY)))" \
Expand Down

0 comments on commit de59e30

Please sign in to comment.