From: Federico Caselli Date: Tue, 17 Jan 2023 21:51:02 +0000 (+0100) Subject: ci: add sqlalchemy integration pipeline X-Git-Tag: pool-3.2.0~126^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d3da83fbb07e46337d3b8f95652cfb07a0ba01e;p=thirdparty%2Fpsycopg.git ci: add sqlalchemy integration pipeline --- diff --git a/.github/workflows/3rd-party-tests.yml b/.github/workflows/3rd-party-tests.yml new file mode 100644 index 000000000..516ea08d0 --- /dev/null +++ b/.github/workflows/3rd-party-tests.yml @@ -0,0 +1,107 @@ +name: Test on 3rd party libraries + +on: + push: + branches: + - "master" + - "sqlalchemy_pipeline" + paths-ignore: + - "docs/*" + - "tools/*" + workflow_dispatch: + +concurrency: + # Cancel older requests of the same workflow in the same branch. + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + sqlalchemy: + name: sqlalchemy-${{ matrix.sqlalchemy_label }},psycopg-${{ matrix.impl }},py-${{ matrix.python-version }} + # linux should be enough to test if everything works. + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: + - "3.11" + - "3.7" + sqlalchemy_label: + # what version of sqlalchemy to download is defined in the "include" section below, + # in the variable pip_sqlalchemy + - git_main + - release + impl: + - c + - python + include: + - sqlalchemy_label: git_main + pip_sqlalchemy: git+https://github.com/sqlalchemy/sqlalchemy.git#egg=SQLAlchemy + - sqlalchemy_label: release + # TODO: remove pre once v2 is stable + pip_sqlalchemy: --pre sqlalchemy>=2a + + env: + PSYCOPG_IMPL: ${{ matrix.impl }} + DEPS: ./psycopg pytest pytest-xdist + + services: + pg: + image: postgres:15 + env: + POSTGRES_PASSWORD: password + POSTGRES_DB: test + ports: + - 5432:5432 + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Setup PG + env: + PGPASSWORD: password + run: | + psql -AXqte "host=127.0.0.1 dbname=test user=postgres" << HERE + SELECT version(); + CREATE SCHEMA test_schema; + CREATE SCHEMA test_schema_2; + CREATE EXTENSION hstore; + HERE + + - name: Include psycopg-c to the packages to install + if: ${{ matrix.impl == 'c' }} + run: | + echo "DEPS=$DEPS ./psycopg_c" >> $GITHUB_ENV + + - name: Install pycopg packages + run: pip install $DEPS + + - name: Setup and install sqlalchemy + run: | + pip download --no-deps --no-binary :all: ${{ matrix.pip_sqlalchemy }} + mkdir sa_home + case $(file --brief --mime-type SQLAlchemy*) in + application/gzip) + tar -C sa_home -xzf SQLAlchemy* + ;; + application/zip) + unzip -d sa_home -q SQLAlchemy* + ;; + *) + echo "Unexpected format for $(file --mime-type SQLAlchemy*)" >&2 + exit 1 + ;; + esac + mv sa_home/$( ls sa_home ) sa_home/sa + cd sa_home/sa + pip install . + + - name: Run sqlalchemy tests + env: + URL: postgresql+psycopg://postgres:password@127.0.0.1/test + working-directory: sa_home/sa + run: pytest -n 2 -q --dburi $URL --backend-only --dropfirst