-
Notifications
You must be signed in to change notification settings - Fork 22
170 lines (165 loc) · 6.92 KB
/
build_and_test_on_demand_cmake.yaml
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
167
168
169
170
name: Build and test NBS on demand using cmake
on:
workflow_dispatch:
inputs:
build_preset:
type: choice
default: "relwithdebinfo"
description: "Build preset"
options:
- debug
- relwithdebinfo
- release-asan
- release-tsan
run_build:
type: boolean
default: true
description: "run build"
run_tests:
type: boolean
default: true
description: "run tests"
sleep_after_tests:
type: string
default: "0"
description: "Amount of seconds to sleep after tests"
workflow_call:
inputs:
build_preset:
type: string
default: "relwithdebinfo"
run_build:
type: boolean
default: true
run_tests:
type: boolean
default: true
sleep_after_tests:
type: string
default: "0"
description: "Amount of seconds to sleep after tests"
disk_type:
type: string
default: "network-ssd-nonreplicated"
description: "Disk type for VM"
jobs:
provide-runner:
name: Start self-hosted runner
timeout-minutes: 60
if: always()
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-runner.outputs.label }}
instance-id: ${{ steps.start-runner.outputs.instance-id }}
runner_ipv4: ${{ steps.start-runner.outputs.external-ipv4 }}
runner_local_ipv4: ${{ steps.start-runner.outputs.local-ipv4 }}
steps:
- name: checkout PR
uses: actions/checkout@v4
if: github.event.pull_request.head.sha != ''
with:
submodules: true
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ !contains(github.event.pull_request.labels.*.name, 'rebase') && 1 || 0 }}
- name: rebase PR
if: ${{ github.event.pull_request.head.sha != '' && contains(github.event.pull_request.labels.*.name, 'rebase') }}
shell: bash
run: |
git config user.email "[email protected]"
git config user.name "Rebase Robotovich"
git fetch origin ${{ github.event.pull_request.base.ref }}
git rebase origin/${{ github.event.pull_request.base.ref }}
- name: checkout
uses: actions/checkout@v4
if: github.event.pull_request.head.sha == ''
with:
submodules: true
- name: Start runner
id: start-runner
if: always()
uses: ./.github/actions/runner_create
timeout-minutes: 60
with:
repo_owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
service_account_key: ${{ secrets.NEBIUS_SA_JSON_CREDENTIALS }}
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
vm_folder: bjeuq5o166dq4ukv3eec
vm_name: ${{ github.event.pull_request.number && format('pr-{0}-{1}-{2}', github.event.pull_request.number, github.run_id, github.run_attempt) || format('run-{0}-{1}', github.run_id, github.run_attempt) }}
vm_zone: eu-north1-c
vm_cpu: 60
vm_memory: 420
vm_disk_type: ${{ inputs.disk_type || 'network-ssd-nonreplicated' }}
vm_disk_size: 1023
vm_subnet: f8uh0ml4rhb45nde9p75
vm_image: ${{ vars.IMAGE_ID_2204 }}
vm_labels: ${{ github.event.pull_request.number && format('pr={0},run={1}-{2},repo={3},owner={4}', github.event.pull_request.number, github.run_id, github.run_attempt, github.event.repository.name, github.repository_owner) || format('run={0}-{1},repo={2},owner={3}', github.run_id, github.run_attempt, github.event.repository.name, github.repository_owner) }}
vm_user_passwd: ${{ secrets.VM_USER_PASSWD }}
build-and-test:
name: Build and test NBS [id=${{ needs.provide-runner.outputs.instance-id }} local_ip=${{ needs.provide-runner.outputs.runner_local_ipv4 }} ip=${{ needs.provide-runner.outputs.runner_ipv4 }}]
uses: ./.github/workflows/build_and_test_cmake.yaml
needs:
- provide-runner
with:
runner_kind: self-hosted
runner_label: ${{ needs.provide-runner.outputs.label }}
runner_instance_id: ${{ needs.provide-runner.outputs.instance-id }}
runner_ipv4: ${{ needs.provide-runner.outputs.runner_ipv4 }}
build_preset: ${{ inputs.build_preset }}
run_build: ${{ inputs.run_build }}
run_tests: ${{ inputs.run_tests }}
sleep_after_tests: ${{ inputs.sleep_after_tests }}
secrets: inherit
sleep-if-needed:
name: Sleep ${{ needs.build-and-test.outputs.sleep_after_tests || '0' }}s if build failed
if: ${{ !cancelled() }}
needs:
- provide-runner # required to get output from the start-runner job
- build-and-test # required to wait when the main job is done
runs-on: ubuntu-latest
steps:
- name: Sleep ${{ needs.build-and-test.outputs.sleep_after_tests || '0' }}s if build failed
shell: bash
if: ${{ needs.build-and-test.outputs.sleep_after_tests && needs.build-and-test.outputs.sleep_after_tests != '0' }}
run: |
echo "sleeping ${{ needs.build-and-test.outputs.sleep_after_tests }}s"
/usr/bin/sleep ${{ needs.build-and-test.outputs.sleep_after_tests }}
release-runner:
name: Release self-hosted runner [id=${{ needs.provide-runner.outputs.instance-id }} local_ip=${{ needs.provide-runner.outputs.runner_local_ipv4 }} ip=${{ needs.provide-runner.outputs.runner_ipv4 }}]
needs:
- provide-runner # required to get output from the start-runner job
- build-and-test # required to wait when the main job is done
- sleep-if-needed # required to wait until all debug is done
runs-on: ubuntu-latest
if: always()
steps:
- name: Checkout PR
uses: actions/checkout@v4
if: github.event.pull_request.head.sha != ''
with:
submodules: true
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: ${{ !contains(github.event.pull_request.labels.*.name, 'rebase') && 1 || 0 }}
- name: rebase PR
if: ${{ github.event.pull_request.head.sha != '' && contains(github.event.pull_request.labels.*.name, 'rebase') }}
shell: bash
run: |
git config user.email "[email protected]"
git config user.name "Rebase Robotovich"
git fetch origin ${{ github.event.pull_request.base.ref }}
git rebase origin/${{ github.event.pull_request.base.ref }}
- name: checkout
uses: actions/checkout@v4
if: github.event.pull_request.head.sha == ''
with:
submodules: true
- name: Stop runner
uses: ./.github/actions/runner_remove
if: always()
timeout-minutes: 60
with:
service_account_key: ${{ secrets.NEBIUS_SA_JSON_CREDENTIALS }}
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
repo_owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
vm_id: ${{ needs.provide-runner.outputs.instance-id }}