Skip to content

Commit

Permalink
Add commit hash in the primer comment (#6783)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
  • Loading branch information
DanielNoord and Pierre-Sassoulas committed Jun 1, 2022
1 parent a0786d3 commit c2b9144
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/primer_comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ jobs:
- name: Compare outputs
run: |
. venv/bin/activate
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
python tests/primer/primer_tool.py compare \
--commit=${{ github.event.workflow_run.head_sha }} \
--base-file=output_${{ steps.python.outputs.python-version }}_main.txt \
--new-file=output_${{ steps.python.outputs.python-version }}_pr.txt
- name: Post comment
id: post-comment
uses: actions/github-script@v6
Expand Down
7 changes: 7 additions & 0 deletions tests/primer/primer_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def __init__(self, json_path: Path) -> None:
required=True,
help="Location of output file of the new run.",
)
compare_parser.add_argument(
"--commit",
required=True,
help="Commit hash of the PR commit being checked.",
)

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

comment += f"*This comment was generated for commit {self.config.commit}*"

with open(PRIMER_DIRECTORY / "comment.txt", "w", encoding="utf-8") as f:
f.write(comment)

Expand Down

0 comments on commit c2b9144

Please sign in to comment.