name: unstable

on:
  push:
    branches:
      - main
    tags:
      - ciflow/unstable/*
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
  cancel-in-progress: true

permissions: read-all

jobs:
  # There must be at least one job here to satisfy GitHub action workflow syntax
  introduction:
    if: github.repository_owner == 'pytorch'
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - name: Introduce PyTorch unstable workflow
        run: |
          echo "PyTorch unstable workflow is used to host experimental or flaky jobs"
          echo " that needs to be run for every commit, but doesn't block PR merging"
          echo " as part of the stable pull or trunk workflows."
          echo
          echo "In addition, a new label called ciflow/unstable can be attached to the"
          echo " PR to trigger this workflow. That can be done either manually or"
          echo " automatically using PyTorch auto-label bot."
          echo
          echo "Once the jobs are deemed stable enough (% red signal < 5% and TTS < 3h),"
          echo " they can graduate and move back to pull or trunk."

  target-determination:
    if: github.repository_owner == 'pytorch'
    name: before-test
    uses: ./.github/workflows/target_determination.yml
    permissions:
      id-token: write
      contents: read

  get-label-type:
    name: get-label-type
    uses: pytorch/pytorch/.github/workflows/_runner-determinator.yml@release/2.8
    if: ${{ (github.event_name != 'schedule' || github.repository == 'pytorch/pytorch') && github.repository_owner == 'pytorch' }}
    with:
      triggering_actor: ${{ github.triggering_actor }}
      issue_owner: ${{ github.event.pull_request.user.login || github.event.issue.user.login }}
      curr_branch: ${{ github.head_ref || github.ref_name }}
      curr_ref_type: ${{ github.ref_type }}
