/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
.github/workflows/pr.yaml
218 строк
9 KB
Nikita Menkovich
fix: trying to fix reporting on timed out/cancelled/failed workflows (#6408)
04 авг 2026, 18:48
Не верифицирован
04 авг 2026, 18:48
3a311a0
Код
Авторство
О чём код?
name: PR-check on: pull_request_target: branches: - 'main' paths-ignore: - 'ydb/docs/**' - '.github/**' - '!.github/config/**' - '!.github/workflows/pr.yaml' - 'example/**' - 'doc/**' - '**.md' types: - 'opened' - 'synchronize' - 'reopened' - 'labeled' permissions: actions: read contents: read pull-requests: write issues: write concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number }} cancel-in-progress: true jobs: check-running-allowed: runs-on: [self-hosted, "self-hosted", "runner_light"] outputs: result: ${{ steps.check-ownership-membership.outputs.result }} steps: - name: checkout workflow scripts uses: actions/checkout@v7 with: submodules: false sparse-checkout: '.github' clean: true ref: ${{ github.event.pull_request.base.sha }} - name: Check if running tests is allowed id: check-ownership-membership uses: actions/github-script@v9 with: github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} script: | const checkOwnershipMembership = require('./.github/scripts/check-ownership-membership.js'); return await checkOwnershipMembership({ github, context, core }); - name: comment-if-waiting-on-ok if: steps.check-ownership-membership.outputs.result == 'false' && github.event.action == 'opened' uses: actions/github-script@v9 with: script: | github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: 'Hi! Thank you for contributing!\nThe tests on this PR will run after a maintainer adds an `ok-to-test` label to this PR manually. Thank you for your patience!' }); - name: cleanup-labels uses: actions/github-script@v9 with: script: | let labelsToRemove = ['ok-to-test', 'recheck']; const prNumber = context.payload.pull_request.number; const prLabels = new Set(context.payload.pull_request.labels.map(l => l.name)); for await (const label of labelsToRemove.filter(l => prLabels.has(l))) { core.info(`remove label=${label} for pr=${prNumber}`); try { const result = await github.rest.issues.removeLabel({ ...context.repo, issue_number: prNumber, name: label }); } catch(error) { // ignore the 404 error that arises // when the label did not exist for the // organization member if (error.status && error.status != 404) { throw error; } } } check-trigger-label: needs: - check-running-allowed uses: ./.github/workflows/check-test-launch-label.yaml create-build-and-test-target-var: needs: - check-trigger-label - check-running-allowed if: needs.check-running-allowed.outputs.result == 'true' && needs.check-trigger-label.outputs.allowed == 'true' runs-on: [self-hosted, "self-hosted", "runner_light"] outputs: matrix_include: ${{ steps.set-build-and-test-targets.outputs.matrix_include }} steps: - name: checkout PR uses: actions/checkout@v7 if: github.event.pull_request.head.sha != '' with: submodules: false sparse-checkout: '.github' clean: 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: | if [ -d ".git/rebase-merge" ] || [ -d ".git/rebase-apply" ]; then echo "Removing stale rebase state left on runner checkout" rm -rf .git/rebase-merge .git/rebase-apply fi git config user.email "robot-nbs@nebius.com" git config user.name "Robot NBS" git fetch origin ${{ github.event.pull_request.base.ref }} git rebase origin/${{ github.event.pull_request.base.ref }} - name: checkout uses: actions/checkout@v7 if: github.event.pull_request.head.sha == '' with: submodules: false clean: true sparse-checkout: '.github' - name: disable sparse checkout (workaround for actions/checkout/issues/2249) if: ${{ always() }} run: git config core.sparseCheckout false continue-on-error: true - name: Calculate pr build and test targets matrix id: set-build-and-test-targets uses: ./.github/actions/nebius_calculate_pr_matrix with: scheduling_type: ${{ vars.NEBIUS_SCHEDULING_TYPE || 'on_demand' }} build_and_test: needs: [check-running-allowed, create-build-and-test-target-var] if: needs.check-running-allowed.outputs.result == 'true' strategy: fail-fast: false matrix: ${{ fromJson(needs.create-build-and-test-target-var.outputs.matrix_include) }} name: Build and test (${{ matrix.mode }}${{ matrix.vm_name_suffix }}) uses: ./.github/workflows/build_and_test_proxy.yaml with: mode: ${{ matrix.mode }} allow_split_workload: ${{ !contains(toJSON(matrix), '"allow_split_workload"') || matrix.allow_split_workload }} build_target: ${{ matrix.build_target }} test_target: ${{ matrix.test_target }} build_preset: ${{ matrix.build_preset }} run_build: ${{ !contains(toJSON(matrix), '"run_build"') || matrix.run_build }} run_tests: ${{ !contains(toJSON(matrix), '"run_tests"') || matrix.run_tests }} target_platform: ${{ matrix.target_platform }} test_size: ${{ matrix.test_size }} test_type: ${{ matrix.test_type }} vm_name_suffix: ${{ matrix.vm_name_suffix }} number_of_retries: ${{ matrix.number_of_retries }} cache_update_build: false cache_update_tests: false sleep_after_tests: ${{ contains(github.event.pull_request.labels.*.name, 'sleep') && '7200' || '1' }} secrets: inherit finalize-build-and-test-comments: needs: [check-running-allowed, create-build-and-test-target-var, build_and_test] if: ${{ always() && needs.check-running-allowed.outputs.result == 'true' && needs.create-build-and-test-target-var.outputs.matrix_include != '' }} runs-on: [self-hosted, "self-hosted", "runner_light"] steps: - name: checkout PR uses: actions/checkout@v7 if: github.event.pull_request.head.sha != '' with: submodules: false sparse-checkout: '.github' clean: 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: | if [ -d ".git/rebase-merge" ] || [ -d ".git/rebase-apply" ]; then echo "Removing stale rebase state left on runner checkout" rm -rf .git/rebase-merge .git/rebase-apply fi git config user.email "robot-nbs@nebius.com" git config user.name "Robot NBS" git fetch origin ${{ github.event.pull_request.base.ref }} git rebase origin/${{ github.event.pull_request.base.ref }} - name: checkout uses: actions/checkout@v7 if: github.event.pull_request.head.sha == '' with: submodules: false clean: true sparse-checkout: '.github' - name: disable sparse checkout (workaround for actions/checkout/issues/2249) if: ${{ always() }} run: git config core.sparseCheckout false continue-on-error: true - name: set up dependencies run: pip install -r .github/scripts/requirements.txt continue-on-error: true - name: finalize workload comments env: GITHUB_TOKEN: ${{ github.token }} MATRIX_INCLUDE: ${{ needs.create-build-and-test-target-var.outputs.matrix_include }} run: | set -euo pipefail export PYTHONPATH="${PYTHONPATH:-}:$GITHUB_WORKSPACE/.github" platform_name=$(uname | tr '[:upper:]' '[:lower:]')-$(arch) python3 -m scripts.tests.finalize_workload_comments \ --matrix-include "$MATRIX_INCLUDE" \ --platform-name "$platform_name" \ --workload-status completed continue-on-error: true