name: debian

on:
  pull_request:
  push:
    branches:
      - 'main'
      - 'force_ci/all/**'     # For development, forcing all workflows to run.
      - 'force_ci/debian/**'  # For debugging and/or only forcing this workflow.

jobs:
  debian-build:
    name: ${{ matrix.dist }}
    runs-on: ubuntu-latest
    container: debian:${{ matrix.dist }}-slim
    strategy:
      fail-fast: false
      matrix:
        dist: [bullseye, bookworm]
    steps:
      - uses: actions/checkout@v2

      - name: Install build-dependencies
        # TODO(dato): find out why setup.py links to compression libraries
        # by hand (and hence their development packages needed here).
        run: |
          apt-get update
          apt-get install --no-install-recommends -y \
              build-essential librocksdb-dev cython3 python3-pkgconfig \
              python3-dev python3-pip python3-pytest \
              libsnappy-dev libbz2-dev liblz4-dev libz-dev

      - name: Build pyrocksdb
        # TODO(dato): consider using pypa/build --no-isolaiton, to
        # build the package using a tool specifically designed for
        # that, rather than trusting it to a tool that does a lot
        # more (pip).
        run: |
          python3 -m pip install --no-build-isolation -v '.[test]'

      - name: Run tests
        run: |
          pytest-3 --pyargs rocksdb
