Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
BarkovBG committed Jan 16, 2024
2 parents fdf2d4d + 293cdec commit 99daa7a
Show file tree
Hide file tree
Showing 8,428 changed files with 1,191 additions and 359,582 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
14 changes: 9 additions & 5 deletions .github/actions/ncp/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ description: Install ncp and display vm IP
inputs:
instance_id:
required: false
description: "runner instance_id"
description: "runner instance-id"
sa_json:
required: true
description: ""
outputs:
runner_ipv4:
value: ${{ steps.result.outputs.runner_ipv4 }}
description: "runner ipv4"
runs:
using: composite
steps:
Expand All @@ -22,8 +26,6 @@ runs:
- name: configure ncp
shell: bash
run: |
set -x
cat <<EOF > sa.json
${{ inputs.sa_json }}
EOF
Expand All @@ -32,10 +34,12 @@ runs:
ncp config set service-account-key sa.json
ncp config set endpoint api.ai.nebius.cloud:443
- name: print ipv4 address of the vm
- id: result
name: print ipv4 address of the vm
shell: bash
run: |
export GITHUB_RUNNER_IPV4=$(ncp compute instance get ${{ inputs.instance_id }} --format json | jq -r .network_interfaces[].primary_v4_address.one_to_one_nat.address)
echo "GITHUB_RUNNER_IPV4=${GITHUB_RUNNER_IPV4}" >> $GITHUB_ENV
echo "ssh -i ~/.ssh/gh-runner github@${GITHUB_RUNNER_IPV4}"
echo "runner_ipv4=${GITHUB_RUNNER_IPV4}" >> $GITHUB_OUTPUT
echo "ssh -i ~/.ssh/gh-runner github@${GITHUB_RUNNER_IPV4}" | tee -a $GITHUB_SUMMARY
20 changes: 20 additions & 0 deletions .github/actions/sleep/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Set sleep_after_tests variable
description: Set up sleep after tests variable
inputs:
sleep_after_tests:
required: false
default: '7200'
description: default sleep_after_tests value
outputs:
sleep_after_tests:
value: ${{ steps.result.outputs.sleep_after_tests }}
description: "sleep_after_tests"
runs:
using: composite
steps:
- id: result
name: set sleep_after_tests
shell: bash
run: |
echo "sleep_after_tests=${{inputs.sleep_after_tests}}" >> $GITHUB_OUTPUT
73 changes: 73 additions & 0 deletions .github/actions/ssh_keys/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Add members ssh keys for VM
description: Add team members public ssh keys to github@ user
inputs:
org:
required: true
description: "org name"
team:
required: true
description: "team slug name"
token:
required: true
description: "GITHUB_TOKEN"

