summaryrefslogtreecommitdiffstats
path: root/.github/workflows/run_tests.yml
blob: ad52813d5d429a8ea6751adbdbcf20e5617ab704 (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: Run-tests

on:
  workflow_call:
    inputs:
      test_targets:
        description: 'Paths to tests for run ,example : ydb/ ydb/tests/func/suite'
        required: true
        type: string
        default: ydb/
      test_type:
        description: 'Test type (unittest,py3test,py2test,pytest)'
        required: false
        type: string
        default: unittest,py3test,py2test,pytest
      test_size:
        description: 'Test size (small,medium,large)'
        required: false
        type: string
        default: small,medium,large
      additional_ya_make_args:
        description: 'additional args for ya make'
        required: false
        type: string
        default: ''
      build_preset:
        description: 'Build preset type'
        required: true
        type: string
      branches:
        description: 'Branches to test (JSON array or single branch)'
        required: false
        type: string
        default: '["main"]'

  workflow_dispatch:
    inputs:
      test_targets:
        description: 'Paths to tests for run ,example : ydb/ ydb/tests/func/suite'
        required: true
        default: ydb/
      test_type:
        description: 'Test type (unittest,py3test,py2test,pytest)'
        required: false
        default: unittest,py3test,py2test,pytest
      test_size:
        description: 'Test size (small,medium,large)'
        required: false
        type: choice
        default: small,medium,large
        options:
          - small
          - medium,
          - large
          - small,medium
          - small,medium,large
      additional_ya_make_args:
        description: 'additional args for ya make'
        required: false
        default: ''
      build_preset:
        description: 'Build preset type (relwithdebinfo, release-asan, release-msan, release-tsan)'
        required: true
        type: choice
        options:
          - relwithdebinfo
          - release-asan
          - release-msan
          - release-tsan
        default: relwithdebinfo

jobs:
  prepare:
    runs-on: ubuntu-latest
    outputs:
      branch_array: ${{ steps.set-branches.outputs.branch_array }}
    steps:
      - name: Set branches
        id: set-branches
        env:
          CALLED_BRANCHES: '${{ inputs.branches }}'
        run: |
          # Проверяем, был ли передан параметр branches из вызывающего workflow
          if [[ -n "$CALLED_BRANCHES" ]]; then
            echo "Branches parameter provided from calling workflow: $CALLED_BRANCHES"
            
            # Проверяем, является ли вход уже JSON-массивом
            if [[ $CALLED_BRANCHES == \[* ]]; then
              echo "branch_array=$CALLED_BRANCHES" >> $GITHUB_OUTPUT
            else
              # Если это одна ветка, создаем JSON-массив с одним элементом
              echo "branch_array=[\"$CALLED_BRANCHES\"]" >> $GITHUB_OUTPUT
            fi
          else
            # Если ветки не переданы, значит это прямой запуск workflow_dispatch
            echo "No branches specified, using current branch: ${{ github.ref_name }}"
            echo "branch_array=[\"${{ github.ref_name }}\"]" >> $GITHUB_OUTPUT
          fi
          
          echo "Final branches to use: $(cat $GITHUB_OUTPUT | grep branch_array | cut -d= -f2)"

  run_tests:
    needs: prepare
    name: ${{ matrix.branch }}:${{ inputs.build_preset }}
    timeout-minutes: 1200
    runs-on: [ self-hosted, auto-provisioned, "${{ format('build-preset-{0}', inputs.build_preset) }}" ]
    strategy:
      fail-fast: false
      matrix:
        branch: ${{ fromJson(needs.prepare.outputs.branch_array) }}
    steps:
      - name: Set variables based on build_preset
        id: set-vars
        run: |
          if [[ "${{ inputs.build_preset }}" == "relwithdebinfo" ]]; then
            echo "threads_count=52" >> $GITHUB_ENV
            echo "timeout=1200" >> $GITHUB_ENV
          elif [[ "${{ inputs.build_preset }}" == "release-asan" ]]; then
            echo "threads_count=20" >> $GITHUB_ENV
            echo "timeout=1200" >> $GITHUB_ENV
          elif [[ "${{ inputs.build_preset }}" == "release-msan" ]]; then
            echo "threads_count=5" >> $GITHUB_ENV
            echo "timeout=1200" >> $GITHUB_ENV
          elif [[ "${{ inputs.build_preset }}" == "release-tsan" ]]; then
            echo "threads_count=10" >> $GITHUB_ENV
            echo "timeout=1200" >> $GITHUB_ENV
          else
            echo "Unknown build_preset value."
            exit 1
          fi

      - name: Checkout ${{ matrix.branch }}
        uses: actions/checkout@v4
        with:
          ref: ${{ matrix.branch }}

      - name: Setup ssh key for slice 
        uses: webfactory/[email protected]
        with:
          ssh-private-key: ${{ secrets.SLICE_QA_SSH_PRIVATE_KEY }}

      - name: Setup ydb access
        uses: ./.github/actions/setup_ci_ydb_service_account_key_file_credentials
        with:
          ci_ydb_service_account_key_file_credentials: ${{ secrets.CI_YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS }}

      - name: Run YDB Tests
        timeout-minutes: ${{ fromJson(env.timeout) }}
        uses: ./.github/actions/build_and_test_ya
        with:
          build_preset: ${{ inputs.build_preset }}
          increment: false
          build_target: ${{ inputs.test_targets }}
          run_build: true
          run_tests: true
          test_retry_count: 3
          test_size: ${{ inputs.test_size }}
          test_type: ${{ inputs.test_type }}
          test_threads: ${{ fromJson(env.threads_count) }}
          custom_branch_name: ${{ matrix.branch }}
          put_build_results_to_cache: true
          additional_ya_make_args: -DDEBUGINFO_LINES_ONLY ${{ inputs.additional_ya_make_args }}
          secs: ${{ format('{{"TESTMO_TOKEN2":"{0}","AWS_KEY_ID":"{1}","AWS_KEY_VALUE":"{2}","REMOTE_CACHE_USERNAME":"{3}","REMOTE_CACHE_PASSWORD":"{4}"}}',
            secrets.TESTMO_TOKEN2, secrets.AWS_KEY_ID, secrets.AWS_KEY_VALUE, secrets.REMOTE_CACHE_USERNAME, secrets.REMOTE_CACHE_PASSWORD ) }}
          vars: ${{ format('{{"AWS_BUCKET":"{0}","AWS_ENDPOINT":"{1}","REMOTE_CACHE_URL":"{2}","TESTMO_URL":"{3}","TESTMO_PROJECT_ID":"{4}"}}',
            vars.AWS_BUCKET, vars.AWS_ENDPOINT, vars.REMOTE_CACHE_URL_YA, vars.TESTMO_URL, vars.TESTMO_PROJECT_ID ) }}