name: Pytorch Unit Tests (with GPU) 

on:
  push:
    branches:
      - 'main'
      - 'mq-working-branch**'
    paths:
      - 'ddtrace/profiling/collector/pytorch.py'
  pull_request:
    paths:
      - 'ddtrace/profiling/collector/pytorch.py'
  workflow_dispatch: 

jobs:
   unit-tests:
    runs-on: APM-4-CORE-GPU-LINUX
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        # Include all history and tags
        with:
          persist-credentials: false
          fetch-depth: 0

      - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
        name: Install Python
        with:
          python-version: '3.12'

      - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
      - name: Install latest stable toolchain and rustfmt
        run: rustup update stable && rustup default stable && rustup component add rustfmt clippy

      - name: Install hatch
        uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc # install
        with:
          version: "1.12.0"
      
      - name: Install PyTorch
        run: pip install torch

      - name: Run tests
        run: hatch run profiling_pytorch:test 
