From a965392559ba4106f75c19ef22c54ea48297bd6d Mon Sep 17 00:00:00 2001 From: Saumya Jain Date: Wed, 10 Apr 2024 14:16:25 +0200 Subject: [PATCH] Update method for getting PR number and modify output report The code updates the way we fetch the Pull Request number in the Github action. Rather than using an external action, we directly make use of Github's CLI, which helps improve the speed and reliability of the workflow. Additionally, the output report's format in terminal.py, previously named as "Git Comment", has been changed to "Error Files" to better reflect the information it carries. CURA-10903 --- .github/workflows/printer-linter-pr-post.yml | 10 ++++++---- printer-linter/src/terminal.py | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/printer-linter-pr-post.yml b/.github/workflows/printer-linter-pr-post.yml index fd6e63ce78..a71449299d 100644 --- a/.github/workflows/printer-linter-pr-post.yml +++ b/.github/workflows/printer-linter-pr-post.yml @@ -72,14 +72,16 @@ jobs: mkdir printer-linter-result unzip printer-linter-result.zip -d printer-linter-result - - name: Get PR Number - id: get-pr-number - uses: mgaitan/gha-get-pr-number + - name: Get Pull Request Number + id: pr + run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Run PR Comments uses: peter-evans/create-or-update-comment@v4 with: - issue-number: ${{ steps.get-pr-number.outputs.number }} + issue-number: ${{ steps.pr.outputs.pull_request_number }} body-path: 'printer-linter-result/comment.md' - name: Run clang-tidy-pr-comments action diff --git a/printer-linter/src/terminal.py b/printer-linter/src/terminal.py index 3de4c3a979..d8ef7a77cb 100644 --- a/printer-linter/src/terminal.py +++ b/printer-linter/src/terminal.py @@ -42,7 +42,7 @@ def main() -> None: settings = yaml.load(f, yaml.FullLoader) full_body_check = {"Diagnostics": []} - comments_check = {"Git Comment": []} + comments_check = {"Error Files": []} for file in files: if not path.exists(file): @@ -52,7 +52,7 @@ def main() -> None: if args.deleted: for file in args.Files: deletedFiles = diagnoseIssuesWithFile(file, settings ) - comments_check["Git Comment"].extend([d.toDict() for d in deletedFiles]) + comments_check["Error Files"].extend([d.toDict() for d in deletedFiles]) results = yaml.dump(comments_check, default_flow_style=False, indent=4, width=240)