actions-rs / clippy-check

📎 GitHub Action for PR annotations with clippy warnings
https://github.com/marketplace/actions/rust-clippy-check
MIT License
287 stars 40 forks source link

Support outputing raw 'clippy' output into a file #159

Open taufik-rama opened 2 years ago

taufik-rama commented 2 years ago

Do the checklist before filing an issue:

Motivation

Basically what the title said, I think it's nice to add support so that the raw output of cargo clippy is stored in a file

Workflow example

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Clippy check
        uses: actions-rs/clippy-check@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          args: --all-features
          output: clippy.json # this new attribute

Additional context

Currently I'm trying to integrate some rust projects with SonarQube action. It needs the clippy output to be parsed & sent into the server

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      # ...
      - name: Code Analysis
        uses: sonarsource/sonarqube-scan-action@master
        with:
          args: -Dsonar.rust.clippy.reportPaths=clippy.json # this is the `cargo clippy` output

Currently I'm only able to do that by basically re-running the cargo clippy command & storing the output

  build:
    runs-on: ubuntu-latest

    steps:
      # ...
      - name: Clippy check (file)
        run: cargo clippy --message-format=json > clippy.json

It would be nice if this action could store the raw output somewhere. For the implementation I could think that a simple tee command could do the trick, like:

$ cargo clippy --message-format=json | tee clippy.json

Would basically produce the same output as usual into stdout & also into a file clippy.json

taufik-rama commented 2 years ago

For the third checklist, I'll try to see how it could be done on the source code

taufik-rama commented 2 years ago

Seems more complicated than I imagine :sweat_smile: , I don't usually use current build system

Other approach that I thought might be possible is to add an input that points to the raw $ cargo clippy output file instead, and we could just read that file instead of doing the exec of cargo inside the script