name: Run Tests

on: [pull_request,workflow_dispatch]

permissions:
  contents: read

jobs:
  formatting:
    name: Check Formatting
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
      with:
        python-version: "3.13"
    - name: Install
      run: pip install ruff
    - name: Run Ruff
      run: ruff check .

  tests:
    name: Run Unit Tests
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        python-version: ["3.8", "3.13"]
        os: [ubuntu-latest, windows-latest, macos-latest, macos-15-intel]
    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
      with:
        python-version: ${{ matrix.python-version }}
    - name: Test a minimal install
      run: |
        pip install --no-cache-dir .
        python tests/test_minimal.py
    - name: Install Trimesh
      run: pip install --no-cache-dir .[easy,test]
    - name: Run Pytest
      run: |
        pytest
  docker:
    name: Run Tests In Docker
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
    - name: Run Pytest In Docker
      run: make tests

  arch:
    name: Architecture Tests (s390x + i386)
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
    - uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
    - name: Run Tests On s390x and i386
      run: make test-arch

  corpus:
    runs-on: ubuntu-latest
    name: Check Corpus Loading
    steps:
    - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
    - name: Trimesh DiskCache
      id: cache-resolvers
      uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
      with:
        path: ~/.trimesh-cache
        key: trimesh-cache
    - name: Set up Python 3.13
      uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
      with:
         python-version: "3.13"
    - name: Install Trimesh
      run: pip install .[easy,test]
    - name: Run Corpus Check
      run: python tests/corpus.py -run

