summaryrefslogtreecommitdiffstats
path: root/.github/workflows/run_and_debug_tests.yml
blob: 4e4e54799d9d8a716f8e55d85fcc8475e529eca2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Run and debug tests

on:
  workflow_dispatch:
    inputs:
      test_targets:
        description: 'Paths to tests (e.g., "ydb/tests/olap/" or "ydb/tests/olap/, ydb/tests/functional/")'
        required: false
        type: string
        default: 'ydb/tests/olap/'
      build_preset:
        description: 'Build preset types (comma-separated: "relwithdebinfo, release-asan" or single: "relwithdebinfo")'
        required: false
        type: string
        default: 'relwithdebinfo, release-asan'
      branches:
        description: 'Branches to test (comma-separated: "main, stable-25-3" or JSON array: ["main", "stable-25-3"], empty = use branches_config_path)'
        required: false
        type: string
        default: ''
      use_branches_config:
        description: 'If true, use branches from .github/config/stable_tests_branches.json'
        required: false
        type: boolean
        default: false

jobs:
  prepare:
    runs-on: ubuntu-latest
    outputs:
      branches_json: ${{ steps.format-branches.outputs.branches_json }}
      build_preset_array: ${{ steps.format-build-preset.outputs.build_preset_array }}
    steps:
      - name: Format branches
        id: format-branches
        run: |
          if [ -z "${{ inputs.branches }}" ]; then
            # Empty - will use branches_config_path or default
            echo "branches_json=" >> $GITHUB_OUTPUT
          elif [[ "${{ inputs.branches }}" == \[* ]]; then
            # Already JSON array
            echo "branches_json=${{ inputs.branches }}" >> $GITHUB_OUTPUT
          else
            # Comma-separated format: "main, stable-25-3" -> ["main", "stable-25-3"]
            IFS=',' read -ra BRANCHES <<< "${{ inputs.branches }}"
            JSON_BRANCHES="["
            FIRST=true
            for branch in "${BRANCHES[@]}"; do
              branch=$(echo "$branch" | xargs)  # trim whitespace
              if [ -n "$branch" ]; then
                if [ "$FIRST" = true ]; then
                  FIRST=false
                else
                  JSON_BRANCHES+=", "
                fi
                JSON_BRANCHES+="\"$branch\""
              fi
            done
            JSON_BRANCHES+="]"
            echo "branches_json=$JSON_BRANCHES" >> $GITHUB_OUTPUT
            echo "Converted '${{ inputs.branches }}' to $JSON_BRANCHES"
          fi

      - name: Format build presets
        id: format-build-preset
        run: |
          BUILD_PRESET_INPUT="${{ inputs.build_preset }}"
          if [ -z "$BUILD_PRESET_INPUT" ]; then
            BUILD_PRESET_INPUT="relwithdebinfo"
          fi
          
          # Check if already JSON array
          if [[ "$BUILD_PRESET_INPUT" == \[* ]]; then
            echo "build_preset_array=$BUILD_PRESET_INPUT" >> $GITHUB_OUTPUT
          else
            # Comma-separated format: "relwithdebinfo, release-asan" -> ["relwithdebinfo", "release-asan"]
            IFS=',' read -ra PRESETS <<< "$BUILD_PRESET_INPUT"
            JSON_PRESETS="["
            FIRST=true
            for preset in "${PRESETS[@]}"; do
              preset=$(echo "$preset" | xargs)  # trim whitespace
              if [ -n "$preset" ]; then
                if [ "$FIRST" = true ]; then
                  FIRST=false
                else
                  JSON_PRESETS+=", "
                fi
                JSON_PRESETS+="\"$preset\""
              fi
            done
            JSON_PRESETS+="]"
            echo "build_preset_array=$JSON_PRESETS" >> $GITHUB_OUTPUT
            echo "Converted '$BUILD_PRESET_INPUT' to $JSON_PRESETS"
          fi

  main:
    name: Run and debug tests
    needs: prepare
    uses: ./.github/workflows/run_tests.yml
    secrets: inherit
    strategy:
      fail-fast: false
      matrix:
        build_preset: ${{ fromJson(needs.prepare.outputs.build_preset_array) }}
    with:
      test_targets: ${{ inputs.test_targets }}
      test_size: small,medium
      build_preset: ${{ matrix.build_preset }}
      branches: ${{ needs.prepare.outputs.branches_json || '' }}
      branches_config_path: ${{ inputs.use_branches_config && '.github/config/stable_tests_branches.json' || '' }}

  collect_combined_summary:
    needs: main
    if: always()
    uses: ./.github/workflows/collect_combined_summary.yml