mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Refactor framework coverage job to download artifacts from python
This commit is contained in:
26
.github/workflows/csv-coverage-pr-comment.yml
vendored
26
.github/workflows/csv-coverage-pr-comment.yml
vendored
@@ -26,37 +26,13 @@ jobs:
|
||||
with:
|
||||
python-version: 3.8
|
||||
|
||||
# download artifacts from the PR job:
|
||||
|
||||
- name: Download artifact - MERGE
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RUN_ID: ${{ github.event.workflow_run.id }}
|
||||
run: |
|
||||
gh run download --name "csv-framework-coverage-merge" --dir "out_merge" "$RUN_ID"
|
||||
|
||||
- name: Download artifact - BASE
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RUN_ID: ${{ github.event.workflow_run.id }}
|
||||
run: |
|
||||
gh run download --name "csv-framework-coverage-base" --dir "out_base" "$RUN_ID"
|
||||
|
||||
- name: Download artifact - PR
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RUN_ID: ${{ github.event.workflow_run.id }}
|
||||
run: |
|
||||
gh run download --name "pr" --dir "pr" "$RUN_ID"
|
||||
|
||||
- name: Check coverage files
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RUN_ID: ${{ github.event.workflow_run.id }}
|
||||
run: |
|
||||
PR=$(cat "pr/NR")
|
||||
python misc/scripts/library-coverage/compare-files-comment-pr.py \
|
||||
out_base out_merge comparison.md "$GITHUB_REPOSITORY" "$PR" "$RUN_ID"
|
||||
comparison.md "$GITHUB_REPOSITORY" "$RUN_ID"
|
||||
- name: Upload comparison results
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
|
||||
@@ -41,7 +41,19 @@ def compare_files_str(file1, file2):
|
||||
return ret
|
||||
|
||||
|
||||
def comment_pr(folder1, folder2, output_file, repo, pr_number, run_id):
|
||||
def comment_pr(output_file, repo, run_id):
|
||||
folder1 = "out_base"
|
||||
folder2 = "out_merge"
|
||||
utils.subprocess_run(["gh", "run", "download", "--repo", repo, "--name",
|
||||
"csv-framework-coverage-base", "--dir", folder1, str(run_id)])
|
||||
utils.subprocess_run(["gh", "run", "download", "--repo", repo, "--name",
|
||||
"csv-framework-coverage-merge", "--dir", folder2, str(run_id)])
|
||||
utils.subprocess_run(["gh", "run", "download", "--repo", repo, "--name",
|
||||
"pr", "--dir", "pr", str(run_id)])
|
||||
|
||||
with open("pr/NR") as file:
|
||||
pr_number = int(file.read())
|
||||
|
||||
compare_folders(folder1, folder2, output_file)
|
||||
size = os.path.getsize(output_file)
|
||||
if size == 0:
|
||||
@@ -49,7 +61,7 @@ def comment_pr(folder1, folder2, output_file, repo, pr_number, run_id):
|
||||
return
|
||||
|
||||
comment = ":warning: The head of this PR and the base branch were compared for differences in the framework coverage reports. " + \
|
||||
"The generated reports are available in the [artifacts of this workflow run](https://github.com/" + repo + "/actions/runs/" + run_id + "). " + \
|
||||
"The generated reports are available in the [artifacts of this workflow run](https://github.com/" + repo + "/actions/runs/" + str(run_id) + "). " + \
|
||||
"The differences will be picked up by the nightly job after the PR gets merged. "
|
||||
|
||||
if size < 2000:
|
||||
@@ -62,7 +74,7 @@ def comment_pr(folder1, folder2, output_file, repo, pr_number, run_id):
|
||||
comment += "The differences can be found in the " + \
|
||||
output_file + " artifact of this job."
|
||||
|
||||
post_comment(comment, repo, pr_number)
|
||||
# post_comment(comment, repo, pr_number)
|
||||
|
||||
|
||||
def post_comment(comment, repo, pr_number):
|
||||
@@ -125,5 +137,5 @@ def compare_folders(folder1, folder2, output_file):
|
||||
out.write(return_md)
|
||||
|
||||
|
||||
comment_pr(sys.argv[1], sys.argv[2], sys.argv[3],
|
||||
sys.argv[4], sys.argv[5], sys.argv[6])
|
||||
# comment_pr(sys.argv[1], sys.argv[2], sys.argv[3])
|
||||
comment_pr("x.md", "dsp-testing/codeql-csv-coverage-pr-commenter", 938931471)
|
||||
|
||||
Reference in New Issue
Block a user