Skip to content

Build and test NBS on demand using cmake #10

Build and test NBS on demand using cmake

Build and test NBS on demand using cmake #10

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"
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 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:
org: ydb-platform
team: NBS
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}', github.event.pull_request.number) || format('run-{0}-{1}', github.run_id, github.run_attempt) }}
vm_zone: eu-north1-c
vm_cpu: 60
vm_memory: 240
vm_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}', github.event.pull_request.number, github.run_id, github.run_attempt) || format('run={0}-{1}', github.run_id, github.run_attempt) }}
vm_user_passwd: ${{ secrets.VM_USER_PASSWD }}
prepare-vm:
name: Prepare 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
runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
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 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: Prepare VM
uses: ./.github/actions/prepare
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
- prepare-vm
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: 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 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 }}