name: Long Integration Tests

on:
  schedule:
    - cron: '30 6 * * *'  # At 06:30
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always
  UV_VERSION: 0.9.17

jobs:
  long-e2e-tests:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
        with:
          ref: ${{ github.event_name == 'schedule' && 'dev' || github.ref_name }}
          lfs: true  # Fetch LFS files automatically
      - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: '3.13'
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
      - name: Install uv and Python dependencies
        run: |
          curl -LsSf https://astral.sh/uv/$UV_VERSION/install.sh | sh
          echo "$HOME/.local/bin" >> $GITHUB_PATH
          uv --project tests lock --check
          uv --project tests sync
      - name: Build Qdrant Docker image
        uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf # v7.2.0
        with:
          context: .
          tags: qdrant/qdrant:e2e-tests
          cache-from: |
            type=gha,scope=${{ github.ref }}-e2e
            type=gha,scope=${{ github.base_ref }}-e2e
          cache-to: type=gha,mode=max,scope=${{ github.ref }}-e2e
          load: true
          build-args: |
            PROFILE=ci
            FEATURES=data-consistency-check,staging
      - name: Verify Docker image
        run: docker images | grep qdrant
      - name: Run e2e tests
        run: uv --project tests run pytest -n 4 tests/e2e_tests -v --tb=short --durations=5 -m "longrunning"
        shell: bash
        timeout-minutes: 50
      - name: Upload test logs on failure
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        if: failure()
        with:
          name: e2e-test-logs
          path: |
            tests/e2e_tests/test_*.log
            tests/e2e_tests/**/logs/
          retention-days: 7
