]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
ci: run CRDB tests in CI
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 28 Aug 2022 16:56:08 +0000 (17:56 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 29 Aug 2022 08:19:57 +0000 (09:19 +0100)
.github/workflows/tests.yml

index 9dc03fdb779541956d1d612bf17d7f7265323323..fa5ec0794e63b43c616e860fbdc037c78ba7f37c 100644 (file)
@@ -239,3 +239,64 @@ jobs:
 
 
   # }}}
+
+  crdb:  # {{{
+    runs-on: ubuntu-latest
+
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - {crdb: "latest-v22.1", python: "3.10", impl: "c", libpq: "newest"}
+          - {crdb: "latest-v21.2", python: "3.9", impl: "python", libpq: ""}
+
+    env:
+      PSYCOPG_IMPL: ${{ matrix.impl }}
+      PSYCOPG_TEST_DSN: "host=127.0.0.1 port=26257 user=root dbname=defaultdb"
+      PYTEST_ADDOPTS: --color yes
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - uses: actions/setup-python@v2
+        with:
+          python-version: ${{ matrix.python }}
+
+      - name: Run CockroachDB
+        # Note: this would love to be a service, but I don't see a way to pass
+        # the args to the docker run command line.
+        run: |
+          docker pull cockroachdb/cockroach:${{ matrix.crdb }}
+          docker run --rm -d --name crdb -p 26257:26257 \
+            cockroachdb/cockroach:${{ matrix.crdb }} start-single-node --insecure
+
+      - name: Install the newest libpq version available
+        if: ${{ matrix.libpq == 'newest' }}
+        run: |
+          set -x
+          rel=$(lsb_release -c -s)
+          echo "deb http://apt.postgresql.org/pub/repos/apt ${rel}-pgdg main" \
+            | sudo tee -a /etc/apt/sources.list.d/pgdg.list
+          sudo apt-get -qq update
+          pqver=$(apt-cache show libpq5 | grep ^Version: | head -1 \
+            | awk '{print $2}')
+          sudo apt-get -qq -y install "libpq-dev=${pqver}" "libpq5=${pqver}"
+
+      - name: Install tox
+        run: pip install tox
+
+      - name: Run tests (Python implementation)
+        if: ${{ matrix.impl == 'python' }}
+        run: tox -c psycopg -e ${{ matrix.python }}
+
+      - name: Run tests (C implementation)
+        if: ${{ matrix.impl == 'c' }}
+        # skip tests failing on importing psycopg_c.pq on subprocess
+        # they only fail on Travis, work ok locally under tox too.
+        run: tox -c psycopg_c -e ${{ matrix.python }} -- -m 'not subprocess'
+
+      - name: Stop CockroachDB
+        run: docker kill crdb
+
+
+  # }}}