aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/build_and_test_ya_ondemand.yml
blob: 0029ec4915b9395933c46c116cb185080c9bb3f3 (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
name: Ya-Build-and-Test-On-demand

on:
  workflow_dispatch:
    inputs:
      image:
        type: string
        default: fd8earpjmhevh8h6ug5o
        description: "VM image"
      build_target:
        type: string
        default: "ydb/"
        description: "limit build and test to specific target"
      build_preset:
        type: choice
        default: "relwithdebinfo"
        description: "Build preset"
        options:
          - relwithdebinfo
          - release-asan
          - release-tsan
      test_size:
        type: choice
        default: "small,medium,large"
        description: "test size to run"
        options:
          - small
          - small,medium
          - small,medium,large
      test_type:
        type: choice
        default: "unittest,py3test,py2test,pytest"
        description: "type of tests to run"
        options:
          - unittest
          - py3test,py2test,pytest
          - unittest,py3test,py2test,pytest
      test_threads:
        type: string
        default: "28"
        description: "Test threads count"
      link_threads:
        type: string
        default: "8"
        description: "link threads count"
      run_build:
        type: boolean
        default: true
        description: "run build"
      run_tests:
        type: boolean
        default: true
        description: "run tests"
  workflow_call:
    inputs:
      image:
        type: string
        default: fd8earpjmhevh8h6ug5o
      build_target:
        type: string
        default: "ydb/"
      build_preset:
        type: string
        default: "relwithdebinfo"
      test_size:
        type: string
        default: "small,medium,large"
      test_type:
        type: string
        default: "unittest,py3test,py2test,pytest"
      run_build:
        type: boolean
        default: true
      run_tests:
        type: boolean
        default: true
      test_threads:
        type: string
        default: 28
        description: "Test threads count"
      link_threads:
        type: string
        default: 8
        description: "link threads count"

jobs:
  provide-runner:
    name: Start self-hosted YC runner
    timeout-minutes: 5
    runs-on: ubuntu-latest
    outputs:
      label: ${{ steps.start-yc-runner.outputs.label }}
      instance-id: ${{ steps.start-yc-runner.outputs.instance-id }}
    steps:
      - name: Start YC runner
        id: start-yc-runner
        uses: yc-actions/yc-github-runner@v1
        with:
          mode: start
          yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
          github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
          folder-id: ${{ secrets.YC_FOLDER }}
          image-id: ${{ inputs.image }}
          disk-size: ${{ vars.DISK_SIZE && vars.DISK_SIZE || '1023GB' }}
          disk-type: network-ssd-nonreplicated
          cores: 64
          memory: 192GB
          core-fraction: 100
          zone-id: ru-central1-b
          subnet-id: ${{ secrets.YC_SUBNET }}

  prepare-vm:
    name: Prepare runner
    needs: provide-runner
    runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
    steps:
      - name: Checkout PR
        uses: actions/checkout@v3
        if: github.event.pull_request.head.sha != ''
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - name: Checkout
        uses: actions/checkout@v3
        if: github.event.pull_request.head.sha == ''
      - name: Prepare VM
        uses: ./.github/actions/prepare_vm

  main:
    uses: ./.github/workflows/build_and_test_ya.yml
    needs:
      - provide-runner
      - prepare-vm
    with:
      runner_kind: self-hosted
      runner_label: ${{ needs.provide-runner.outputs.label }}
      build_target: ${{ inputs.build_target }}
      build_preset: ${{ inputs.build_preset }}
      run_build: ${{ inputs.run_build }}
      run_tests: ${{ inputs.run_tests }}
      test_size: ${{ inputs.test_size }}
      test_type: ${{ inputs.test_type }}
      link_threads: ${{ inputs.link_threads }}
      test_threads: ${{ inputs.test_threads }}
    secrets: inherit

  release-runner:
    name: Release self-hosted YC runner if provided on-demand
    needs:
      - provide-runner # required to get output from the start-runner job
      - main # required to wait when the main job is done
    runs-on: ubuntu-latest
    if: always()
    steps:
      - name: Stop YC runner
        uses: yc-actions/yc-github-runner@v1
        with:
          mode: stop
          yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }}
          github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
          label: ${{ needs.provide-runner.outputs.label }}
          instance-id: ${{ needs.provide-runner.outputs.instance-id }}