name: Test

on: [push, pull_request]

jobs:
  fetch-deps:
    name: Download original binaries
    uses: ./.github/workflows/legobin.yml

  pytest-win:
    name: 'Python Windows'
    runs-on: windows-latest
    needs: fetch-deps

    steps:
    - uses: actions/checkout@v4

    - name: Restore cached original binaries
      id: cache-original-binaries
      uses: actions/cache/restore@v3
      with:
        enableCrossOsArchive: true
        path: legobin
        key: legobin

    - name: Install python libraries
      shell: bash
      run: |
        pip install pytest -r tools/requirements.txt

    - name: Run python unit tests (Windows)
      shell: bash
      run: |
        pytest tools/isledecomp --lego1=legobin/LEGO1.DLL

  pytest-ubuntu:
    name: 'Python Linux'
    runs-on: ubuntu-latest
    needs: fetch-deps

    steps:
    - uses: actions/checkout@v4

    - name: Restore cached original binaries
      id: cache-original-binaries
      uses: actions/cache/restore@v3
      with:
        enableCrossOsArchive: true
        path: legobin
        key: legobin

    - name: Install python libraries
      shell: bash
      run: |
        pip install pytest -r tools/requirements.txt

    - name: Run python unit tests (Ubuntu)
      shell: bash
      run: |
        pytest tools/isledecomp --lego1=legobin/LEGO1.DLL
