Skip to content

Commit

Permalink
Add a workaround for gh actions dropping python 2.7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
secwall committed Jun 21, 2023
1 parent 5170bcb commit 382edfe
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,39 @@ on:
jobs:
test:
name: Run tests and linters
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
env:
LANG: en_US.utf8
DEBIAN_FRONTEND: noninteractive
PG_MAJOR: 15
container:
image: ubuntu:jammy
steps:
- uses: actions/checkout@v3
- name: Set up Python 2.7
uses: actions/setup-python@v4
with:
python-version: 2.7
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install tox
- name: Set postgresql uid/gid
run: |
python3.11 -m pip install --upgrade pip
python3.11 -m pip install tox
groupadd -r postgres --gid=999
useradd -r -d /var/lib/postgresql -g postgres --uid=999 postgres
- name: Set locale to utf-8
run: |
apt-get update
apt-get install -y ca-certificates locales
rm -rf /var/lib/apt/lists/*
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
- name: Install PostgreSQL ${PG_MAJOR} and Python
run: |
echo 'deb http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
echo 'deb https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu/ jammy main' > /etc/apt/sources.list.d/deadsnakes-ubuntu-ppa.list
apt-get -o Acquire::AllowInsecureRepositories=true -o Acquire::AllowDowngradeToInsecureRepositories=true update
apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -o APT::Get::AllowUnauthenticated=true install -y postgresql-common sudo libpq-dev python2.7-dev python3.11-dev python3.11-lib2to3 build-essential curl postgresql-$PG_MAJOR postgresql-contrib-$PG_MAJOR
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.11 get-pip.py
pip3.11 install tox
- name: Start PostgreSQL
run: sudo service postgresql start
- name: Create PostgreSQL test env
run: |
sudo -u postgres psql -c "CREATE USER ${USER} WITH SUPERUSER ENCRYPTED PASSWORD 'dummy'"
echo "*:*:*:${USER}:dummy" > ~/.pgpass
chmod 0600 ~/.pgpass
chown -R postgres:postgres .
mkdir -p /var/log/postgresql
chown postgres:postgres /var/log/postgresql
sudo -u postgres /usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl -D /etc/postgresql/${PG_MAJOR}/main -l /var/log/postgresql/postgresql-${PG_MAJOR}-main.log start
- name: Run tox
run: tox
run: sudo -u postgres tox

0 comments on commit 382edfe

Please sign in to comment.