mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 02:13:44 +03:00
Update GitHub Actions as on branch main_2_8
Drop Python version not supported on master. Drop Travis workflow on master branch too.
This commit is contained in:
parent
9dbe8c6757
commit
5d19c6ef7e
17
.github/workflows/docs.yml
vendored
17
.github/workflows/docs.yml
vendored
|
@ -2,16 +2,17 @@ name: Build documentation
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches:
|
||||
- maint_2_8
|
||||
|
||||
jobs:
|
||||
docs:
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- name: install requirements
|
||||
run: pip install --upgrade pip setuptools wheel
|
||||
- name: run tests
|
||||
run: TRAVIS_PYTHON_VERSION=3.6 ./scripts/travis_update_docs.sh
|
||||
- uses: actions/checkout@v2
|
||||
- name: Trigger docs build
|
||||
run: ./scripts/travis_update_docs.sh
|
||||
env:
|
||||
TRAVIS_BRANCH: maint_2_8
|
||||
TRAVIS_TOKEN: ${{ secrets.TRAVIS_TOKEN }}
|
||||
|
|
71
.github/workflows/tests.yml
vendored
71
.github/workflows/tests.yml
vendored
|
@ -2,36 +2,61 @@ name: Tests
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
name: Python ${{ matrix.python-version }}
|
||||
runs-on: ubuntu-18.04
|
||||
name: Unit tests run
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version:
|
||||
- 2.7
|
||||
- 3.6
|
||||
- 3.7
|
||||
- 3.8
|
||||
include:
|
||||
- python: 3.6
|
||||
postgres: 10
|
||||
- python: 3.7
|
||||
postgres: 11
|
||||
- python: 3.8
|
||||
postgres: 12
|
||||
- python: 3.9
|
||||
postgres: 13
|
||||
|
||||
# Opposite extremes of the supported Py/PG range, other architecture
|
||||
- python: 3.6
|
||||
postgres: 13
|
||||
architecture: 'x86'
|
||||
- python: 3.9
|
||||
postgres: 9.5
|
||||
architecture: 'x86'
|
||||
|
||||
env:
|
||||
PSYCOPG2_TESTDB: postgres
|
||||
PSYCOPG2_TESTDB_HOST: 127.0.0.1
|
||||
PSYCOPG2_TESTDB_USER: postgres
|
||||
PSYCOPG2_TESTDB_PASSWORD: password
|
||||
|
||||
services:
|
||||
postgresql:
|
||||
image: postgres:${{ matrix.postgres }}
|
||||
env:
|
||||
POSTGRES_PASSWORD: password
|
||||
ports:
|
||||
- 5432:5432
|
||||
# Set health checks to wait until postgres has started
|
||||
options: >-
|
||||
--health-cmd pg_isready
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: install requirements
|
||||
run: pip install --upgrade pip setuptools wheel
|
||||
- name: install local project
|
||||
run: pip install .
|
||||
- name: cleanup local egg info
|
||||
run: rm -rf psycopg2.egg-info
|
||||
- name: setup test databases
|
||||
run: sudo ./scripts/travis_prepare.sh
|
||||
- name: run tests
|
||||
run: ./scripts/travis_test.sh
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python }}
|
||||
- name: Install tox
|
||||
run: pip install tox
|
||||
- name: Run tests
|
||||
run: tox -e ${{ matrix.python }}
|
||||
timeout-minutes: 5
|
||||
|
|
34
.travis.yml
34
.travis.yml
|
@ -1,34 +0,0 @@
|
|||
# Travis CI configuration file for psycopg2
|
||||
|
||||
language: python
|
||||
|
||||
dist: bionic
|
||||
|
||||
arch:
|
||||
- amd64
|
||||
- arm64
|
||||
|
||||
python:
|
||||
- 3.6
|
||||
- 3.7
|
||||
- 3.8
|
||||
- 3.9
|
||||
|
||||
install:
|
||||
- sudo apt-get install -y bc
|
||||
- pip install -U pip setuptools wheel
|
||||
- pip install .
|
||||
- rm -rf psycopg2.egg-info
|
||||
- sudo scripts/travis_prepare.sh
|
||||
|
||||
script:
|
||||
- scripts/travis_test.sh
|
||||
|
||||
deploy:
|
||||
- provider: script
|
||||
script: bash scripts/travis_update_docs.sh
|
||||
on:
|
||||
branch: master
|
||||
|
||||
notifications:
|
||||
email: false
|
|
@ -1,156 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e -x
|
||||
|
||||
# Prepare the test databases in Travis CI.
|
||||
#
|
||||
# The script should be run with sudo.
|
||||
# The script is not idempotent: it assumes the machine in a clean state
|
||||
# and is designed for a sudo-enabled Trusty environment.
|
||||
#
|
||||
# The variables TEST_PAST, TEST_FUTURE, DONT_TEST_PRESENT can be used to test
|
||||
# against unsupported Postgres versions and skip tests with supported ones.
|
||||
#
|
||||
# The variables can be set in the travis configuration
|
||||
# (https://travis-ci.org/psycopg/psycopg2/settings)
|
||||
export TEST_PAST=${TEST_PAST:-0}
|
||||
export TEST_FUTURE=${TEST_FUTURE:-0}
|
||||
export TEST_VERBOSE=${TEST_VERBOSE:-0}
|
||||
export PSYCOPG2_TEST_FAST=${PSYCOPG2_TEST_FAST:-0}
|
||||
export TEST_PRESENT=${TEST_PRESENT:-1}
|
||||
|
||||
set_param () {
|
||||
# Set a parameter in a postgresql.conf file
|
||||
param=$1
|
||||
value=$2
|
||||
|
||||
sed -i "s/^\s*#\?\s*$param.*/$param = $value/" "$DATADIR/postgresql.conf"
|
||||
}
|
||||
|
||||
create () {
|
||||
export VERSION=$1
|
||||
export PACKAGE=${2:-$VERSION}
|
||||
|
||||
# Version as number: 9.6 -> 906; 11 -> 1100
|
||||
export VERNUM=$(echo $VERSION \
|
||||
| sed 's/\([0-9]\+\)\(\.\([0-9]\+\)\)\?/100 * \1 + 0\3/' | bc)
|
||||
|
||||
# Port number: 9.6 -> 50906
|
||||
export PORT=$(( 50000 + $VERNUM ))
|
||||
|
||||
export DATADIR="/var/lib/postgresql/$PACKAGE/psycopg"
|
||||
export PGDIR="/usr/lib/postgresql/$PACKAGE"
|
||||
export PGBIN="$PGDIR/bin"
|
||||
|
||||
# install postgres versions not available on the image
|
||||
if [[ ! -d "${PGDIR}" ]]; then
|
||||
if (( "$VERNUM" >= 904 )); then
|
||||
# A versiou supported by postgres
|
||||
if [[ ! "${apt_updated:-}" ]]; then
|
||||
apt_updated="yeah"
|
||||
sudo apt-get update -y
|
||||
fi
|
||||
sudo apt-get install -y \
|
||||
postgresql-server-dev-${VERSION} postgresql-${VERSION}
|
||||
else
|
||||
# A dinosaur
|
||||
wget -O - \
|
||||
https://upload.psycopg.org/postgresql/postgresql-${PACKAGE}-$(lsb_release -cs).tar.bz2 \
|
||||
| sudo tar xjf - -C /usr/lib/postgresql
|
||||
fi
|
||||
fi
|
||||
|
||||
sudo -u postgres "$PGBIN/initdb" -D "$DATADIR"
|
||||
|
||||
set_param port "$PORT"
|
||||
if (( "$VERNUM" >= 800 )); then
|
||||
set_param listen_addresses "'*'"
|
||||
else
|
||||
set_param tcpip_socket true
|
||||
fi
|
||||
|
||||
# for two-phase commit testing
|
||||
if (( "$VERNUM" >= 801 )); then set_param max_prepared_transactions 10; fi
|
||||
|
||||
# for replication testing
|
||||
if (( "$VERNUM" >= 900 )); then set_param max_wal_senders 5; fi
|
||||
if (( "$VERNUM" >= 904 )); then set_param max_replication_slots 5; fi
|
||||
|
||||
if (( "$VERNUM" >= 904 )); then
|
||||
set_param wal_level logical
|
||||
elif (( "$VERNUM" >= 900 )); then
|
||||
set_param wal_level hot_standby
|
||||
fi
|
||||
|
||||
if (( "$VERNUM" >= 900 )); then
|
||||
echo "host replication travis 0.0.0.0/0 trust" >> "$DATADIR/pg_hba.conf"
|
||||
fi
|
||||
|
||||
# start the server, wait for start
|
||||
sudo -u postgres "$PGBIN/pg_ctl" -w -l /dev/null -D "$DATADIR" start
|
||||
|
||||
# create the test database
|
||||
DBNAME=psycopg2_test
|
||||
CONNINFO="user=postgres host=localhost port=$PORT dbname=template1"
|
||||
|
||||
if (( "$VERNUM" >= 901 )); then
|
||||
psql -c "create user travis createdb createrole replication" "$CONNINFO"
|
||||
elif (( "$VERNUM" >= 801 )); then
|
||||
psql -c "create user travis createdb createrole" "$CONNINFO"
|
||||
else
|
||||
psql -c "create user travis createdb createuser" "$CONNINFO"
|
||||
fi
|
||||
|
||||
psql -c "create database $DBNAME with owner travis" "$CONNINFO"
|
||||
|
||||
# configure global objects on the test database
|
||||
CONNINFO="user=postgres host=localhost port=$PORT dbname=$DBNAME"
|
||||
|
||||
if (( "$VERNUM" >= 901 )); then
|
||||
psql -c "create extension hstore" "$CONNINFO"
|
||||
elif (( "$VERNUM" >= 803 )); then
|
||||
psql -f "$PGDIR/share/contrib/hstore.sql" "$CONNINFO"
|
||||
fi
|
||||
|
||||
if (( "$VERNUM" == 901 )); then
|
||||
psql -c "create extension json" "$CONNINFO"
|
||||
fi
|
||||
}
|
||||
|
||||
# Would give a permission denied error in the travis build dir
|
||||
cd /
|
||||
|
||||
if (( "$TEST_PRESENT" )); then
|
||||
if [[ ${TRAVIS_CPU_ARCH} == "arm64" ]]; then
|
||||
# Postgres versions supported by ARM64
|
||||
create 10
|
||||
else
|
||||
create 13
|
||||
create 12
|
||||
create 11
|
||||
create 10
|
||||
create 9.6
|
||||
create 9.5
|
||||
create 9.4
|
||||
fi
|
||||
fi
|
||||
# Unsupported postgres versions that we still support
|
||||
# Images built by https://github.com/psycopg/psycopg2-wheels/tree/build-dinosaurs
|
||||
if (( "$TEST_PAST" )); then
|
||||
create 7.4
|
||||
create 8.0
|
||||
create 8.1
|
||||
create 8.2
|
||||
create 8.3
|
||||
create 8.4
|
||||
create 9.0
|
||||
create 9.1
|
||||
create 9.2
|
||||
create 9.3
|
||||
fi
|
||||
|
||||
# Postgres built from master
|
||||
if (( "$TEST_FUTURE" )); then
|
||||
# create 14 14-master
|
||||
true
|
||||
fi
|
|
@ -1,87 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Run the tests in all the databases
|
||||
# The script is designed for a Trusty environment.
|
||||
#
|
||||
# The variables TEST_PAST, TEST_FUTURE, DONT_TEST_PRESENT can be used to test
|
||||
# against unsupported Postgres versions and skip tests with supported ones.
|
||||
#
|
||||
# The variables TEST_VERBOSE enables verbose test log.
|
||||
#
|
||||
# The variables can be set in the travis configuration
|
||||
# (https://travis-ci.org/psycopg/psycopg2/settings)
|
||||
|
||||
set -e -x
|
||||
|
||||
export TEST_PAST=${TEST_PAST:-0}
|
||||
export TEST_FUTURE=${TEST_FUTURE:-0}
|
||||
export TEST_VERBOSE=${TEST_VERBOSE:-0}
|
||||
export PSYCOPG2_TEST_FAST=${PSYCOPG2_TEST_FAST:-0}
|
||||
export TEST_PRESENT=${TEST_PRESENT:-1}
|
||||
|
||||
run_test () {
|
||||
VERSION=$1
|
||||
DBNAME=psycopg2_test
|
||||
if (( "$TEST_VERBOSE" )); then
|
||||
VERBOSE=--verbose
|
||||
else
|
||||
VERBOSE=
|
||||
fi
|
||||
|
||||
# Port number: 9.6 -> 50906
|
||||
port=$(echo $VERSION \
|
||||
| sed 's/\([0-9]\+\)\(\.\([0-9]\+\)\)\?/50000 + 100 * \1 + 0\3/' | bc)
|
||||
|
||||
printf "\n\nRunning tests against PostgreSQL $VERSION (port $port)\n\n"
|
||||
export PSYCOPG2_TESTDB=$DBNAME
|
||||
export PSYCOPG2_TESTDB_HOST=localhost
|
||||
export PSYCOPG2_TESTDB_PORT=$port
|
||||
export PSYCOPG2_TESTDB_USER=travis
|
||||
export PSYCOPG2_TEST_REPL_DSN=
|
||||
unset PSYCOPG2_TEST_GREEN
|
||||
python -c \
|
||||
"import tests; tests.unittest.main(defaultTest='tests.test_suite')" \
|
||||
$VERBOSE
|
||||
|
||||
printf "\n\nRunning tests against PostgreSQL $VERSION (green mode)\n\n"
|
||||
export PSYCOPG2_TEST_GREEN=1
|
||||
python -c \
|
||||
"import tests; tests.unittest.main(defaultTest='tests.test_suite')" \
|
||||
$VERBOSE
|
||||
}
|
||||
|
||||
if (( "$TEST_PRESENT" )); then
|
||||
if [[ "${TRAVIS_CPU_ARCH}" == "arm64" ]]; then
|
||||
# Postgres versions supported by ARM64
|
||||
run_test 10
|
||||
else
|
||||
# Postgres versions supported by Travis CI
|
||||
run_test 13
|
||||
run_test 12
|
||||
run_test 11
|
||||
run_test 10
|
||||
run_test 9.6
|
||||
run_test 9.5
|
||||
run_test 9.4
|
||||
fi
|
||||
fi
|
||||
# Unsupported postgres versions that we still support
|
||||
# Images built by https://github.com/psycopg/psycopg2-wheels/tree/build-dinosaurs
|
||||
if (( "$TEST_PAST" )); then
|
||||
run_test 9.3
|
||||
run_test 9.2
|
||||
run_test 9.1
|
||||
run_test 9.0
|
||||
run_test 8.4
|
||||
run_test 8.3
|
||||
run_test 8.2
|
||||
run_test 8.1
|
||||
run_test 8.0
|
||||
run_test 7.4
|
||||
fi
|
||||
|
||||
# Postgres built from master
|
||||
if (( "$TEST_FUTURE" )); then
|
||||
# create 14 14-master
|
||||
true
|
||||
fi
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
set -euo pipefail
|
||||
|
||||
# The travis token can be set at https://travis-ci.org/psycopg/psycopg2/settings
|
||||
# The travis token can be set at https://github.com/psycopg/psycopg2/settings/secrets/actions
|
||||
# and can be set on a selected branch only (which should match the DOC_BRANCH
|
||||
# in the psycopg-website Makefile, or it won't refresh a thing).
|
||||
if [ -z "${TRAVIS_TOKEN:-}" ]; then
|
||||
|
@ -13,18 +13,11 @@ if [ -z "${TRAVIS_TOKEN:-}" ]; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
# Avoid to rebuild the website for each matrix entry.
|
||||
want_python="3.6"
|
||||
if [ "${TRAVIS_PYTHON_VERSION}" != "${want_python}" ]; then
|
||||
echo "skipping docs update: only updated on Python ${want_python} build" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "triggering psycopg-website rebuild" >&2
|
||||
curl -s -X POST \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Accept: application/json" \
|
||||
-H "Travis-API-Version: 3" \
|
||||
-H "Authorization: token ${TRAVIS_TOKEN}" \
|
||||
-d '{ "request": { "branch":"master" }}' \
|
||||
https://api.travis-ci.org/repo/psycopg%2Fpsycopg-website/requests
|
||||
-d "{\"request\": {\"branch\": \"${TRAVIS_BRANCH}\"}}" \
|
||||
https://api.travis-ci.com/repo/psycopg%2Fpsycopg-website/requests
|
||||
|
|
Loading…
Reference in New Issue
Block a user