runs:
using: composite
steps:
- name: init
shell: bash
run: |
echo "LOGINS_FILE=$(mktemp)" >> $GITHUB_ENV
echo "KEYS_FILE=$(mktemp)" >> $GITHUB_ENV
- name: collect members
shell: bash
if: ${{ github.repository == 'ydb-platform/nbs'}}
run: |
echo "https://api.github.com/orgs/${org}/teams/${team}/members?per_page=100&page=1"
curl -s -L -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $token" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/${org}/teams/${team}/members?per_page=100&page=1"
curl -s -L -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $token" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/${org}/teams/${team}/members?per_page=100&page=1" | jq -r .[].login | tee -a $LOGINS_FILE
env:
org: ${{ inputs.org }}
team: ${{ inputs.team }}
token: ${{ inputs.token }}
- name: collect members
shell: bash
if: ${{ github.repository != 'ydb-platform/nbs' }}
run: |
echo "https://api.github.com/orgs/${org}/members?per_page=100&page=1"
curl -s -L -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $token" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/${org}/members?per_page=100&page=1"
curl -s -L -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $token" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/orgs/${org}/members?per_page=100&page=1" | jq -r .[].login | tee -a $LOGINS_FILE
env:
org: ${{ inputs.org }}
team: ${{ inputs.team }}
token: ${{ inputs.token }}
- name: collect members public ssh keys
shell: bash
run: |
cat $LOGINS_FILE | while read login; do
curl -s -L -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $token" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/users/${login}/keys | jq -r .[].key | while read key; do
echo $key $login;
done;
done | tee -a $KEYS_FILE
env:
token: ${{ inputs.token }}
- name: add ssh keys to user authorized_keys file
shell: bash
run: |
cat $KEYS_FILE >> /home/github/.ssh/authorized_keys
6 changes: 0 additions & 6 deletions .github/actions/test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ inputs:
cache_update:
required: false
description: "Use cache for tests"
sleep_after_tests:
required: false
default: "0"
description: "Number of seconds to sleep after ya test launch"
runs:
using: composite
steps:
Expand Down Expand Up @@ -120,8 +116,6 @@ runs:
fi
)
sleep ${{ inputs.sleep_after_tests }}
- name: postprocess junit report
shell: bash
run: |
Expand Down
29 changes: 27 additions & 2 deletions .github/workflows/build_and_test_cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ on:
type: string
default: "linux"
description: "runner label"
runner_instance_id:
type: string
default: ""
description: "runner instance id"
runner_ipv4:
type: string
default: ""
description: "runner ipv4"
run_build:
type: boolean
default: true
Expand All @@ -21,12 +29,22 @@ on:
type: boolean
default: true
description: "run tests"
sleep_after_tests:
type: string
default: "0"
description: "Amount of time to sleep after tests"
outputs:
sleep_after_tests:
description: "sleep_after_tests"
value: ${{ jobs.build-and-test.outputs.sleep_after_tests }}


jobs:
build-and-test:
name: Build and test ${{ inputs.build_preset }}
name: Build and test ${{ inputs.build_preset }} [id=${{ inputs.runner_instance_id }} ip=${{ inputs.runner_ipv4 }}]
runs-on: [ self-hosted, "${{ inputs.runner_kind }}", "${{ inputs.runner_label }}" ]
outputs:
sleep_after_tests: ${{ steps.failure.outputs.sleep_after_tests }}
timeout-minutes: 1440
steps:
- name: Checkout PR
Expand Down Expand Up @@ -60,4 +78,11 @@ jobs:

- name: Run tests
uses: ./.github/actions/test_cmake
if: inputs.run_tests
if: inputs.run_tests

- id: failure
name: set sleep_after_tests in case of failure
if: failure()
uses: ./.github/actions/sleep
with:
sleep_after_tests: ${{ inputs.sleep_after_tests != '0' && inputs.sleep_after_tests || '7200' }}
33 changes: 26 additions & 7 deletions .github/workflows/build_and_test_on_demand.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ on:
default: false
description: "Update build cache in test stage"


jobs:
provide-runner:
name: Start self-hosted runner
Expand All @@ -103,6 +104,7 @@ jobs:
- name: Start YC runner
id: start-yc-runner
uses: librarian/[email protected]
timeout-minutes: 60
with:
mode: start
yc-sa-json-credentials: ${{ secrets.NEBIUS_SA_JSON_CREDENTIALS }}
Expand All @@ -123,9 +125,11 @@ jobs:
ssh-public-key: ${{ secrets.RUNNER_PUBLIC_KEY }}

prepare-vm:
name: Prepare runner
name: Prepare runner [id=${{ needs.provide-runner.outputs.instance-id }}]
needs: provide-runner
runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
outputs:
runner_ipv4: ${{ steps.configure-ncp.outputs.runner_ipv4 }}
steps:
- name: Checkout PR
uses: actions/checkout@v3
Expand All @@ -135,47 +139,62 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
if: github.event.pull_request.head.sha == ''
- name: Configure NCP
- id: configure-ncp
name: Configure NCP
uses: ./.github/actions/ncp
with:
instance_id: ${{ needs.provide-runner.outputs.instance-id }}
sa_json: ${{ secrets.NEBIUS_GITHUB_USER_SA_JSON}}
- id: configure-authorized-keys
name: Configure authorized_keys
uses: ./.github/actions/ssh_keys
with:
org: ydb-platform
team: nbs
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
- name: Prepare VM
uses: ./.github/actions/prepare

build-and-test:
name: Build and test NBS
name: Build and test NBS [id=${{ needs.provide-runner.outputs.instance-id }} ip=${{ needs.prepare-vm.outputs.runner_ipv4 }}]
uses: ./.github/workflows/build_and_test_ya.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.prepare-vm.outputs.runner_ipv4 }}
build_target: ${{ inputs.build_target }}
test_target: ${{ inputs.test_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 }}
sleep_after_tests: ${{ inputs.sleep_after_tests }}
link_threads: 32
test_threads: 64
link_threads: 24
test_threads: 24
cache_update_build: ${{ fromJson(github.event_name == 'workflow_dispatch' && format('{0}', inputs.cache_update) || format('{0}', inputs.cache_update_build)) }}
cache_update_tests: ${{ fromJson(github.event_name == 'workflow_dispatch' && format('{0}', inputs.cache_update) || format('{0}', inputs.cache_update_tests)) }}
secrets: inherit

release-runner:
name: Release self-hosted runner
name: Release self-hosted runner ${{ needs.provide-runner.outputs.instance-id }}
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
if: always()
steps:
- name: Sleep ${{ needs.build-and-test.outputs.sleep_after_tests }}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 }}

- name: Stop YC runner
uses: librarian/[email protected]
timeout-minutes: 60
with:
mode: stop
yc-sa-json-credentials: ${{ secrets.NEBIUS_SA_JSON_CREDENTIALS }}
Expand Down
32 changes: 30 additions & 2 deletions .github/workflows/build_and_test_on_demand_cmake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ on:
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:
Expand All @@ -31,6 +35,10 @@ on:
run_tests:
type: boolean
default: true
sleep_after_tests:
type: string
default: "0"
description: "Amount of seconds to sleep after tests"

jobs:
provide-runner:
Expand All @@ -44,6 +52,7 @@ jobs:
- name: Start YC runner
id: start-yc-runner
uses: librarian/[email protected]
timeout-minutes: 60
with:
mode: start
yc-sa-json-credentials: ${{ secrets.NEBIUS_SA_JSON_CREDENTIALS }}
Expand All @@ -67,6 +76,8 @@ jobs:
name: Prepare runner
needs: provide-runner
runs-on: [ self-hosted, "${{ needs.provide-runner.outputs.label }}" ]
outputs:
runner_ipv4: ${{ steps.configure-ncp.outputs.runner_ipv4 }}
steps:
- name: Checkout PR
uses: actions/checkout@v3
Expand All @@ -76,26 +87,37 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
if: github.event.pull_request.head.sha == ''
- name: Configure NCP
- id: configure-ncp
name: Configure NCP
uses: ./.github/actions/ncp
with:
instance_id: ${{ needs.provide-runner.outputs.instance-id }}
sa_json: ${{ secrets.NEBIUS_GITHUB_USER_SA_JSON}}
- id: configure-authorized-keys
name: Configure authorized_keys
uses: ./.github/actions/ssh_keys
with:
org: ydb-platform
team: nbs
token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
- name: Prepare VM
uses: ./.github/actions/prepare

build-and-test:
name: Build and test NBS
name: Build and test NBS [id=${{ needs.provide-runner.outputs.instance-id }} ip=${{ needs.prepare-vm.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.prepare-vm.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

release-runner:
Expand All @@ -106,8 +128,14 @@ jobs:
runs-on: ubuntu-latest
if: always()
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 }}

- name: Stop YC runner
uses: librarian/[email protected]
timeout-minutes: 60
with:
mode: stop
yc-sa-json-credentials: ${{ secrets.NEBIUS_SA_JSON_CREDENTIALS }}
Expand Down
Loading

0 comments on commit 99daa7a

Please sign in to comment.