Skip to content

Commit

Permalink
Integrated checks (ydb-platform#4800)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexv-smirnov authored and MrLolthe1st committed May 28, 2024
1 parent be29735 commit e9182d3
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/actions/build_and_test_ya/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions .github/actions/build_ya/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion .github/actions/test_ya/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions .github/scripts/tests/generate-summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()
12 changes: 12 additions & 0 deletions .github/workflows/docs_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@ 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
uses: diplodoc-platform/docs-build-action@v3
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"}'
30 changes: 30 additions & 0 deletions .github/workflows/pr_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}'

0 comments on commit e9182d3

Please sign in to comment.