mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:41:23 +00:00
[ty] Add GitHub output format (#20358)
## Summary This PR wires up the GitHub output format moved to `ruff_db` in #20320 to the ty CLI. It's a bit smaller than the GitLab version (#20155) because some of the helpers were already in place, but I did factor out a few `DisplayDiagnosticConfig` constructor calls in Ruff. I also exposed the `GithubRenderer` and a wrapper `DisplayGithubDiagnostics` type because we needed a way to configure the program name displayed in the GitHub diagnostics. This was previously hard-coded to `Ruff`: <img width="675" height="247" alt="image" src="https://github.com/user-attachments/assets/592da860-d2f5-4abd-bc5a-66071d742509" /> Another option would be to drop the program name in the output format, but I think it can be helpful in workflows with multiple programs emitting annotations (such as Ruff and ty!) ## Test Plan New CLI test, and a manual test with `--config 'terminal.output-format = "github"'`
This commit is contained in:
parent
7e464b8150
commit
ac5488086f
11 changed files with 95 additions and 39 deletions
|
@ -324,6 +324,9 @@ pub enum OutputFormat {
|
|||
/// Print diagnostics in the JSON format expected by GitLab Code Quality reports.
|
||||
#[value(name = "gitlab")]
|
||||
Gitlab,
|
||||
#[value(name = "github")]
|
||||
/// Print diagnostics in the format used by GitHub Actions workflow error annotations.
|
||||
Github,
|
||||
}
|
||||
|
||||
impl From<OutputFormat> for ty_project::metadata::options::OutputFormat {
|
||||
|
@ -332,6 +335,7 @@ impl From<OutputFormat> for ty_project::metadata::options::OutputFormat {
|
|||
OutputFormat::Full => Self::Full,
|
||||
OutputFormat::Concise => Self::Concise,
|
||||
OutputFormat::Gitlab => Self::Gitlab,
|
||||
OutputFormat::Github => Self::Github,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue