diff options
author | Kirill Rysin <35688753+naspirato@users.noreply.github.com> | 2025-04-01 16:27:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-01 14:27:54 +0000 |
commit | ba82742c9da36e65c0829204c050e957bb6bceae (patch) | |
tree | 6df09730a5a6415b0f1c13dd230ff77ab89957ff | |
parent | 04d730d6697355ffff8e0afbef96a5d115cfdee2 (diff) | |
download | ydb-ba82742c9da36e65c0829204c050e957bb6bceae.tar.gz |
Fix workflow update muted_ya.txt (#16605)
-rwxr-xr-x | .github/scripts/tests/update_mute_issues.py | 15 | ||||
-rw-r--r-- | .github/workflows/collect_analytics.yml | 8 | ||||
-rw-r--r-- | .github/workflows/create_issues_for_muted_tests.yml | 23 | ||||
-rw-r--r-- | .github/workflows/update_muted_ya.yml | 31 |
4 files changed, 59 insertions, 18 deletions
diff --git a/.github/scripts/tests/update_mute_issues.py b/.github/scripts/tests/update_mute_issues.py index 7ae751272e..8387f40a0f 100755 --- a/.github/scripts/tests/update_mute_issues.py +++ b/.github/scripts/tests/update_mute_issues.py @@ -19,6 +19,20 @@ CURRENT_TEST_HISTORY_DASHBOARD = "https://datalens.yandex/34xnbsom67hcq?" # admin:org # project + +def handle_github_errors(response): + if 'errors' in response: + for error in response['errors']: + if error['type'] == 'INSUFFICIENT_SCOPES': + print("Error: Insufficient Scopes") + print("Message:", error['message']) + raise Exception("Insufficient scopes. Please update your token's scopes.") + # Handle other types of errors if necessary + else: + print("Unknown error type:", error.get('type', 'No type')) + print("Message:", error.get('message', 'No message available')) + raise Exception("GraphQL Error: " + error.get('message', 'Unknown error')) + def run_query(query, variables=None): GITHUB_TOKEN = os.environ["GITHUB_TOKEN"] HEADERS = {"Authorization": f"Bearer {GITHUB_TOKEN}", "Content-Type": "application/json"} @@ -26,6 +40,7 @@ def run_query(query, variables=None): 'https://api.github.com/graphql', json={'query': query, 'variables': variables}, headers=HEADERS ) if request.status_code == 200: + handle_github_errors(request.json()) return request.json() else: raise Exception(f"Query failed to run by returning code of {request.status_code}. {query}") diff --git a/.github/workflows/collect_analytics.yml b/.github/workflows/collect_analytics.yml index 3e92d0feb6..06a40ecba0 100644 --- a/.github/workflows/collect_analytics.yml +++ b/.github/workflows/collect_analytics.yml @@ -1,7 +1,7 @@ name: Collect-analytics-run on: schedule: - - cron: "0 * * * *" # Every 1 h + - cron: "0 1-23/2 * * *" #каждые 2 часа в 0 минут, начиная с 1:00 и заканчивая 23:00. workflow_dispatch: inputs: commit_sha: @@ -43,11 +43,7 @@ jobs: - name: Collect test history data with window 10 run release-asan for main continue-on-error: true run: python3 .github/scripts/analytics/flaky_tests_history_n_runs.py --runs=10 --build_type=release-asan - - name: Collect test history data with window 50 run relwithdebinfo for main - continue-on-error: true - run: python3 .github/scripts/analytics/flaky_tests_history_n_runs.py --runs=50 - - name: Collect test history data with window 50 run release-asan for main - run: python3 .github/scripts/analytics/flaky_tests_history_n_runs.py --runs=50 --build_type=release-asan + diff --git a/.github/workflows/create_issues_for_muted_tests.yml b/.github/workflows/create_issues_for_muted_tests.yml index a1e7f9271b..c9aeef7e87 100644 --- a/.github/workflows/create_issues_for_muted_tests.yml +++ b/.github/workflows/create_issues_for_muted_tests.yml @@ -55,4 +55,25 @@ jobs: env: GITHUB_TOKEN: ${{ env.GH_TOKEN }} run: | - python .github/scripts/create_or_update_pr.py append_pr_body --pr_number=${{ github.event.pull_request.number || github.event.inputs.pr_number }} --body=issues_info.txt
\ No newline at end of file + python .github/scripts/create_or_update_pr.py append_pr_body --pr_number=${{ github.event.pull_request.number || github.event.inputs.pr_number }} --body=${{env.GITHUB_WORKSPACE}}/issues_info.txt + + - name: Comment PR + uses: actions/github-script@v7 + + with: + github-token: ${{ env.GH_TOKEN }} + script: | + const fs = require('fs'); + const path = require('path'); + + const workflowUrl = `https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}`; + const filePath = path.join(process.env.GITHUB_WORKSPACE, 'issues_info.txt'); + const bodyText = fs.readFileSync(filePath, 'utf8'); + const completeBody = `Collected in workflow [#${{ github.run_number }}](${workflowUrl})\n\n${bodyText}`; + + github.rest.issues.createComment({ + issue_number: ${{ github.event.pull_request.number || github.event.inputs.pr_number }}, + owner: context.repo.owner, + repo: context.repo.repo, + body: completeBody + }); diff --git a/.github/workflows/update_muted_ya.yml b/.github/workflows/update_muted_ya.yml index 32d8e95051..99f40222b6 100644 --- a/.github/workflows/update_muted_ya.yml +++ b/.github/workflows/update_muted_ya.yml @@ -25,14 +25,23 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install ydb[yc] PyGithub + pip install ydb[yc] PyGithub codeowners pandas - name: Setup ydb access uses: ./.github/actions/setup_ci_ydb_service_account_key_file_credentials with: ci_ydb_service_account_key_file_credentials: ${{ secrets.CI_YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS }} + + - name: Collect test history data with window 1 days relwithdebinfo for ${{ env.BASE_BRANCH }} + run: python3 .github/scripts/analytics/flaky_tests_history.py --days-window=1 --branch=${{ env.BASE_BRANCH }} + + - name: Update muted and not muted tests in DB for ${{ env.BASE_BRANCH }} + run: python3 .github/scripts/tests/get_muted_tests.py upload_muted_tests --branch=${{ env.BASE_BRANCH }} + + - name: Update test monitor (how long tests in state) for ${{ env.BASE_BRANCH }} + run: python3 .github/scripts/analytics/tests_monitor.py --branch=${{ env.BASE_BRANCH }} - - name: Update branch with base branch + - name: Update branch ${{ env.BRANCH_FOR_PR }}_${{ env.BASE_BRANCH }} with branch ${{ env.BASE_BRANCH }} run: | git config user.name YDBot git config user.email ydbot@ydb.tech @@ -51,18 +60,18 @@ jobs: # Attempt to rebase BRANCH_FOR_PR onto BASE_BRANCH if ! git rebase origin/${{ env.BASE_BRANCH }} -X theirs; then - echo "Rebase failed, resetting branch to match BASE_BRANCH..." - + echo "Rebase failed, resetting branch to match ${{ env.BASE_BRANCH }}..." + # Abort the rebase process git rebase --abort - # Reset the branch to BASE_BRANCH + echo "Reset branch ${{ env.BRANCH_FOR_PR }}_${{ env.BASE_BRANCH }} to origin/${{ env.BASE_BRANCH }}" git reset --hard origin/${{ env.BASE_BRANCH }} fi git push origin ${{ env.BRANCH_FOR_PR }}_${{ env.BASE_BRANCH }} --force - - name: Run the script + - name: Run script create_new_muted_ya.py run: | .github/scripts/tests/create_new_muted_ya.py update_muted_ya @@ -82,6 +91,7 @@ jobs: fi - name: Collect PR description + if: env.changes == 'true' id: pr_description run: | PR_BODY='' @@ -129,17 +139,16 @@ jobs: git commit -m "Update muted YA file" - name: Push changes + if: env.changes == 'true' uses: ad-m/github-push-action@v0.8.0 with: github_token: ${{ secrets.YDBOT_TOKEN }} branch: ${{ env.BRANCH_FOR_PR }}_${{ env.BASE_BRANCH }} force: true - - name: Install PyGithub - run: | - pip install PyGithub - name: Create or update PR + if: env.changes == 'true' id: create_or_update_pr env: GITHUB_TOKEN: ${{ secrets.YDBOT_TOKEN }} @@ -148,9 +157,8 @@ jobs: - name: Comment PR - continue-on-error: true uses: actions/github-script@v7 - + if: env.changes == 'true' with: github-token: ${{ secrets.YDBOT_TOKEN }} script: | @@ -176,6 +184,7 @@ jobs: }); - name: Add reviewers + if: env.changes == 'true' uses: octokit/request-action@v2.x with: route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers |