name: Pytest, build docker image, push to GHCR

on: [pull_request, push]

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref }}
  cancel-in-progress: true

env:
  # https://github.com/pytest-dev/pytest/issues/2042#issuecomment-429289164
  PY_IGNORE_IMPORTMISMATCH: 1

jobs:
  pytest:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
        # TODO: pixi has multi env support
    name: ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    defaults:
      run:
        shell: bash -l {0}
    steps:
      - name: Checkout
        uses: actions/checkout@v5
      - name: Setup pixi
        uses: prefix-dev/setup-pixi@v0.9.1
        with:
          pixi-version: v0.48.2
          cache: false
      - name: Install environment
        run: |
          pixi install
          pixi install -e test

      - name: Test
        run: |
          pixi run -e test pytest --record-mode none
