Skip to content

Commit 0e91269

Browse files
committed
Refactor framework coverage job to download artifacts from python
1 parent fa215bc commit 0e91269

File tree

2 files changed

+18
-30
lines changed

2 files changed

+18
-30
lines changed

.github/workflows/csv-coverage-pr-comment.yml

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,13 @@ jobs:
2626
with:
2727
python-version: 3.8
2828

29-
# download artifacts from the PR job:
30-
31-
- name: Download artifact - MERGE
32-
env:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34-
RUN_ID: ${{ github.event.workflow_run.id }}
35-
run: |
36-
gh run download --name "csv-framework-coverage-merge" --dir "out_merge" "$RUN_ID"
37-
38-
- name: Download artifact - BASE
39-
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
RUN_ID: ${{ github.event.workflow_run.id }}
42-
run: |
43-
gh run download --name "csv-framework-coverage-base" --dir "out_base" "$RUN_ID"
44-
45-
- name: Download artifact - PR
46-
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
RUN_ID: ${{ github.event.workflow_run.id }}
49-
run: |
50-
gh run download --name "pr" --dir "pr" "$RUN_ID"
51-
5229
- name: Check coverage files
5330
env:
5431
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5532
RUN_ID: ${{ github.event.workflow_run.id }}
5633
run: |
57-
PR=$(cat "pr/NR")
5834
python misc/scripts/library-coverage/compare-files-comment-pr.py \
59-
out_base out_merge comparison.md "$GITHUB_REPOSITORY" "$PR" "$RUN_ID"
35+
comparison.md "$GITHUB_REPOSITORY" "$RUN_ID"
6036
- name: Upload comparison results
6137
uses: actions/upload-artifact@v2
6238
with:

misc/scripts/library-coverage/compare-files-comment-pr.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,27 @@ def compare_files_str(file1, file2):
4141
return ret
4242

4343

44-
def comment_pr(folder1, folder2, output_file, repo, pr_number, run_id):
44+
def comment_pr(output_file, repo, run_id):
45+
folder1 = "out_base"
46+
folder2 = "out_merge"
47+
utils.subprocess_run(["gh", "run", "download", "--repo", repo, "--name",
48+
"csv-framework-coverage-base", "--dir", folder1, str(run_id)])
49+
utils.subprocess_run(["gh", "run", "download", "--repo", repo, "--name",
50+
"csv-framework-coverage-merge", "--dir", folder2, str(run_id)])
51+
utils.subprocess_run(["gh", "run", "download", "--repo", repo, "--name",
52+
"pr", "--dir", "pr", str(run_id)])
53+
54+
with open("pr/NR") as file:
55+
pr_number = int(file.read())
56+
4557
compare_folders(folder1, folder2, output_file)
4658
size = os.path.getsize(output_file)
4759
if size == 0:
4860
print("No difference in the coverage reports")
4961
return
5062

5163
comment = ":warning: The head of this PR and the base branch were compared for differences in the framework coverage reports. " + \
52-
"The generated reports are available in the [artifacts of this workflow run](https://github.com/" + repo + "/actions/runs/" + run_id + "). " + \
64+
"The generated reports are available in the [artifacts of this workflow run](https://github.com/" + repo + "/actions/runs/" + str(run_id) + "). " + \
5365
"The differences will be picked up by the nightly job after the PR gets merged. "
5466

5567
if size < 2000:
@@ -62,7 +74,7 @@ def comment_pr(folder1, folder2, output_file, repo, pr_number, run_id):
6274
comment += "The differences can be found in the " + \
6375
output_file + " artifact of this job."
6476

65-
post_comment(comment, repo, pr_number)
77+
# post_comment(comment, repo, pr_number)
6678

6779

6880
def post_comment(comment, repo, pr_number):
@@ -125,5 +137,5 @@ def compare_folders(folder1, folder2, output_file):
125137
out.write(return_md)
126138

127139

128-
comment_pr(sys.argv[1], sys.argv[2], sys.argv[3],
129-
sys.argv[4], sys.argv[5], sys.argv[6])
140+
# comment_pr(sys.argv[1], sys.argv[2], sys.argv[3])
141+
comment_pr("x.md", "dsp-testing/codeql-csv-coverage-pr-commenter", 938931471)

0 commit comments

Comments
 (0)