Skip to content

Commit c2b9144

Browse files
Add commit hash in the primer comment (#6783)
Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent a0786d3 commit c2b9144

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.github/workflows/primer_comment.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ jobs:
111111
- name: Compare outputs
112112
run: |
113113
. venv/bin/activate
114-
python tests/primer/primer_tool.py compare --base-file=output_${{ steps.python.outputs.python-version }}_main.txt --new-file=output_${{ steps.python.outputs.python-version }}_pr.txt
114+
python tests/primer/primer_tool.py compare \
115+
--commit=${{ github.event.workflow_run.head_sha }} \
116+
--base-file=output_${{ steps.python.outputs.python-version }}_main.txt \
117+
--new-file=output_${{ steps.python.outputs.python-version }}_pr.txt
115118
- name: Post comment
116119
id: post-comment
117120
uses: actions/github-script@v6

tests/primer/primer_tool.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ def __init__(self, json_path: Path) -> None:
7979
required=True,
8080
help="Location of output file of the new run.",
8181
)
82+
compare_parser.add_argument(
83+
"--commit",
84+
required=True,
85+
help="Commit hash of the PR commit being checked.",
86+
)
8287

8388
# Storing arguments
8489
self.config = self._argument_parser.parse_args()
@@ -256,6 +261,8 @@ def _create_comment(
256261
"🤖 **Effect of this PR on checked open source code:** 🤖\n\n" + comment
257262
)
258263

264+
comment += f"*This comment was generated for commit {self.config.commit}*"
265+
259266
with open(PRIMER_DIRECTORY / "comment.txt", "w", encoding="utf-8") as f:
260267
f.write(comment)
261268

0 commit comments

Comments
 (0)