name: Live Daily
run-name: Live Daily

on:
  schedule:
    - cron: "23 3 * * *"
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: figshare-live-daily
  cancel-in-progress: false

jobs:
  live-public:
    name: Public API Smoke
    runs-on: ubuntu-latest
    timeout-minutes: 30

    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: Install stable toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo artifacts
        uses: Swatinem/rust-cache@v2

      - name: Run public live smoke suite
        run: cargo test --test live_public --all-features --locked -- --ignored --nocapture --test-threads=1

  live-account:
    name: Authenticated API Smoke
    runs-on: ubuntu-latest
    timeout-minutes: 30
    env:
      FIGSHARE_TOKEN: ${{ secrets.FIGSHARE_TOKEN }}

    steps:
      - name: Require FIGSHARE_TOKEN for authenticated smoke
        if: ${{ env.FIGSHARE_TOKEN == '' }}
        run: |
          echo "FIGSHARE_TOKEN is not configured for this repository."
          echo "Add the repository secret before running the authenticated smoke workflow."
          exit 1

      - name: Checkout
        if: ${{ env.FIGSHARE_TOKEN != '' }}
        uses: actions/checkout@v5

      - name: Install stable toolchain
        if: ${{ env.FIGSHARE_TOKEN != '' }}
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo artifacts
        if: ${{ env.FIGSHARE_TOKEN != '' }}
        uses: Swatinem/rust-cache@v2

      - name: Run authenticated live smoke suite
        if: ${{ env.FIGSHARE_TOKEN != '' }}
        run: cargo test --test live_account --all-features --locked -- --ignored --nocapture --test-threads=1
