deptry icon indicating copy to clipboard operation
deptry copied to clipboard

Generate annotations when running inside GitHub Action workflows

Open vitaliyf opened this issue 1 year ago • 2 comments

GitHub supports annotating PRs with comments attached to relevant files/lines - for example, https://github.com/pytest-dev/pytest-github-actions-annotate-failures is a plugin that does this for pytest failures.

Describe the solution you would like

This would be neat to have for deptry when someone runs it inside a GitHub action/workflow since it would visually point at the exact file and line that is causing issues.

It is pretty straightforward to implement - you can see how it's done in the above pytest plugin. At a glance, you already have all relevant information (filename, line number, comment). It can be turned on either with an optional --argument, or automatically detect that it's running within a workflow by inspecting os.environ as is done by pytest plugin: https://github.com/pytest-dev/pytest-github-actions-annotate-failures/blob/v0.2.0/pytest_github_actions_annotate_failures/plugin.py#L36

Additional context

Official documentation for this output format is here: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-setting-a-notice-message

vitaliyf avatar Mar 16 '24 17:03 vitaliyf

Curious if anyone has taken a stab at this in a way that we could integrate into the project?

iloveitaly avatar Nov 06 '24 16:11 iloveitaly

Hi @vitaliyf would love to try, opened a PR, would appreciate your review @iloveitaly FYI

OrenMe avatar Feb 15 '25 07:02 OrenMe