Skip to content

Commit 7cab7c7

Browse files
Integrated checks (#4800)
1 parent 50b9d76 commit 7cab7c7

File tree

6 files changed

+77
-2
lines changed

6 files changed

+77
-2
lines changed

.github/actions/build_and_test_ya/action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@ runs:
6666
check_url=$(curl -s $jobs_url | jq --arg n "$BUILD_PRESET" -r '.jobs[] | select(.name | contains($n)) | .html_url')
6767
6868
echo "Pre-commit [check]($check_url) for $(git rev-parse HEAD) has started." | .github/scripts/tests/comment-pr.py --rewrite
69-
69+
70+
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
71+
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
72+
-d '{"state":"pending","description":"The check has been started","context":"build_${{inputs.build_preset}}"}'
73+
74+
if [[ "${{inputs.run_tests}}" == "true" ]];then
75+
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
76+
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
77+
-d '{"state":"pending","description":"The check has been started","context":"test_${{inputs.build_preset}}"}'
78+
fi
79+
7080
- name: Prepare s3cmd
7181
uses: ./.github/actions/s3cmd
7282
with:

.github/actions/build_ya/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,14 @@ runs:
140140
run: |
141141
set -x
142142
if [ "${{ steps.build.outputs.status }}" == "failed" ]; then
143+
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
144+
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
145+
-d '{"state":"failure","description":"The check has been failed","context":"build_${{inputs.build_preset}}"}'
143146
echo "Build failed. see the [build logs]($LOG_URL)." | .github/scripts/tests/comment-pr.py --fail
144147
else
148+
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
149+
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
150+
-d '{"state":"success","description":"The check has been completed successfully","context":"build_${{inputs.build_preset}}"}'
145151
echo "Build successful." | .github/scripts/tests/comment-pr.py --ok
146152
fi
147153

.github/actions/test_ya/action.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,25 @@ runs:
282282
mkdir $ARTIFACTS_DIR/summary/
283283
284284
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
285-
285+
286286
.github/scripts/tests/generate-summary.py \
287287
--summary-out-path $ARTIFACTS_DIR/summary/ \
288288
--summary-url-prefix $S3_URL_PREFIX/summary/ \
289289
--test-history-url $TEST_HISTORY_URL \
290290
--build-preset "$BUILD_PRESET" \
291+
--status-report-file statusrep.txt \
291292
"Tests" ya-test.html "$JUNIT_REPORT_XML"
292293
294+
teststatus=$(cat statusrep.txt)
295+
if [[ $teststatus == "success" ]];then
296+
testmessage="The check has been completed successfully"
297+
else
298+
testmessage="The check has been failed"
299+
fi
300+
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
301+
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
302+
-d '{"state":"'$teststatus'","description":"'"$testmessage"'","context":"test_${{inputs.build_preset}}"}'
303+
293304
- name: sync test results to s3
294305
if: always()
295306
shell: bash

.github/scripts/tests/generate-summary.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ def main():
324324
parser.add_argument("--summary-url-prefix", required=True)
325325
parser.add_argument('--test-history-url', required=False)
326326
parser.add_argument('--build-preset', default="default-linux-x86-64-relwithdebinfo", required=False)
327+
parser.add_argument('--status-report-file', required=False)
327328
parser.add_argument("args", nargs="+", metavar="TITLE html_out path")
328329
args = parser.parse_args()
329330

@@ -349,13 +350,18 @@ def main():
349350

350351
if summary.is_empty | summary.is_failed:
351352
color = 'red'
353+
overall_status="failure"
352354
else:
353355
color = 'green'
356+
overall_status="success"
354357

355358
run_number = int(os.environ.get("GITHUB_RUN_NUMBER"))
356359

357360
update_pr_comment_text(pr, args.build_preset, run_number, color, text='\n'.join(text), rewrite=False)
358361

362+
if args.status_report_file:
363+
with open(args.status_report_file,'w') as fo:
364+
fo.write( overall_status )
359365

360366
if __name__ == "__main__":
361367
main()

.github/workflows/docs_build.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,22 @@ jobs:
1212
cancel-in-progress: true
1313
runs-on: ubuntu-latest
1414
steps:
15+
- name: Update integrated status
16+
shell: bash
17+
run: |
18+
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
19+
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
20+
-d '{"state":"pending","description":"Waiting for relevant checks to complete","context":"checks_integrated"}'
1521
- name: Checkout
1622
uses: actions/checkout@v3
1723
- name: Build
1824
uses: diplodoc-platform/docs-build-action@v3
1925
with:
2026
revision: "pr-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}"
2127
src-root: "./ydb/docs"
28+
- name: Update integrated status
29+
shell: bash
30+
run: |
31+
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
32+
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
33+
-d '{"state":"success","description":"All checks completed","context":"checks_integrated"}'

.github/workflows/pr_check.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ jobs:
2525
result: ${{ steps.check-ownership-membership.outputs.result == 'true' && steps.check-is-mergeable.outputs.result == 'true' }}
2626
commit_sha: ${{ steps.check-is-mergeable.outputs.commit_sha }}
2727
steps:
28+
- name: Reset integrated status
29+
run: |
30+
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
31+
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
32+
-d '{"state":"pending","description":"Waiting for relevant checks to complete","context":"checks_integrated"}'
33+
2834
- name: Check if running tests is allowed
2935
id: check-ownership-membership
3036
uses: actions/github-script@v6
@@ -225,3 +231,27 @@ jobs:
225231
secrets.TESTMO_TOKEN, secrets.AWS_KEY_ID, secrets.AWS_KEY_VALUE, secrets.REMOTE_CACHE_USERNAME, secrets.REMOTE_CACHE_PASSWORD ) }}
226232
vars: ${{ format('{{"AWS_BUCKET":"{0}","AWS_ENDPOINT":"{1}","REMOTE_CACHE_URL":"{2}","TESTMO_URL":"{3}","TESTMO_PROJECT_ID":"{4}"}}',
227233
vars.AWS_BUCKET, vars.AWS_ENDPOINT, vars.REMOTE_CACHE_URL_YA, vars.TESTMO_URL, vars.TESTMO_PROJECT_ID ) }}
234+
235+
update_integrated_status:
236+
runs-on: ubuntu-latest
237+
needs: build_and_test
238+
if: always()
239+
steps:
240+
- name: Gather required checks results
241+
shell: bash
242+
run: |
243+
successbuilds=$(curl -L -X GET -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
244+
https://api.github.com/repos/${{github.repository}}/commits/${{github.event.pull_request.head.sha}}/status | \
245+
jq -cr '.statuses | .[] | select(.state=="success") | select(.context | startswith("build_")) | .context' | \
246+
wc -l )
247+
if [[ $successbuilds == "3" ]];then
248+
integrated_status="success"
249+
else
250+
integrated_status="failure"
251+
fi
252+
curl -L -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{github.token}}" -H "X-GitHub-Api-Version: 2022-11-28" \
253+
https://api.github.com/repos/${{github.repository}}/statuses/${{github.event.pull_request.head.sha}} \
254+
-d '{"state":"'$integrated_status'","description":"All checks completed","context":"checks_integrated"}'
255+
256+
257+

0 commit comments

Comments
 (0)