name: CI
on:
  push:
  pull_request:
  schedule:
    - cron: '0 6 * * 6'
defaults:
  run:
    shell: bash
jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        include:
          - python: '^3.10'
            os: ubuntu-latest
          - python: '3.10'
            os: windows-latest
          - python: 3.9
            os: macos-latest
          - python: 3.8
            os: ubuntu-latest
          - python: 3.7
            os: windows-latest
          - python: 3.6
            os: macos-latest
          - python: 3.6
            os: ubuntu-latest
            versions: minimal
    runs-on: ${{matrix.os}}
    steps:
      - name: Download source
        uses: actions/checkout@v2
      - name: Install Python
        uses: actions/setup-python@v2
        with:
          python-version: ${{matrix.python}}
      - name: Pin to lowest versions
        if: matrix.versions == 'minimal'
        run: |
          sed -i -E 's/"(\^|>=)([0-9])/"==\2/' pyproject.toml
      - name: Setup virtualenv
        uses: syphar/restore-virtualenv@d0a933d92488e0505e012c3367e3f987a6276f5a
        with:
          requirement_files: pyproject.toml
      - name: Install packages
        run: |
          python -m pip install -U pip'>=19'; pip install -U wheel
          pip install -U --upgrade-strategy=eager . $(awk '/^$/ {p = 0}  ! /${{runner.os}}/ { if (p) {print $1} }  /dev-dependencies/ {p = 1}' pyproject.toml)
      - name: Test
        run: |
          .tools/ci.sh with_groups
      - name: Check formatting
        if: matrix.versions == null
        run: |
          git diff --exit-code
