peripheryapp / periphery

A tool to identify unused code in Swift projects.
MIT License
5.02k stars 178 forks source link

Create formatter for GitHub Actions #746

Closed Iron-Ham closed 1 month ago

Iron-Ham commented 1 month ago

This pull request adds a formatter for use with GitHub Actions.

The output of this formatter is meant to work as an actions annotation, as per the Actions Docs.

For example, if I had a file within my Utilities module that had an unused function, it would be output this way:

::warning file=Modules/Utilities/Sources/Utility/Sequence+Contains.swift,line=13,col=10,title=unused::Function 'containsNone(_:)' is unused

Usage

$ periphery scan --relative-results --format actions

[!NOTE] Failure to specify --relative-results will result in a usage error being thrown instructing the user to use --relative-results. GitHub Actions specifically wants relative paths.

When used in CI, we get results directly on pull requests.

Screenshot 2024-05-22 at 12 14 28 PM

New class and methods:

Enum extension:

ileitch commented 1 month ago

Many thanks for this! I renamed the format to github-actions as actions by itself may be ambiguous.