name: Tests cloud

permissions: write-all

on:
  push:
    branches:
      - main
  workflow_dispatch:
  pull_request:
    types: [opened, labeled, synchronize, reopened]

jobs:
  test:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'tests:run-cloud'))
    runs-on: [self-hosted, style-checker-aarch64]
    defaults:
      run:
        shell: bash
    strategy:
      matrix:
        go:
          - "1.24"
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Go ${{ matrix.go }}
        uses: actions/setup-go@v5
        with:
          go-version: ${{ matrix.go }}

      - name: Tests
        env:
          CLICKHOUSE_USE_DOCKER: false
          CLICKHOUSE_USE_SSL: true
          CLICKHOUSE_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
          CLICKHOUSE_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }}
          CLICKHOUSE_JWT: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_JWT_DESERT_VM_43 }}
          TESTCONTAINERS_RYUK_DISABLED: "true"
        run: |
          CLICKHOUSE_DIAL_TIMEOUT=20 CLICKHOUSE_TEST_TIMEOUT=600s CLICKHOUSE_QUORUM_INSERT=2 make test
