name: Skipped Flaky Tests Report

on:
  schedule:
    # Run every Monday and Thursday at 6 AM Eastern Time (EST)
    - cron: '0 11 * * 1,4'
  workflow_dispatch:
    inputs:
      branch:
        description: "Branch to run the workflow on"
        required: true
        default: "main"
        type: string


jobs:
  flaky-tests:
    name: Run Skipped Flaky Tests Report
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        with:
          ref: ${{ inputs.branch }}

      - name: Set up Python
        uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
        with:
          python-version: '3.11'

      - name: Install codeowners
        run: |
            pip install codeowners

      - name: Run flaky tests report script
        run: python scripts/report_skipped_flaky.py

      - name: Upload report artifact
        uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
        with:
          name: flaky-tests-report
          path: flaky_tests_report.json
          retention-days: 7
