name: Test examples

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

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

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest]
        python: ["3.10"]

    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Set up Python ${{ matrix.python }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python }}

      - name: Install pip dependencies
        run: |
          python -m pip install --upgrade pip
          pip install tox
      - name: Test examples
        env:
          MPLBACKEND: agg
          PLATFORM: ${{ matrix.os }}
          DISPLAY: :42
        run: |
          tox -e examples-docs
