diff --git a/.github/actions/build_and_test_ya/action.yml b/.github/actions/build_and_test_ya/action.yml index 8c852ad4e0d2..f4ed8b8c5359 100644 --- a/.github/actions/build_and_test_ya/action.yml +++ b/.github/actions/build_and_test_ya/action.yml @@ -66,7 +66,17 @@ runs: check_url=$(curl -s $jobs_url | jq --arg n "$BUILD_PRESET" -r '.jobs[] | select(.name | contains($n)) | .html_url') echo "Pre-commit [check]($check_url) for $(git rev-parse HEAD) has started." | .github/scripts/tests/comment-pr.py --rewrite - + + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \ + -d '{"state":"pending","description":"The check has been started","context":"build_${{inputs.build_preset}}"}' + + if [[ "${{inputs.run_tests}}" == "true" ]];then + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \ + -d '{"state":"pending","description":"The check has been started","context":"test_${{inputs.build_preset}}"}' + fi + - name: Prepare s3cmd uses: ./.github/actions/s3cmd with: diff --git a/.github/actions/build_ya/action.yml b/.github/actions/build_ya/action.yml index 2869db1eb766..91ef4489ae15 100644 --- a/.github/actions/build_ya/action.yml +++ b/.github/actions/build_ya/action.yml @@ -140,8 +140,14 @@ runs: run: | set -x if [ "${{ steps.build.outputs.status }}" == "failed" ]; then + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \ + -d '{"state":"failure","description":"The check has been failed","context":"build_${{inputs.build_preset}}"}' echo "Build failed. see the [build logs]($LOG_URL)." | .github/scripts/tests/comment-pr.py --fail else + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \ + -d '{"state":"success","description":"The check has been completed successfully","context":"build_${{inputs.build_preset}}"}' echo "Build successful." | .github/scripts/tests/comment-pr.py --ok fi diff --git a/.github/actions/test_ya/action.yml b/.github/actions/test_ya/action.yml index 3eb4154e0c13..13963b0f2d37 100644 --- a/.github/actions/test_ya/action.yml +++ b/.github/actions/test_ya/action.yml @@ -282,14 +282,25 @@ runs: mkdir $ARTIFACTS_DIR/summary/ cat $SUMMARY_LINKS | python3 -c 'import sys; print(" | ".join([v for _, v in sorted([l.strip().split(" ", 1) for l in sys.stdin], key=lambda a: (int(a[0]), a))]))' >> $GITHUB_STEP_SUMMARY - + .github/scripts/tests/generate-summary.py \ --summary-out-path $ARTIFACTS_DIR/summary/ \ --summary-url-prefix $S3_URL_PREFIX/summary/ \ --test-history-url $TEST_HISTORY_URL \ --build-preset "$BUILD_PRESET" \ + --status-report-file statusrep.txt \ "Tests" ya-test.html "$JUNIT_REPORT_XML" + teststatus=$(cat statusrep.txt) + if [[ $teststatus == "success" ]];then + testmessage="The check has been completed successfully" + else + testmessage="The check has been failed" + fi + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \ + -d '{"state":"'$teststatus'","description":"'"$testmessage"'","context":"test_${{inputs.build_preset}}"}' + - name: sync test results to s3 if: always() shell: bash diff --git a/.github/scripts/tests/generate-summary.py b/.github/scripts/tests/generate-summary.py index 68700b2623dd..f8b441744bcd 100755 --- a/.github/scripts/tests/generate-summary.py +++ b/.github/scripts/tests/generate-summary.py @@ -324,6 +324,7 @@ def main(): parser.add_argument("--summary-url-prefix", required=True) parser.add_argument('--test-history-url', required=False) parser.add_argument('--build-preset', default="default-linux-x86-64-relwithdebinfo", required=False) + parser.add_argument('--status-report-file', required=False) parser.add_argument("args", nargs="+", metavar="TITLE html_out path") args = parser.parse_args() @@ -349,13 +350,18 @@ def main(): if summary.is_empty | summary.is_failed: color = 'red' + overall_status="failure" else: color = 'green' + overall_status="success" run_number = int(os.environ.get("GITHUB_RUN_NUMBER")) update_pr_comment_text(pr, args.build_preset, run_number, color, text='\n'.join(text), rewrite=False) + if args.status_report_file: + with open(args.status_report_file,'w') as fo: + fo.write( overall_status ) if __name__ == "__main__": main() diff --git a/.github/workflows/docs_build.yaml b/.github/workflows/docs_build.yaml index 63f6a00e8c39..179d0668ee72 100644 --- a/.github/workflows/docs_build.yaml +++ b/.github/workflows/docs_build.yaml @@ -12,6 +12,12 @@ jobs: cancel-in-progress: true runs-on: ubuntu-latest steps: + - name: Update integrated status + shell: bash + run: | + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \ + -d '{"state":"pending","description":"Waiting for relevant checks to complete","context":"checks_integrated"}' - name: Checkout uses: actions/checkout@v3 - name: Build @@ -19,3 +25,9 @@ jobs: with: revision: "pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}" src-root: "./ydb/docs" + - name: Update integrated status + shell: bash + run: | + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \ + -d '{"state":"success","description":"All checks completed","context":"checks_integrated"}' diff --git a/.github/workflows/pr_check.yml b/.github/workflows/pr_check.yml index 48633d40a1e3..84ed514f45c8 100644 --- a/.github/workflows/pr_check.yml +++ b/.github/workflows/pr_check.yml @@ -25,6 +25,12 @@ jobs: result: ${{ steps.check-ownership-membership.outputs.result == 'true' && steps.check-is-mergeable.outputs.result == 'true' }} commit_sha: ${{ steps.check-is-mergeable.outputs.commit_sha }} steps: + - name: Reset integrated status + run: | + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \ + -d '{"state":"pending","description":"Waiting for relevant checks to complete","context":"checks_integrated"}' + - name: Check if running tests is allowed id: check-ownership-membership uses: actions/github-script@v6 @@ -225,3 +231,27 @@ jobs: secrets.TESTMO_TOKEN, secrets.AWS_KEY_ID, secrets.AWS_KEY_VALUE, secrets.REMOTE_CACHE_USERNAME, secrets.REMOTE_CACHE_PASSWORD ) }} vars: ${{ format('{{"AWS_BUCKET":"{0}","AWS_ENDPOINT":"{1}","REMOTE_CACHE_URL":"{2}","TESTMO_URL":"{3}","TESTMO_PROJECT_ID":"{4}"}}', vars.AWS_BUCKET, vars.AWS_ENDPOINT, vars.REMOTE_CACHE_URL_YA, vars.TESTMO_URL, vars.TESTMO_PROJECT_ID ) }} + + update_integrated_status: + runs-on: ubuntu-latest + needs: build_and_test + if: always() + steps: + - name: Gather required checks results + shell: bash + run: | + successbuilds=$(curl -L -X GET -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/commits/${{github.event.pull_request.head.sha}}/status | \ + jq -cr '.statuses | .[] | select(.state=="success") | select(.context | startswith("build_")) | .context' | \ + wc -l ) + if [[ $successbuilds == "3" ]];then + integrated_status="success" + else + integrated_status="failure" + fi + curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \ + -d '{"state":"'$integrated_status'","description":"All checks completed","context":"checks_integrated"}' + + +